📄 triangular.hpp
字号:
typename M::const_iterator2,
typename M::iterator2>::type iterator2_type;
#endif
typedef typename storage_restrict_traits<typename M::storage_category,
packed_proxy_tag>::storage_category storage_category;
typedef typename F::packed_category packed_category;
typedef typename M::orientation_category orientation_category;
// Construction and destruction
BOOST_UBLAS_INLINE
triangular_adaptor ():
matrix_expression<self_type> (),
data_ (nil_) {}
BOOST_UBLAS_INLINE
triangular_adaptor (matrix_type &data):
matrix_expression<self_type> (),
data_ (data) {}
BOOST_UBLAS_INLINE
triangular_adaptor (const triangular_adaptor &m):
matrix_expression<self_type> (),
data_ (m.data_) {}
// Accessors
BOOST_UBLAS_INLINE
size_type size1 () const {
return data_.size1 ();
}
BOOST_UBLAS_INLINE
size_type size2 () const {
return data_.size2 ();
}
BOOST_UBLAS_INLINE
const matrix_closure_type &data () const {
return data_;
}
BOOST_UBLAS_INLINE
matrix_closure_type &data () {
return data_;
}
#ifdef BOOST_UBLAS_DEPRECATED
// Resetting
BOOST_UBLAS_INLINE
void reset (matrix_type &data) {
// References are not retargetable.
// Thanks to Michael Stevens for spotting this.
// data_ = data;
data_.reset (data);
}
#endif
// Element access
#ifndef BOOST_UBLAS_PROXY_CONST_MEMBER
BOOST_UBLAS_INLINE
const_reference operator () (size_type i, size_type j) const {
BOOST_UBLAS_CHECK (i < size1 (), bad_index ());
BOOST_UBLAS_CHECK (j < size2 (), bad_index ());
if (functor_type::other (i, j))
return data () (i, j);
else if (functor_type::one (i, j))
return one_;
else
return zero_;
}
BOOST_UBLAS_INLINE
reference operator () (size_type i, size_type j) {
BOOST_UBLAS_CHECK (i < size1 (), bad_index ());
BOOST_UBLAS_CHECK (j < size2 (), bad_index ());
if (functor_type::other (i, j))
return data () (i, j);
else if (functor_type::one (i, j)) {
#ifndef BOOST_UBLAS_REFERENCE_CONST_MEMBER
// Raising exceptions abstracted as requested during review.
// throw external_logic ();
external_logic ().raise ();
#endif
return one_;
} else {
#ifndef BOOST_UBLAS_REFERENCE_CONST_MEMBER
// Raising exceptions abstracted as requested during review.
// throw external_logic ();
external_logic ().raise ();
#endif
return zero_;
}
}
#else
BOOST_UBLAS_INLINE
reference operator () (size_type i, size_type j) const {
BOOST_UBLAS_CHECK (i < size1 (), bad_index ());
BOOST_UBLAS_CHECK (j < size2 (), bad_index ());
if (functor_type::other (i, j))
return data () (i, j);
else if (functor_type::one (i, j)) {
#ifndef BOOST_UBLAS_REFERENCE_CONST_MEMBER
// Raising exceptions abstracted as requested during review.
// throw external_logic ();
external_logic ().raise ();
#endif
return one_;
} else {
#ifndef BOOST_UBLAS_REFERENCE_CONST_MEMBER
// Raising exceptions abstracted as requested during review.
// throw external_logic ();
external_logic ().raise ();
#endif
return zero_;
}
}
#endif
// Assignment
BOOST_UBLAS_INLINE
triangular_adaptor &operator = (const triangular_adaptor &m) {
matrix_assign (scalar_assign<reference, value_type> (), *this, m);
return *this;
}
BOOST_UBLAS_INLINE
triangular_adaptor &assign_temporary (triangular_adaptor &m) {
*this = m;
return *this;
}
template<class AE>
BOOST_UBLAS_INLINE
triangular_adaptor &operator = (const matrix_expression<AE> &ae) {
matrix_assign (scalar_assign<reference, value_type> (), *this, matrix<value_type> (ae));
return *this;
}
template<class AE>
BOOST_UBLAS_INLINE
triangular_adaptor &assign (const matrix_expression<AE> &ae) {
matrix_assign (scalar_assign<reference, BOOST_UBLAS_TYPENAME AE::value_type> (), *this, ae);
return *this;
}
template<class AE>
BOOST_UBLAS_INLINE
triangular_adaptor& operator += (const matrix_expression<AE> &ae) {
matrix_assign (scalar_assign<reference, value_type> (), *this, matrix<value_type> (*this + ae));
return *this;
}
template<class AE>
BOOST_UBLAS_INLINE
triangular_adaptor &plus_assign (const matrix_expression<AE> &ae) {
matrix_assign (scalar_plus_assign<reference, BOOST_UBLAS_TYPENAME AE::value_type> (), *this, ae);
return *this;
}
template<class AE>
BOOST_UBLAS_INLINE
triangular_adaptor& operator -= (const matrix_expression<AE> &ae) {
matrix_assign (scalar_assign<reference, value_type> (), *this, matrix<value_type> (*this - ae));
return *this;
}
template<class AE>
BOOST_UBLAS_INLINE
triangular_adaptor &minus_assign (const matrix_expression<AE> &ae) {
matrix_assign (scalar_minus_assign<reference, BOOST_UBLAS_TYPENAME AE::value_type> (), *this, ae);
return *this;
}
template<class AT>
BOOST_UBLAS_INLINE
triangular_adaptor& operator *= (const AT &at) {
matrix_assign_scalar (scalar_multiplies_assign<reference, AT> (), *this, at);
return *this;
}
template<class AT>
BOOST_UBLAS_INLINE
triangular_adaptor& operator /= (const AT &at) {
matrix_assign_scalar (scalar_divides_assign<reference, AT> (), *this, at);
return *this;
}
// Comparison
bool operator == (const triangular_adaptor &ta) const {
return (*this).data () == ta.data ();
}
// Swapping
BOOST_UBLAS_INLINE
void swap (triangular_adaptor &m) {
// Too unusual semantic.
// BOOST_UBLAS_CHECK (this != &m, external_logic ());
if (this != &m)
matrix_swap (scalar_swap<reference, reference> (), *this, m);
}
#ifndef BOOST_UBLAS_NO_MEMBER_FRIENDS
BOOST_UBLAS_INLINE
friend void swap (triangular_adaptor &m1, triangular_adaptor &m2) {
m1.swap (m2);
}
#endif
#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR
typedef indexed_iterator1<self_type, packed_random_access_iterator_tag> iterator1;
typedef indexed_iterator2<self_type, packed_random_access_iterator_tag> iterator2;
typedef indexed_const_iterator1<self_type, packed_random_access_iterator_tag> const_iterator1;
typedef indexed_const_iterator2<self_type, packed_random_access_iterator_tag> const_iterator2;
#else
class const_iterator1;
class iterator1;
class const_iterator2;
class iterator2;
#endif
#ifdef BOOST_MSVC_STD_ITERATOR
typedef reverse_iterator_base1<const_iterator1, value_type, const_reference> const_reverse_iterator1;
typedef reverse_iterator_base1<iterator1, value_type, reference> reverse_iterator1;
typedef reverse_iterator_base2<const_iterator2, value_type, const_reference> const_reverse_iterator2;
typedef reverse_iterator_base2<iterator2, value_type, reference> reverse_iterator2;
#else
typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;
typedef reverse_iterator_base1<iterator1> reverse_iterator1;
typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;
typedef reverse_iterator_base2<iterator2> reverse_iterator2;
#endif
// Element lookup
BOOST_UBLAS_INLINE
const_iterator1 find1 (int rank, size_type i, size_type j) const {
if (rank == 1)
i = functor_type::restrict1 (i, j);
return const_iterator1 (*this, data ().find1 (rank, i, j));
}
BOOST_UBLAS_INLINE
iterator1 find1 (int rank, size_type i, size_type j) {
if (rank == 1)
i = functor_type::mutable_restrict1 (i, j);
return iterator1 (*this, data ().find1 (rank, i, j));
}
BOOST_UBLAS_INLINE
const_iterator2 find2 (int rank, size_type i, size_type j) const {
if (rank == 1)
j = functor_type::restrict2 (i, j);
return const_iterator2 (*this, data ().find2 (rank, i, j));
}
BOOST_UBLAS_INLINE
iterator2 find2 (int rank, size_type i, size_type j) {
if (rank == 1)
j = functor_type::mutable_restrict2 (i, j);
return iterator2 (*this, data ().find2 (rank, i, j));
}
// Iterators simply are indices.
#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR
class const_iterator1:
public container_const_reference<triangular_adaptor>,
public random_access_iterator_base<packed_random_access_iterator_tag,
const_iterator1, value_type> {
public:
#ifndef BOOST_MSVC_STD_ITERATOR
typedef typename iterator_restrict_traits<typename const_iterator1_type::iterator_category,
packed_random_access_iterator_tag>::iterator_category iterator_category;
typedef typename const_iterator1_type::difference_type difference_type;
typedef typename const_iterator1_type::value_type value_type;
typedef typename const_iterator1_type::reference reference;
typedef typename const_iterator1_type::pointer pointer;
#else
typedef typename iterator_restrict_traits<typename M::const_iterator1::iterator_category,
packed_random_access_iterator_tag>::iterator_category iterator_category;
typedef const_reference reference;
#endif
typedef const_iterator2 dual_iterator_type;
typedef const_reverse_iterator2 dual_reverse_iterator_type;
// Construction and destruction
BOOST_UBLAS_INLINE
const_iterator1 ():
container_const_reference<self_type> (), it1_ () {}
BOOST_UBLAS_INLINE
const_iterator1 (const self_type &m, const const_iterator1_type &it1):
container_const_reference<self_type> (m), it1_ (it1) {}
BOOST_UBLAS_INLINE
const_iterator1 (const iterator1 &it):
container_const_reference<self_type> (it ()), it1_ (it.it1_) {}
// Arithmetic
BOOST_UBLAS_INLINE
const_iterator1 &operator ++ () {
++ it1_;
return *this;
}
BOOST_UBLAS_INLINE
const_iterator1 &operator -- () {
-- it1_;
return *this;
}
BOOST_UBLAS_INLINE
const_iterator1 &operator += (difference_type n) {
it1_ += n;
return *this;
}
BOOST_UBLAS_INLINE
const_iterator1 &operator -= (difference_type n) {
it1_ -= n;
return *this;
}
BOOST_UBLAS_INLINE
difference_type operator - (const const_iterator1 &it) const {
BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
return it1_ - it.it1_;
}
// Dereference
BOOST_UBLAS_INLINE
reference operator * () const {
size_type i = index1 ();
size_type j = index2 ();
BOOST_UBLAS_CHECK (i < (*this) ().size1 (), bad_index ());
BOOST_UBLAS_CHECK (j < (*this) ().size2 (), bad_index ());
if (functor_type::other (i, j))
return *it1_;
else
return (*this) () (i, j);
}
#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
BOOST_UBLAS_INLINE
#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
typename self_type::
#endif
const_iterator2 begin () const {
return (*this) ().find2 (1, index1 (), 0);
}
BOOST_UBLAS_INLINE
#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
typename self_type::
#endif
const_iterator2 end () const {
return (*this) ().find2 (1, index1 (), (*this) ().size2 ());
}
BOOST_UBLAS_INLINE
#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
typename self_type::
#endif
const_reverse_iterator2 rbegin () const {
return const_reverse_iterator2 (end ());
}
BOOST_UBLAS_INLINE
#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
typename self_type::
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -