10 #ifndef EIGEN_DYNAMIC_SPARSEMATRIX_H 11 #define EIGEN_DYNAMIC_SPARSEMATRIX_H 36 template<
typename _Scalar,
int _Options,
typename _StorageIndex>
55 template<
typename _Scalar,
int _Options,
typename _StorageIndex>
57 :
public SparseMatrixBase<DynamicSparseMatrix<_Scalar, _Options, _StorageIndex> >
67 using Base::IsRowMajor;
68 using Base::operator=;
78 std::vector<internal::CompressedStorage<Scalar,StorageIndex> >
m_data;
82 inline Index rows()
const {
return IsRowMajor ? outerSize() : m_innerSize; }
83 inline Index cols()
const {
return IsRowMajor ? m_innerSize : outerSize(); }
88 std::vector<internal::CompressedStorage<Scalar,StorageIndex> >&
_data() {
return m_data; }
89 const std::vector<internal::CompressedStorage<Scalar,StorageIndex> >&
_data()
const {
return m_data; }
96 const Index outer = IsRowMajor ? row :
col;
97 const Index inner = IsRowMajor ? col :
row;
98 return m_data[outer].at(inner);
107 const Index outer = IsRowMajor ? row :
col;
108 const Index inner = IsRowMajor ? col :
row;
109 return m_data[outer].atWithInsertion(inner);
126 res += m_data[
j].
size();
139 m_data[
j].reserve(reserveSizePerVector);
154 return insertBackByOuterInner(IsRowMajor?row:col, IsRowMajor?col:row);
162 &&
"wrong sorted insertion");
163 m_data[outer].append(0, inner);
164 return m_data[outer].value(m_data[outer].
size()-1);
169 const Index outer = IsRowMajor ? row :
col;
170 const Index inner = IsRowMajor ? col :
row;
173 Index id =
static_cast<Index>(m_data[outer].size()) - 1;
174 m_data[outer].resize(
id+2,1);
176 while ( (
id >= startId) && (m_data[outer].index(
id) > inner) )
178 m_data[outer].index(
id+1) = m_data[outer].index(
id);
179 m_data[outer].value(
id+1) = m_data[outer].value(
id);
182 m_data[outer].index(
id+1) = inner;
183 m_data[outer].value(
id+1) = 0;
184 return m_data[outer].value(
id+1);
201 const Index outerSize = IsRowMajor ? rows :
cols;
204 if (
Index(m_data.size()) != outerSize)
206 m_data.resize(outerSize);
212 const Index outerSize = IsRowMajor ? rows :
cols;
213 const Index innerSize = IsRowMajor ? cols :
rows;
214 if (m_innerSize>innerSize)
221 if (m_data.size() != outerSize)
223 m_data.resize(outerSize);
229 : m_innerSize(0), m_data(0)
231 #ifdef EIGEN_SPARSE_CREATE_TEMPORARY_PLUGIN 241 #ifdef EIGEN_SPARSE_CREATE_TEMPORARY_PLUGIN 248 template<
typename OtherDerived>
252 #ifdef EIGEN_SPARSE_CREATE_TEMPORARY_PLUGIN 255 Base::operator=(other.
derived());
259 : Base(), m_innerSize(0)
261 #ifdef EIGEN_SPARSE_CREATE_TEMPORARY_PLUGIN 272 m_data.swap(other.
m_data);
299 reserve(reserveSize);
313 const Index outer = IsRowMajor ? row :
col;
314 const Index inner = IsRowMajor ? col :
row;
315 return insertBack(outer,inner);
332 # ifdef EIGEN_DYNAMICSPARSEMATRIX_PLUGIN 333 # include EIGEN_DYNAMICSPARSEMATRIX_PLUGIN 337 template<
typename Scalar,
int _Options,
typename _StorageIndex>
343 : Base(mat.m_data[outer]), m_outer(outer)
346 inline Index row()
const {
return IsRowMajor ? m_outer : Base::index(); }
347 inline Index col()
const {
return IsRowMajor ? Base::index() : m_outer; }
354 template<
typename Scalar,
int _Options,
typename _StorageIndex>
360 : Base(mat.m_data[outer]), m_outer(outer)
363 inline Index row()
const {
return IsRowMajor ? m_outer : Base::index(); }
364 inline Index col()
const {
return IsRowMajor ? Base::index() : m_outer; }
373 template<
typename _Scalar,
int _Options,
typename _StorageIndex>
375 :
evaluator_base<DynamicSparseMatrix<_Scalar,_Options,_StorageIndex> >
384 Flags = SparseMatrixType::Flags
390 operator SparseMatrixType&() {
return m_matrix->const_cast_derived(); }
391 operator const SparseMatrixType&()
const {
return *m_matrix; }
404 #endif // EIGEN_DYNAMIC_SPARSEMATRIX_H ReverseInnerIterator(const DynamicSparseMatrix &mat, Index outer)
DynamicSparseMatrix< Scalar,(Flags &~RowMajorBit)|(IsRowMajor?RowMajorBit:0), StorageIndex > TransposedSparseMatrix
Scalar & insertBackByOuterInner(Index outer, Index inner)
SparseMatrixType::ReverseInnerIterator ReverseInnerIterator
const int OuterRandomAccessPattern
std::vector< internal::CompressedStorage< Scalar, StorageIndex > > m_data
DynamicSparseMatrix(const DynamicSparseMatrix &other)
Scalar & insertBack(Index row, Index col)
Q id(Eigen::AngleAxisd(0, Q_z_axis))
void swap(DynamicSparseMatrix &other)
Scalar coeff(Index row, Index col) const
const unsigned int LvalueBit
evaluator(const SparseMatrixType &mat)
InnerIterator(const DynamicSparseMatrix &mat, Index outer)
std::vector< internal::CompressedStorage< Scalar, StorageIndex > > & _data()
Namespace containing all symbols from the Eigen library.
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
void resize(Index rows, Index cols)
const SparseMatrixType * m_matrix
EIGEN_DEVICE_FUNC IndexDest convert_index(const IndexSrc &idx)
Eigen::Index Index
The interface type of indices.
DynamicSparseMatrix< _Scalar, _Options, _StorageIndex > SparseMatrixType
const std::vector< internal::CompressedStorage< Scalar, StorageIndex > > & _data() const
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
#define EIGEN_SPARSE_CREATE_TEMPORARY_PLUGIN
#define EIGEN_SPARSE_PUBLIC_INTERFACE(Derived)
SparseVector< Scalar, _Options, _StorageIndex >::ReverseInnerIterator Base
Base class of any sparse matrices or sparse expressions.
SparseVector< Scalar, _Options, _StorageIndex >::InnerIterator Base
EIGEN_DEPRECATED void startFill(Index reserveSize=1000)
SparseMatrixBase< DynamicSparseMatrix > Base
internal::traits< DynamicSparseMatrix< _Scalar, _Options, _StorageIndex > >::Scalar Scalar
SparseMatrixType::InnerIterator InnerIterator
Scalar coeff(Index row, Index col) const
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
EIGEN_DEPRECATED Scalar & fillrand(Index row, Index col)
EIGEN_DEPRECATED void endFill()
EIGEN_DEPRECATED Scalar & fill(Index row, Index col)
A sparse matrix class designed for matrix assembly purpose.
void reserve(Index reserveSize=1000)
void resizeAndKeepData(Index rows, Index cols)
const unsigned int NestByRefBit
EIGEN_DEPRECATED DynamicSparseMatrix(Index rows, Index cols)
const Derived & derived() const
_StorageIndex StorageIndex
Index nonZerosEstimate() const
Index innerNonZeros(Index j) const
Scalar & coeffRef(Index row, Index col)
NumTraits< Scalar >::Real RealScalar
Scalar & insert(Index row, Index col)
void swap(mpfr::mpreal &x, mpfr::mpreal &y)
EIGEN_DEPRECATED DynamicSparseMatrix()
void swap(scoped_array< T > &a, scoped_array< T > &b)
void prune(Scalar reference, RealScalar epsilon=NumTraits< RealScalar >::dummy_precision())
Derived & const_cast_derived() const
DynamicSparseMatrix & operator=(const DynamicSparseMatrix &other)
EIGEN_DEPRECATED DynamicSparseMatrix(const SparseMatrixBase< OtherDerived > &other)