00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef MTL_HERMITIAN_VIEW_INCLUDE
00013 #define MTL_HERMITIAN_VIEW_INCLUDE
00014
00015 #include <iostream>
00016 #include <boost/shared_ptr.hpp>
00017 #include <boost/numeric/mtl/matrix/map_view.hpp>
00018 #include <boost/numeric/mtl/matrix/transposed_view.hpp>
00019 #include <boost/numeric/mtl/operation/conj.hpp>
00020 #include <boost/numeric/mtl/concept/collection.hpp>
00021
00022
00023 namespace mtl { namespace matrix {
00024
00025 template <class Matrix>
00026 struct hermitian_view
00027 : private transposed_view<Matrix>,
00028 public map_view<mtl::sfunctor::conj<typename Matrix::value_type>,
00029 transposed_view<Matrix> >
00030 {
00031 typedef transposed_view<Matrix> trans_base;
00032 typedef mtl::sfunctor::conj<typename Matrix::value_type> functor_type;
00033 typedef map_view<functor_type, transposed_view<Matrix> > base;
00034 typedef hermitian_view self;
00035 typedef const Matrix& const_ref_type;
00036 typedef typename Collection<Matrix>::size_type size_type;
00037 typedef typename Collection<Matrix>::value_type value_type;
00038
00039 hermitian_view(const Matrix& matrix)
00040 : trans_base(const_cast<Matrix&>(matrix)),
00041 base(functor_type(), static_cast<trans_base&>(*this))
00042 {}
00043
00044 #if 0
00045 hermitian_view(boost::shared_ptr<Matrix> p)
00046 : trans_base(p), base(functor_type(), static_cast<trans_base&>(*this))
00047 {}
00048 #endif
00049
00050 typename base::value_type operator()(size_type r, size_type c) const { return base::operator()(r, c); }
00051
00052 friend size_type inline num_rows(const self& A) { return num_rows((const base&)(A)); }
00053 friend size_type inline num_cols(const self& A) { return num_cols((const base&)(A)); }
00054 friend size_type inline size(const self& A) { return size((const base&)(A)); }
00055
00056 const_ref_type inline const_ref() const { return base::ref.ref; }
00057
00058 friend inline std::ostream& operator<<(std::ostream& os, const self& A) { return os << (const base&)(A); }
00059 };
00060
00061
00062
00063
00064
00065 }}
00066
00067
00068
00069
00070 namespace mtl { namespace traits {
00071
00072 template <typename Matrix>
00073 struct row< mtl::matrix::hermitian_view<Matrix> >
00074 : public row< mtl::matrix::map_view<sfunctor::conj<typename Matrix::value_type>,
00075 transposed_view<Matrix> > >
00076 {};
00077
00078 template <typename Matrix>
00079 struct col< mtl::matrix::hermitian_view<Matrix> >
00080 : public col< mtl::matrix::map_view<sfunctor::conj<typename Matrix::value_type>,
00081 transposed_view<Matrix> > >
00082 {};
00083
00084 template <typename Matrix>
00085 struct const_value< mtl::matrix::hermitian_view<Matrix> >
00086 : public const_value< mtl::matrix::map_view<sfunctor::conj<typename Matrix::value_type>,
00087 transposed_view<Matrix> > >
00088 {};
00089
00090 template <typename Tag, typename Matrix>
00091 struct range_generator< Tag, mtl::matrix::hermitian_view<Matrix> >
00092 : public range_generator< Tag, mtl::matrix::map_view<sfunctor::conj<typename Matrix::value_type>,
00093 transposed_view<Matrix> > >
00094 {};
00095
00096 template <typename Matrix>
00097 struct range_generator< tag::major, mtl::matrix::hermitian_view<Matrix> >
00098 : public range_generator< tag::major, mtl::matrix::map_view<sfunctor::conj<typename Matrix::value_type>,
00099 transposed_view<Matrix> > >
00100 {};
00101
00102
00103 }}
00104
00105 #endif // MTL_HERMITIAN_VIEW_INCLUDE