10 #ifndef EIGEN_SPARSE_MAP_H
11 #define EIGEN_SPARSE_MAP_H
20 template <
typename MatScalar,
int MatOptions,
typename MatIndex,
int Options,
typename Str
ideType>
22 :
public traits<SparseMatrix<MatScalar, MatOptions, MatIndex> > {
28 template <
typename MatScalar,
int MatOptions,
typename MatIndex,
int Options,
typename Str
ideType>
30 :
public traits<SparseMatrix<MatScalar, MatOptions, MatIndex> > {
38 template <
typename Derived,
46 template <
typename Derived>
52 enum { IsRowMajor = Base::IsRowMajor };
53 using Base::operator=;
70 inline Index rows()
const {
return IsRowMajor ? m_outerSize : m_innerSize; }
72 inline Index cols()
const {
return IsRowMajor ? m_innerSize : m_outerSize; }
101 Index end = isCompressed() ? m_outerIndex[outer + 1] :
start + m_innerNonZeros[outer];
104 else if (
end > 0 && inner == m_innerIndices[
end - 1])
105 return m_values[
end - 1];
110 const Index id =
r - &m_innerIndices[0];
111 return ((*
r == inner) && (
id <
end)) ? m_values[id] :
Scalar(0);
116 : m_outerSize(IsRowMajor ?
rows :
cols),
117 m_innerSize(IsRowMajor ?
cols :
rows),
119 m_outerIndex(outerIndexPtr),
120 m_innerIndices(innerIndexPtr),
122 m_innerNonZeros(innerNonZerosPtr) {}
129 m_outerIndex(m_zero_nnz.
data()),
130 m_innerIndices(innerIndexPtr),
132 m_innerNonZeros(0) {}
145 template <
typename Derived>
153 enum { IsRowMajor = Base::IsRowMajor };
155 using Base::operator=;
160 using Base::innerIndexPtr;
161 using Base::innerNonZeroPtr;
162 using Base::outerIndexPtr;
163 using Base::valuePtr;
180 Index end = Base::isCompressed() ? Base::m_outerIndex[outer + 1] :
start + Base::m_innerNonZeros[outer];
184 const Index id =
r - &Base::m_innerIndices[0];
185 eigen_assert((*
r == inner) && (
id <
end) &&
"coeffRef cannot be called on a zero coefficient");
186 return const_cast<Scalar*
>(Base::m_values)[
id];
191 :
Base(
rows,
cols, nnz, outerIndexPtr, innerIndexPtr, valuePtr, innerNonZerosPtr) {}
195 :
Base(
size, nnz, innerIndexPtr, valuePtr) {}
213 #ifndef EIGEN_PARSED_BY_DOXYGEN
214 template <
typename MatScalar,
int MatOptions,
typename MatIndex,
int Options,
typename Str
ideType>
216 :
public SparseMapBase<Map<SparseMatrix<MatScalar, MatOptions, MatIndex>, Options, StrideType> >
218 template <typename SparseMatrixType>
225 enum { IsRowMajor = Base::IsRowMajor };
238 Scalar* valuePtr, StorageIndex* innerNonZerosPtr = 0)
239 :
Base(
rows,
cols, nnz, outerIndexPtr, innerIndexPtr, valuePtr, innerNonZerosPtr) {}
240 #ifndef EIGEN_PARSED_BY_DOXYGEN
245 template <
typename MatScalar,
int MatOptions,
typename MatIndex,
int Options,
typename Str
ideType>
247 :
public SparseMapBase<Map<const SparseMatrix<MatScalar, MatOptions, MatIndex>, Options, StrideType> > {
251 enum { IsRowMajor = Base::IsRowMajor };
261 const Scalar* valuePtr,
const StorageIndex* innerNonZerosPtr = 0)
262 :
Base(
rows,
cols, nnz, outerIndexPtr, innerIndexPtr, valuePtr, innerNonZerosPtr) {}
270 template <
typename MatScalar,
int MatOptions,
typename MatIndex,
int Options,
typename Str
ideType>
272 :
evaluator<SparseCompressedBase<Map<SparseMatrix<MatScalar, MatOptions, MatIndex>, Options, StrideType> > > {
280 template <
typename MatScalar,
int MatOptions,
typename MatIndex,
int Options,
typename Str
ideType>
282 :
evaluator<SparseCompressedBase<Map<const SparseMatrix<MatScalar, MatOptions, MatIndex>, Options, StrideType> > > {
#define eigen_assert(x)
Definition: Macros.h:910
int data[]
Definition: Map_placement_new.cpp:1
#define EIGEN_SPARSE_PUBLIC_INTERFACE(Derived)
Definition: SparseUtil.h:39
int rows
Definition: Tutorial_commainit_02.cpp:1
int cols
Definition: Tutorial_commainit_02.cpp:1
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
SCALAR Scalar
Definition: bench_gemm.cpp:45
Base class for dense Map and Block expression with direct access.
Definition: MapBase.h:41
Specialization of class Map for SparseMatrix-like storage.
Definition: SparseMap.h:221
SparseMapBase< Map > Base
Definition: SparseMap.h:223
~Map()
Definition: SparseMap.h:242
Map(Index rows, Index cols, Index nnz, StorageIndex *outerIndexPtr, StorageIndex *innerIndexPtr, Scalar *valuePtr, StorageIndex *innerNonZerosPtr=0)
Definition: SparseMap.h:237
Definition: SparseMap.h:247
SparseMapBase< Map > Base
Definition: SparseMap.h:249
Map(Index rows, Index cols, Index nnz, const StorageIndex *outerIndexPtr, const StorageIndex *innerIndexPtr, const Scalar *valuePtr, const StorageIndex *innerNonZerosPtr=0)
Definition: SparseMap.h:260
~Map()
Definition: SparseMap.h:265
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:96
Common base class for sparse [compressed]-{row|column}-storage format.
Definition: SparseCompressedBase.h:43
Common base class for Map and Ref instance of sparse matrix and vector.
Definition: SparseMap.h:47
Index m_innerSize
Definition: SparseMap.h:61
SparseCompressedBase< Derived > Base
Definition: SparseMap.h:49
Index innerSize() const
Definition: SparseMap.h:74
Index cols() const
Definition: SparseMap.h:72
Base::Scalar Scalar
Definition: SparseMap.h:50
Scalar coeff(Index row, Index col) const
Definition: SparseMap.h:96
const StorageIndex * outerIndexPtr() const
Definition: SparseMap.h:90
const StorageIndex * innerNonZeroPtr() const
Definition: SparseMap.h:92
Index rows() const
Definition: SparseMap.h:70
Index outerSize() const
Definition: SparseMap.h:76
IndexPointer m_innerIndices
Definition: SparseMap.h:64
const Scalar * valuePtr() const
Definition: SparseMap.h:86
Index nonZeros() const
Definition: SparseMap.h:78
Index m_outerSize
Definition: SparseMap.h:60
Base::StorageIndex StorageIndex
Definition: SparseMap.h:51
std::conditional_t< bool(internal::is_lvalue< Derived >::value), StorageIndex *, const StorageIndex * > IndexPointer
Definition: SparseMap.h:58
SparseMapBase(Index rows, Index cols, Index nnz, IndexPointer outerIndexPtr, IndexPointer innerIndexPtr, ScalarPointer valuePtr, IndexPointer innerNonZerosPtr=0)
Definition: SparseMap.h:114
SparseMapBase()
Definition: SparseMap.h:138
bool isCompressed() const
Definition: SparseMap.h:81
IndexPointer m_outerIndex
Definition: SparseMap.h:63
const StorageIndex * innerIndexPtr() const
Definition: SparseMap.h:88
~SparseMapBase()
Definition: SparseMap.h:135
std::conditional_t< bool(internal::is_lvalue< Derived >::value), Scalar *, const Scalar * > ScalarPointer
Definition: SparseMap.h:56
SparseMapBase(Index size, Index nnz, IndexPointer innerIndexPtr, ScalarPointer valuePtr)
Definition: SparseMap.h:125
IndexPointer m_innerNonZeros
Definition: SparseMap.h:66
Array< StorageIndex, 2, 1 > m_zero_nnz
Definition: SparseMap.h:62
ScalarPointer m_values
Definition: SparseMap.h:65
SparseMapBase(Index size, Index nnz, StorageIndex *innerIndexPtr, Scalar *valuePtr)
Definition: SparseMap.h:194
StorageIndex * outerIndexPtr()
Definition: SparseMap.h:169
SparseMapBase(Index rows, Index cols, Index nnz, StorageIndex *outerIndexPtr, StorageIndex *innerIndexPtr, Scalar *valuePtr, StorageIndex *innerNonZerosPtr=0)
Definition: SparseMap.h:189
~SparseMapBase()
Definition: SparseMap.h:198
Base::StorageIndex StorageIndex
Definition: SparseMap.h:152
Scalar & coeffRef(Index row, Index col)
Definition: SparseMap.h:175
MapBase< Derived, ReadOnlyAccessors > ReadOnlyMapBase
Definition: SparseMap.h:147
Base::Scalar Scalar
Definition: SparseMap.h:151
SparseMapBase< Derived, ReadOnlyAccessors > Base
Definition: SparseMap.h:150
SparseMapBase()
Definition: SparseMap.h:201
StorageIndex * innerIndexPtr()
Definition: SparseMap.h:167
StorageIndex * innerNonZeroPtr()
Definition: SparseMap.h:171
Scalar * valuePtr()
Definition: SparseMap.h:165
Definition: SparseMap.h:40
Base class of any sparse matrices or sparse expressions.
Definition: SparseMatrixBase.h:30
internal::traits< Derived >::StorageIndex StorageIndex
Definition: SparseMatrixBase.h:44
internal::traits< Derived >::Scalar Scalar
Definition: SparseMatrixBase.h:32
A versatible sparse matrix representation.
Definition: SparseMatrix.h:121
static constexpr lastp1_t end
Definition: IndexedViewHelper.h:79
@ ReadOnlyAccessors
Definition: Constants.h:372
@ WriteAccessors
Definition: Constants.h:374
const unsigned int LvalueBit
Definition: Constants.h:148
EIGEN_DEVICE_FUNC IndexDest convert_index(const IndexSrc &idx)
Definition: XprHelper.h:63
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
const unsigned int NestByRefBit
Definition: Constants.h:173
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
Extend namespace for flags.
Definition: fsi_chan_precond_driver.cc:56
Definition: Eigen_Colamd.h:49
void start(const unsigned &i)
(Re-)start i-th timer
Definition: oomph_utilities.cc:243
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:43
@ has_write_access
Definition: ForwardDeclarations.h:39
evaluator(const XprType &mat)
Definition: SparseMap.h:277
evaluator()
Definition: SparseMap.h:276
evaluator< SparseCompressedBase< Map< SparseMatrix< MatScalar, MatOptions, MatIndex >, Options, StrideType > > > Base
Definition: SparseMap.h:274
Map< SparseMatrix< MatScalar, MatOptions, MatIndex >, Options, StrideType > XprType
Definition: SparseMap.h:275
evaluator(const XprType &mat)
Definition: SparseMap.h:288
evaluator()
Definition: SparseMap.h:287
Map< const SparseMatrix< MatScalar, MatOptions, MatIndex >, Options, StrideType > XprType
Definition: SparseMap.h:286
evaluator< SparseCompressedBase< Map< const SparseMatrix< MatScalar, MatOptions, MatIndex >, Options, StrideType > > > Base
Definition: SparseMap.h:285
Definition: CoreEvaluators.h:104
Definition: XprHelper.h:819
SparseMatrix< MatScalar, MatOptions, MatIndex > PlainObjectType
Definition: SparseMap.h:23
traits< PlainObjectType > TraitsBase
Definition: SparseMap.h:24
traits< PlainObjectType > TraitsBase
Definition: SparseMap.h:32
SparseMatrix< MatScalar, MatOptions, MatIndex > PlainObjectType
Definition: SparseMap.h:31
Definition: ForwardDeclarations.h:21