📄 matrix.hpp
字号:
}
#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 {
const self_type &m = (*this) ();
return m.find1 (1, 0, index2 ());
}
BOOST_UBLAS_INLINE
#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
typename self_type::
#endif
const_iterator1 end () const {
const self_type &m = (*this) ();
return m.find1 (1, m.size1 (), index2 ());
}
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 {
const self_type &m = (*this) ();
return functor_type::index1 (it_ - m.begin2 ().it_, m.size1 (), m.size2 ());
}
BOOST_UBLAS_INLINE
size_type index2 () const {
const self_type &m = (*this) ();
return functor_type::index2 (it_ - m.begin2 ().it_, m.size1 (), m.size2 ());
}
// Assignment
BOOST_UBLAS_INLINE
const_iterator2 &operator = (const const_iterator2 &it) {
container_const_reference<self_type>::assign (&it ());
it_ = it.it_;
return *this;
}
// Comparison
BOOST_UBLAS_INLINE
bool operator == (const const_iterator2 &it) const {
BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
return it_ == it.it_;
}
BOOST_UBLAS_INLINE
bool operator < (const const_iterator2 &it) const {
BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
return it_ < it.it_;
}
private:
const_iterator_type it_;
friend class iterator2;
};
#endif
BOOST_UBLAS_INLINE
const_iterator2 begin2 () const {
return find2 (0, 0, 0);
}
BOOST_UBLAS_INLINE
const_iterator2 end2 () const {
return find2 (0, 0, size2_);
}
#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR
class iterator2:
public container_reference<matrix>,
public random_access_iterator_base<dense_random_access_iterator_tag,
iterator2, value_type> {
public:
typedef dense_random_access_iterator_tag iterator_category;
#ifndef BOOST_MSVC_STD_ITERATOR
typedef typename matrix::difference_type difference_type;
typedef typename matrix::value_type value_type;
typedef typename matrix::reference reference;
typedef typename 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> (), it_ () {}
BOOST_UBLAS_INLINE
iterator2 (self_type &m, const iterator_type &it):
container_reference<self_type> (m), it_ (it) {}
// Arithmetic
BOOST_UBLAS_INLINE
iterator2 &operator ++ () {
functor_type::increment2 (it_, (*this) ().size1 (), (*this) ().size2 ());
return *this;
}
BOOST_UBLAS_INLINE
iterator2 &operator -- () {
functor_type::decrement2 (it_, (*this) ().size1 (), (*this) ().size2 ());
return *this;
}
BOOST_UBLAS_INLINE
iterator2 &operator += (difference_type n) {
it_ += n * functor_type::one2 ((*this) ().size1 (), (*this) ().size2 ());
return *this;
}
BOOST_UBLAS_INLINE
iterator2 &operator -= (difference_type n) {
it_ -= n * functor_type::one2 ((*this) ().size1 (), (*this) ().size2 ());
return *this;
}
BOOST_UBLAS_INLINE
difference_type operator - (const iterator2 &it) const {
BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
return functor_type::distance2 (it_ - it.it_, (*this) ().size1 (), (*this) ().size2 ());
}
// Dereference
BOOST_UBLAS_INLINE
reference operator * () const {
BOOST_UBLAS_CHECK (index1 () < (*this) ().size1 (), bad_index ());
BOOST_UBLAS_CHECK (index2 () < (*this) ().size2 (), bad_index ());
return *it_;
}
#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
BOOST_UBLAS_INLINE
#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
typename self_type::
#endif
iterator1 begin () const {
self_type &m = (*this) ();
return m.find1 (1, 0, index2 ());
}
BOOST_UBLAS_INLINE
#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
typename self_type::
#endif
iterator1 end () const {
self_type &m = (*this) ();
return m.find1 (1, m.size1 (), index2 ());
}
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 {
self_type &m = (*this) ();
return functor_type::index1 (it_ - m.begin2 ().it_, m.size1 (), m.size2 ());
}
BOOST_UBLAS_INLINE
size_type index2 () const {
self_type &m = (*this) ();
return functor_type::index2 (it_ - m.begin2 ().it_, m.size1 (), m.size2 ());
}
// Assignment
BOOST_UBLAS_INLINE
iterator2 &operator = (const iterator2 &it) {
container_reference<self_type>::assign (&it ());
it_ = it.it_;
return *this;
}
// Comparison
BOOST_UBLAS_INLINE
bool operator == (const iterator2 &it) const {
BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
return it_ == it.it_;
}
BOOST_UBLAS_INLINE
bool operator < (const iterator2 &it) const {
BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
return it_ < it.it_;
}
private:
iterator_type it_;
friend class const_iterator2;
};
#endif
BOOST_UBLAS_INLINE
iterator2 begin2 () {
return find2 (0, 0, 0);
}
BOOST_UBLAS_INLINE
iterator2 end2 () {
return find2 (0, 0, size2_);
}
// 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 size1_;
size_type size2_;
array_type data_;
};
// Bounded matrix class
template<class T, std::size_t M, std::size_t N, class F>
class bounded_matrix:
public matrix<T, F, bounded_array<T, M * N> > {
public:
#ifndef BOOST_UBLAS_NO_DERIVED_HELPERS
BOOST_UBLAS_USING matrix<T, F, bounded_array<T, M * N> >::operator =;
#endif
BOOST_STATIC_CONSTANT (std::size_t, max_size1 = M);
BOOST_STATIC_CONSTANT (std::size_t, max_size2 = N);
typedef matrix<T, F, bounded_array<T, M * N> > matrix_type;
// Construction and destruction
BOOST_UBLAS_INLINE
bounded_matrix ():
matrix_type (M, N) {}
BOOST_UBLAS_INLINE
bounded_matrix (std::size_t size1, std::size_t size2):
matrix_type (size1, size2) {}
template<class AE>
BOOST_UBLAS_INLINE
bounded_matrix (const matrix_expression<AE> &ae):
matrix_type (ae) {}
BOOST_UBLAS_INLINE
~bounded_matrix () {}
// Assignment
BOOST_UBLAS_INLINE
bounded_matrix &operator = (const bounded_matrix &m) {
matrix_type::operator = (m);
return *this;
}
};
// Array based matrix class
template<class T, class F, class A>
class vector_of_vector:
public matrix_expression<vector_of_vector<T, F, A> > {
public:
#ifndef BOOST_UBLAS_NO_PROXY_SHORTCUTS
BOOST_UBLAS_USING matrix_expression<vector_of_vector<T, F, A> >::operator ();
#endif
typedef concrete_tag simd_category;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef T value_type;
// typedef const T &const_reference;
typedef typename type_traits<T>::const_reference const_reference;
typedef T &reference;
typedef const T *const_pointer;
typedef T *pointer;
typedef F functor_type;
typedef A array_type;
typedef const A const_array_type;
typedef const vector_of_vector<T, F, A> const_self_type;
typedef vector_of_vector<T, F, A> self_type;
#ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS
typedef const matrix_const_reference<const_self_type> const_closure_type;
#else
typedef const matrix_reference<const_self_type> const_closure_type;
#endif
typedef matrix_reference<self_type> closure_type;
typedef typename A::const_iterator vector_const_iterator_type;
typedef typename A::iterator vector_iterator_type;
typedef typename A::value_type::const_iterator const_iterator_type;
typedef typename A::value_type::iterator iterator_type;
typedef dense_tag storage_category;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -