10 #ifndef EIGEN_SPARSE_REF_H
11 #define EIGEN_SPARSE_REF_H
16 StandardCompressedFormat = 2
21 template<
typename Derived>
class SparseRefBase;
23 template<
typename MatScalar,
int MatOptions,
typename MatIndex,
int _Options,
typename _Str
ideType>
24 struct traits<Ref<SparseMatrix<MatScalar,MatOptions,MatIndex>, _Options, _StrideType> >
25 :
public traits<SparseMatrix<MatScalar,MatOptions,MatIndex> >
27 typedef SparseMatrix<MatScalar,MatOptions,MatIndex> PlainObjectType;
30 Flags = traits<SparseMatrix<MatScalar,MatOptions,MatIndex> >::Flags |
CompressedAccessBit | NestByRefBit
33 template<
typename Derived>
struct match {
35 StorageOrderMatch = PlainObjectType::IsVectorAtCompileTime || Derived::IsVectorAtCompileTime || ((PlainObjectType::Flags&
RowMajorBit)==(Derived::Flags&
RowMajorBit)),
38 typedef typename internal::conditional<MatchAtCompileTime,internal::true_type,internal::false_type>::type type;
43 template<
typename MatScalar,
int MatOptions,
typename MatIndex,
int _Options,
typename _Str
ideType>
44 struct traits<Ref<const SparseMatrix<MatScalar,MatOptions,MatIndex>, _Options, _StrideType> >
45 :
public traits<Ref<SparseMatrix<MatScalar,MatOptions,MatIndex>, _Options, _StrideType> >
52 template<
typename Derived>
53 struct traits<SparseRefBase<Derived> > :
public traits<Derived> {};
55 template<
typename Derived>
class SparseRefBase
56 :
public SparseMapBase<Derived>
60 typedef SparseMapBase<Derived> Base;
61 _EIGEN_SPARSE_PUBLIC_INTERFACE(SparseRefBase)
64 : Base(RowsAtCompileTime==Dynamic?0:RowsAtCompileTime,ColsAtCompileTime==Dynamic?0:ColsAtCompileTime, 0, 0, 0, 0, 0)
70 template<
typename Expression>
71 void construct(Expression& expr)
73 ::new (static_cast<Base*>(
this)) Base(expr.rows(), expr.cols(), expr.nonZeros(), expr.outerIndexPtr(), expr.innerIndexPtr(), expr.valuePtr(), expr.innerNonZeroPtr());
92 template<typename MatScalar,
int MatOptions, typename MatIndex,
int Options, typename StrideType>
97 typedef internal::traits<Ref> Traits;
98 template<
int OtherOptions>
100 template<
int OtherOptions>
104 typedef internal::SparseRefBase<Ref> Base;
105 _EIGEN_SPARSE_PUBLIC_INTERFACE(Ref)
108 #ifndef EIGEN_PARSED_BY_DOXYGEN
109 template<
int OtherOptions>
113 eigen_assert( ((Options &
int(StandardCompressedFormat))==0) || (expr.isCompressed()) );
114 Base::construct(expr.
derived());
117 template<
int OtherOptions>
121 eigen_assert( ((Options &
int(StandardCompressedFormat))==0) || (expr.isCompressed()) );
122 Base::construct(expr.derived());
125 template<
typename Derived>
126 inline Ref(
const SparseCompressedBase<Derived>& expr)
128 template<
typename Derived>
129 inline Ref(SparseCompressedBase<Derived>& expr)
132 EIGEN_STATIC_ASSERT(
bool(internal::is_lvalue<Derived>::value), THIS_EXPRESSION_IS_NOT_A_LVALUE__IT_IS_READ_ONLY);
133 EIGEN_STATIC_ASSERT(
bool(Traits::template match<Derived>::MatchAtCompileTime), STORAGE_LAYOUT_DOES_NOT_MATCH);
134 eigen_assert( ((Options &
int(StandardCompressedFormat))==0) || (expr.isCompressed()) );
135 Base::construct(expr.const_cast_derived());
140 template<
typename MatScalar,
int MatOptions,
typename MatIndex,
int Options,
typename Str
ideType>
141 class Ref<const
SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType>
142 :
public internal::SparseRefBase<Ref<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> >
145 typedef internal::traits<Ref> Traits;
148 typedef internal::SparseRefBase<Ref> Base;
149 _EIGEN_SPARSE_PUBLIC_INTERFACE(
Ref)
151 template<typename Derived>
154 construct(expr.derived(),
typename Traits::template match<Derived>::type());
157 inline Ref(
const Ref& other) : Base(other) {
161 template<
typename OtherRef>
162 inline Ref(
const RefBase<OtherRef>& other) {
163 construct(other.derived(),
typename Traits::template match<OtherRef>::type());
168 template<
typename Expression>
169 void construct(
const Expression& expr,internal::true_type)
171 if((Options &
int(StandardCompressedFormat)) && (!expr.isCompressed()))
174 Base::construct(m_object);
178 Base::construct(expr);
182 template<
typename Expression>
183 void construct(
const Expression& expr, internal::false_type)
186 Base::construct(m_object);
190 TPlainObjectType m_object;
196 template<
typename MatScalar,
int MatOptions,
typename MatIndex,
int Options,
typename Str
ideType>
197 struct evaluator<Ref<SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> >
198 : evaluator<SparseCompressedBase<Ref<SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> > >
200 typedef evaluator<SparseCompressedBase<Ref<SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> > > Base;
201 typedef Ref<SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> XprType;
202 evaluator() : Base() {}
203 explicit evaluator(
const XprType &mat) : Base(mat) {}
206 template<
typename MatScalar,
int MatOptions,
typename MatIndex,
int Options,
typename Str
ideType>
207 struct evaluator<Ref<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> >
208 : evaluator<SparseCompressedBase<Ref<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> > >
210 typedef evaluator<SparseCompressedBase<Ref<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> > > Base;
211 typedef Ref<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> XprType;
212 evaluator() : Base() {}
213 explicit evaluator(
const XprType &mat) : Base(mat) {}
220 #endif // EIGEN_SPARSE_REF_H
const unsigned int CompressedAccessBit
Definition: Constants.h:177
A versatible sparse matrix representation.
Definition: SparseMatrix.h:92
const unsigned int LvalueBit
Definition: Constants.h:130
Derived & derived()
Definition: EigenBase.h:44
const unsigned int RowMajorBit
Definition: Constants.h:53
Base class of any sparse matrices or sparse expressions.
Definition: SparseMatrixBase.h:26
A matrix or vector expression mapping an existing expression.
Definition: Ref.h:186
Definition: Eigen_Colamd.h:54
Sparse matrix.
Definition: MappedSparseMatrix.h:32