10 #ifndef EIGEN_SPARSE_REF_H
11 #define EIGEN_SPARSE_REF_H
23 template<
typename Derived>
class SparseRefBase;
25 template<
typename MatScalar,
int MatOptions,
typename MatIndex,
int Options_,
typename Str
ideType_>
26 struct traits<Ref<SparseMatrix<MatScalar,MatOptions,MatIndex>, Options_, StrideType_> >
27 :
public traits<SparseMatrix<MatScalar,MatOptions,MatIndex> >
29 typedef SparseMatrix<MatScalar,MatOptions,MatIndex> PlainObjectType;
35 template<
typename Derived>
struct match {
37 StorageOrderMatch = PlainObjectType::IsVectorAtCompileTime || Derived::IsVectorAtCompileTime || ((PlainObjectType::Flags&
RowMajorBit)==(Derived::Flags&
RowMajorBit)),
40 typedef std::conditional_t<MatchAtCompileTime,internal::true_type,internal::false_type> type;
45 template<
typename MatScalar,
int MatOptions,
typename MatIndex,
int Options_,
typename Str
ideType_>
46 struct traits<Ref<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options_, StrideType_> >
47 :
public traits<Ref<SparseMatrix<MatScalar,MatOptions,MatIndex>, Options_, StrideType_> >
54 template<
typename MatScalar,
int MatOptions,
typename MatIndex,
int Options_,
typename Str
ideType_>
55 struct traits<Ref<SparseVector<MatScalar,MatOptions,MatIndex>, Options_, StrideType_> >
56 :
public traits<SparseVector<MatScalar,MatOptions,MatIndex> >
58 typedef SparseVector<MatScalar,MatOptions,MatIndex> PlainObjectType;
64 template<
typename Derived>
struct match {
68 typedef std::conditional_t<MatchAtCompileTime,internal::true_type,internal::false_type> type;
73 template<
typename MatScalar,
int MatOptions,
typename MatIndex,
int Options_,
typename Str
ideType_>
74 struct traits<Ref<const SparseVector<MatScalar,MatOptions,MatIndex>, Options_, StrideType_> >
75 :
public traits<Ref<SparseVector<MatScalar,MatOptions,MatIndex>, Options_, StrideType_> >
82 template<
typename Derived>
83 struct traits<SparseRefBase<Derived> > :
public traits<Derived> {};
85 template<
typename Derived>
class SparseRefBase
86 :
public SparseMapBase<Derived>
90 typedef SparseMapBase<Derived> Base;
94 : Base(RowsAtCompileTime==
Dynamic?0:RowsAtCompileTime,ColsAtCompileTime==
Dynamic?0:ColsAtCompileTime, 0, 0, 0, 0, 0)
99 template<
typename Expression>
100 void construct(Expression& expr)
102 if(expr.outerIndexPtr()==0)
103 internal::construct_at<Base>(
this, expr.size(), expr.nonZeros(), expr.innerIndexPtr(), expr.valuePtr());
105 internal::construct_at<Base>(
this, expr.rows(), expr.cols(), expr.nonZeros(), expr.outerIndexPtr(), expr.innerIndexPtr(), expr.valuePtr(), expr.innerNonZeroPtr());
123 #ifndef EIGEN_PARSED_BY_DOXYGEN
124 template<
typename MatScalar,
int MatOptions,
typename MatIndex,
int Options,
typename Str
ideType>
125 class Ref<SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType >
126 :
public internal::SparseRefBase<Ref<SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType > >
128 template<typename SparseMatrixType, int Options>
129 class
Ref<SparseMatrixType, Options>
135 template<
int OtherOptions>
137 template<
int OtherOptions>
141 typedef internal::SparseRefBase<Ref>
Base;
145 #ifndef EIGEN_PARSED_BY_DOXYGEN
146 template<
int OtherOptions>
154 template<
int OtherOptions>
162 template<
typename Derived>
163 inline Ref(
const SparseCompressedBase<Derived>& expr)
166 template<
typename Derived>
170 EIGEN_STATIC_ASSERT(
bool(internal::is_lvalue<Derived>::value), THIS_EXPRESSION_IS_NOT_A_LVALUE__IT_IS_READ_ONLY);
171 EIGEN_STATIC_ASSERT(
bool(Traits::template match<Derived>::MatchAtCompileTime), STORAGE_LAYOUT_DOES_NOT_MATCH);
178 template<
typename MatScalar,
int MatOptions,
typename MatIndex,
int Options,
typename Str
ideType>
180 :
public internal::SparseRefBase<Ref<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> >
186 typedef internal::SparseRefBase<Ref>
Base;
189 template<
typename Derived>
192 construct(expr.
derived(),
typename Traits::template match<Derived>::type());
195 inline Ref(
const Ref& other) :
Base(other), m_hasCopy(false) {
199 template<
typename OtherRef>
201 construct(other.derived(),
typename Traits::template match<OtherRef>::type());
212 template<
typename Expression>
213 void construct(
const Expression& expr,internal::true_type)
227 template<
typename Expression>
228 void construct(
const Expression& expr, internal::false_type)
251 #ifndef EIGEN_PARSED_BY_DOXYGEN
252 template<
typename MatScalar,
int MatOptions,
typename MatIndex,
int Options,
typename Str
ideType>
253 class Ref<
SparseVector<MatScalar,MatOptions,MatIndex>, Options, StrideType >
254 :
public internal::SparseRefBase<Ref<SparseVector<MatScalar,MatOptions,MatIndex>, Options, StrideType > >
256 template<typename SparseVectorType>
257 class
Ref<SparseVectorType>
263 template<
int OtherOptions>
267 typedef internal::SparseRefBase<Ref>
Base;
270 #ifndef EIGEN_PARSED_BY_DOXYGEN
271 template<
int OtherOptions>
278 template<
typename Derived>
282 template<
typename Derived>
286 EIGEN_STATIC_ASSERT(
bool(internal::is_lvalue<Derived>::value), THIS_EXPRESSION_IS_NOT_A_LVALUE__IT_IS_READ_ONLY);
287 EIGEN_STATIC_ASSERT(
bool(Traits::template match<Derived>::MatchAtCompileTime), STORAGE_LAYOUT_DOES_NOT_MATCH);
293 template<
typename MatScalar,
int MatOptions,
typename MatIndex,
int Options,
typename Str
ideType>
295 :
public internal::SparseRefBase<Ref<const SparseVector<MatScalar,MatOptions,MatIndex>, Options, StrideType> >
301 typedef internal::SparseRefBase<Ref>
Base;
304 template<
typename Derived>
307 construct(expr.
derived(),
typename Traits::template match<Derived>::type());
310 inline Ref(
const Ref& other) :
Base(other), m_hasCopy(false) {
314 template<
typename OtherRef>
316 construct(other.derived(),
typename Traits::template match<OtherRef>::type());
327 template<
typename Expression>
328 void construct(
const Expression& expr,internal::true_type)
333 template<
typename Expression>
334 void construct(
const Expression& expr, internal::false_type)
350 template<
typename MatScalar,
int MatOptions,
typename MatIndex,
int Options,
typename Str
ideType>
351 struct evaluator<
Ref<
SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> >
352 : evaluator<SparseCompressedBase<Ref<SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> > >
354 typedef evaluator<SparseCompressedBase<Ref<SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> > > Base;
356 evaluator() : Base() {}
357 explicit evaluator(
const XprType &
mat) : Base(
mat) {}
360 template<
typename MatScalar,
int MatOptions,
typename MatIndex,
int Options,
typename Str
ideType>
361 struct evaluator<Ref<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> >
362 : evaluator<SparseCompressedBase<Ref<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> > >
364 typedef evaluator<SparseCompressedBase<Ref<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> > > Base;
365 typedef Ref<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> XprType;
366 evaluator() : Base() {}
367 explicit evaluator(
const XprType &
mat) : Base(
mat) {}
370 template<
typename MatScalar,
int MatOptions,
typename MatIndex,
int Options,
typename Str
ideType>
371 struct evaluator<Ref<SparseVector<MatScalar,MatOptions,MatIndex>, Options, StrideType> >
372 : evaluator<SparseCompressedBase<Ref<SparseVector<MatScalar,MatOptions,MatIndex>, Options, StrideType> > >
374 typedef evaluator<SparseCompressedBase<Ref<SparseVector<MatScalar,MatOptions,MatIndex>, Options, StrideType> > > Base;
375 typedef Ref<SparseVector<MatScalar,MatOptions,MatIndex>, Options, StrideType> XprType;
376 evaluator() : Base() {}
377 explicit evaluator(
const XprType &
mat) : Base(
mat) {}
380 template<
typename MatScalar,
int MatOptions,
typename MatIndex,
int Options,
typename Str
ideType>
381 struct evaluator<Ref<const SparseVector<MatScalar,MatOptions,MatIndex>, Options, StrideType> >
382 : evaluator<SparseCompressedBase<Ref<const SparseVector<MatScalar,MatOptions,MatIndex>, Options, StrideType> > >
384 typedef evaluator<SparseCompressedBase<Ref<const SparseVector<MatScalar,MatOptions,MatIndex>, Options, StrideType> > > Base;
385 typedef Ref<const SparseVector<MatScalar,MatOptions,MatIndex>, Options, StrideType> XprType;
386 evaluator() : Base() {}
387 explicit evaluator(
const XprType &
mat) : Base(
mat) {}
#define EIGEN_SPARSE_PUBLIC_INTERFACE(Derived)
#define EIGEN_STATIC_ASSERT(X, MSG)
A matrix or vector expression mapping an existing array of data.
bool construct(Expression &expr)
Ref(const Map< SparseMatrix< MatScalar, OtherOptions, MatIndex >> &expr)
Ref(SparseCompressedBase< Derived > &expr)
Ref(const SparseMatrix< MatScalar, OtherOptions, MatIndex > &expr)
internal::SparseRefBase< Ref > Base
internal::traits< Ref > Traits
SparseMatrix< MatScalar, MatOptions, MatIndex > PlainObjectType
Ref(SparseCompressedBase< Derived > &expr)
SparseVector< MatScalar, MatOptions, MatIndex > PlainObjectType
internal::SparseRefBase< Ref > Base
Ref(const SparseVector< MatScalar, OtherOptions, MatIndex > &expr)
internal::traits< Ref > Traits
Ref(const SparseMatrixBase< Derived > &expr)
void construct(const Expression &expr, internal::true_type)
internal::traits< Ref > Traits
internal::SparseRefBase< Ref > Base
Ref(const RefBase< OtherRef > &other)
void construct(const Expression &expr, internal::false_type)
SparseMatrix< MatScalar, MatOptions, MatIndex > TPlainObjectType
internal::aligned_storage< sizeof(TPlainObjectType), EIGEN_ALIGNOF(TPlainObjectType)>::type m_storage
internal::SparseRefBase< Ref > Base
Ref(const SparseMatrixBase< Derived > &expr)
Ref(const RefBase< OtherRef > &other)
internal::traits< Ref > Traits
void construct(const Expression &expr, internal::false_type)
SparseVector< MatScalar, MatOptions, MatIndex > TPlainObjectType
void construct(const Expression &expr, internal::true_type)
internal::aligned_storage< sizeof(TPlainObjectType), EIGEN_ALIGNOF(TPlainObjectType)>::type m_storage
A matrix or vector expression mapping an existing expression.
Ref(const PlainObjectBase< Derived > &expr, std::enable_if_t< bool(Traits::template match< Derived >::MatchAtCompileTime), Derived > *=0)
Common base class for sparse [compressed]-{row|column}-storage format.
bool isCompressed() const
Base class of any sparse matrices or sparse expressions.
A versatible sparse matrix representation.
bool isCompressed() const
const unsigned int LvalueBit
const unsigned int RowMajorBit
const unsigned int CompressedAccessBit
T * construct_at(T *p, Args &&... args)
const unsigned int NestByRefBit
@ StandardCompressedFormat
Derived & const_cast_derived() const