📄 hermitian.hpp
字号:
reference operator * () const {
return (*this) () (it1_, it2_);
}
#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
BOOST_UBLAS_INLINE
#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
typename self_type::
#endif
const_iterator1 begin () const {
return (*this) ().find1 (1, 0, it2_);
}
BOOST_UBLAS_INLINE
#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
typename self_type::
#endif
const_iterator1 end () const {
return (*this) ().find1 (1, (*this) ().size1 (), it2_);
}
BOOST_UBLAS_INLINE
#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
typename self_type::
#endif
const_reverse_iterator1 rbegin () const {
return const_reverse_iterator1 (end ());
}
BOOST_UBLAS_INLINE
#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
typename self_type::
#endif
const_reverse_iterator1 rend () const {
return const_reverse_iterator1 (begin ());
}
#endif
// Indices
BOOST_UBLAS_INLINE
size_type index1 () const {
return it1_;
}
BOOST_UBLAS_INLINE
size_type index2 () const {
return it2_;
}
// Assignment
BOOST_UBLAS_INLINE
const_iterator2 &operator = (const const_iterator2 &it) {
container_const_reference<self_type>::assign (&it ());
it1_ = it.it1_;
it2_ = it.it2_;
return *this;
}
// Comparison
BOOST_UBLAS_INLINE
bool operator == (const const_iterator2 &it) const {
BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ());
return it2_ == it.it2_;
}
BOOST_UBLAS_INLINE
bool operator < (const const_iterator2 &it) const {
BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ());
return it2_ < it.it2_;
}
private:
size_type it1_;
size_type it2_;
};
#endif
BOOST_UBLAS_INLINE
const_iterator2 begin2 () const {
return find2 (0, 0, 0);
}
BOOST_UBLAS_INLINE
const_iterator2 end2 () const {
return find2 (0, 0, size_);
}
#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR
class iterator2:
public container_reference<hermitian_matrix>,
public random_access_iterator_base<packed_random_access_iterator_tag,
iterator2, value_type> {
public:
typedef packed_random_access_iterator_tag iterator_category;
#ifndef BOOST_MSVC_STD_ITERATOR
typedef typename hermitian_matrix::difference_type difference_type;
typedef typename hermitian_matrix::value_type value_type;
typedef typename hermitian_matrix::reference reference;
typedef typename hermitian_matrix::pointer pointer;
#endif
typedef iterator1 dual_iterator_type;
typedef reverse_iterator1 dual_reverse_iterator_type;
// Construction and destruction
BOOST_UBLAS_INLINE
iterator2 ():
container_reference<self_type> (), it1_ (), it2_ () {}
BOOST_UBLAS_INLINE
iterator2 (self_type &m, size_type it1, size_type it2):
container_reference<self_type> (m), it1_ (it1), it2_ (it2) {}
// Arithmetic
BOOST_UBLAS_INLINE
iterator2 &operator ++ () {
++ it2_;
return *this;
}
BOOST_UBLAS_INLINE
iterator2 &operator -- () {
-- it2_;
return *this;
}
BOOST_UBLAS_INLINE
iterator2 &operator += (difference_type n) {
it2_ += n;
return *this;
}
BOOST_UBLAS_INLINE
iterator2 &operator -= (difference_type n) {
it2_ -= n;
return *this;
}
BOOST_UBLAS_INLINE
difference_type operator - (const iterator2 &it) const {
BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ());
return it2_ - it.it2_;
}
// Dereference
BOOST_UBLAS_INLINE
reference operator * () const {
return (*this) () (it1_, it2_);
}
#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
BOOST_UBLAS_INLINE
#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
typename self_type::
#endif
iterator1 begin () const {
return (*this) ().find1 (1, 0, it2_);
}
BOOST_UBLAS_INLINE
#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
typename self_type::
#endif
iterator1 end () const {
return (*this) ().find1 (1, (*this) ().size1 (), it2_);
}
BOOST_UBLAS_INLINE
#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
typename self_type::
#endif
reverse_iterator1 rbegin () const {
return reverse_iterator1 (end ());
}
BOOST_UBLAS_INLINE
#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
typename self_type::
#endif
reverse_iterator1 rend () const {
return reverse_iterator1 (begin ());
}
#endif
// Indices
BOOST_UBLAS_INLINE
size_type index1 () const {
return it1_;
}
BOOST_UBLAS_INLINE
size_type index2 () const {
return it2_;
}
// Assignment
BOOST_UBLAS_INLINE
iterator2 &operator = (const iterator2 &it) {
container_reference<self_type>::assign (&it ());
it1_ = it.it1_;
it2_ = it.it2_;
return *this;
}
// Comparison
BOOST_UBLAS_INLINE
bool operator == (const iterator2 &it) const {
BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ());
return it2_ == it.it2_;
}
BOOST_UBLAS_INLINE
bool operator < (const iterator2 &it) const {
BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ());
return it2_ < it.it2_;
}
private:
size_type it1_;
size_type it2_;
friend class const_iterator2;
};
#endif
BOOST_UBLAS_INLINE
iterator2 begin2 () {
return find2 (0, 0, 0);
}
BOOST_UBLAS_INLINE
iterator2 end2 () {
return find2 (0, 0, size_);
}
// Reverse iterators
BOOST_UBLAS_INLINE
const_reverse_iterator1 rbegin1 () const {
return const_reverse_iterator1 (end1 ());
}
BOOST_UBLAS_INLINE
const_reverse_iterator1 rend1 () const {
return const_reverse_iterator1 (begin1 ());
}
BOOST_UBLAS_INLINE
reverse_iterator1 rbegin1 () {
return reverse_iterator1 (end1 ());
}
BOOST_UBLAS_INLINE
reverse_iterator1 rend1 () {
return reverse_iterator1 (begin1 ());
}
BOOST_UBLAS_INLINE
const_reverse_iterator2 rbegin2 () const {
return const_reverse_iterator2 (end2 ());
}
BOOST_UBLAS_INLINE
const_reverse_iterator2 rend2 () const {
return const_reverse_iterator2 (begin2 ());
}
BOOST_UBLAS_INLINE
reverse_iterator2 rbegin2 () {
return reverse_iterator2 (end2 ());
}
BOOST_UBLAS_INLINE
reverse_iterator2 rend2 () {
return reverse_iterator2 (begin2 ());
}
private:
size_type size_;
array_type data_;
static value_type conj_;
};
template<class T, class F1, class F2, class A>
typename hermitian_matrix<T, F1, F2, A>::value_type hermitian_matrix<T, F1, F2, A>::conj_;
// Hermitian matrix adaptor class
template<class M, class F>
class hermitian_adaptor:
public matrix_expression<hermitian_adaptor<M, F> > {
public:
#ifndef BOOST_UBLAS_NO_PROXY_SHORTCUTS
BOOST_UBLAS_USING matrix_expression<hermitian_adaptor<M, F> >::operator ();
#endif
typedef const M const_matrix_type;
typedef M matrix_type;
typedef F functor_type;
typedef typename M::size_type size_type;
typedef typename M::difference_type difference_type;
typedef typename M::value_type value_type;
#ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS
// FIXME: no better way to not return the address of a temporary?
// typedef typename M::const_reference const_reference;
typedef typename M::value_type const_reference;
#ifndef BOOST_UBLAS_STRICT_HERMITIAN
typedef typename M::reference reference;
#else
typedef hermitian_matrix_element<hermitian_adaptor<M, F> > reference;
#endif
typedef typename M::const_pointer const_pointer;
typedef typename M::pointer pointer;
#else
// FIXME: no better way to not return the address of a temporary?
// typedef typename M::const_reference const_reference;
// typedef typename boost::mpl::if_c<boost::is_const<M>::value,
// typename M::const_reference,
// typename M::reference>::type reference;
typedef typename M::value_type const_reference;
#ifndef BOOST_UBLAS_STRICT_HERMITIAN
typedef typename boost::mpl::if_c<boost::is_const<M>::value,
typename M::value_type,
typename M::reference>::type reference;
#else
typedef typename boost::mpl::if_c<boost::is_const<M>::value,
typename M::value_type,
hermitian_matrix_element<const hermitian_adaptor<M, F> > >::type reference;
#endif
typedef typename M::const_pointer const_pointer;
typedef typename boost::mpl::if_c<boost::is_const<M>::value,
typename M::const_pointer,
typename M::pointer>::type pointer;
#endif
#ifndef BOOST_UBLAS_CT_PROXY_CLOSURE_TYPEDEFS
typedef typename M::closure_type matrix_closure_type;
#else
typedef typename boost::mpl::if_c<boost::is_const<M>::value,
typename M::const_closure_type,
typename M::closure_type>::type matrix_closure_type;
#endif
typedef const hermitian_adaptor<M, F> const_self_type;
typedef hermitian_adaptor<M, F> self_type;
typedef const_self_type const_closure_type;
typedef self_type closure_type;
#ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS
typedef typename M::const_iterator1 const_iterator1_type;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -