10 #ifndef EIGEN_SPARSEMATRIXBASE_H 11 #define EIGEN_SPARSEMATRIXBASE_H 41 template<
typename OtherDerived>
96 #ifndef EIGEN_PARSED_BY_DOXYGEN
111 #ifndef EIGEN_PARSED_BY_DOXYGEN 131 inline const Derived&
derived()
const {
return *
static_cast<const Derived*
>(
this); }
132 inline Derived&
derived() {
return *
static_cast<Derived*
>(
this); }
135 #endif // not EIGEN_PARSED_BY_DOXYGEN 137 #define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::SparseMatrixBase 138 # include "../plugins/CommonCwiseUnaryOps.h" 139 # include "../plugins/CommonCwiseBinaryOps.h" 140 # include "../plugins/MatrixCwiseUnaryOps.h" 141 # include "../plugins/MatrixCwiseBinaryOps.h" 142 # include "../plugins/BlockMethods.h" 143 # ifdef EIGEN_SPARSEMATRIXBASE_PLUGIN 144 # include EIGEN_SPARSEMATRIXBASE_PLUGIN 146 # undef EIGEN_CURRENT_STORAGE_BASE_CLASS 147 #undef EIGEN_CURRENT_STORAGE_BASE_CLASS 177 template<
typename OtherDerived>
185 template<
typename OtherDerived>
196 return assign(other.derived());
201 template<
typename OtherDerived>
202 inline Derived&
assign(
const OtherDerived& other)
206 if ((!transpose) && other.isRValue())
209 derived().resize(other.rows(), other.cols());
215 for (
typename OtherDerived::InnerIterator it(other, j); it; ++it)
217 Scalar v = it.value();
218 derived().insertBackByOuterInner(j,it.index()) = v;
230 template<
typename OtherDerived>
235 (!((
Flags & RowMajorBit) != (OtherDerived::Flags & RowMajorBit)))) &&
236 "the transpose operation is supposed to be handled in SparseMatrix::operator=");
240 const Index outerSize = other.outerSize();
243 Derived temp(other.rows(), other.cols());
245 temp.reserve((std::max)(this->
rows(),this->
cols())*2);
249 for (
typename OtherDerived::InnerIterator it(other.derived(), j); it; ++it)
251 Scalar v = it.value();
252 temp.insertBackByOuterInner(Flip?it.index():j,Flip?j:it.index()) = v;
257 derived() = temp.markAsRValue();
262 template<
typename Lhs,
typename Rhs>
267 typedef typename Derived::Nested Nested;
270 if (
Flags&RowMajorBit)
273 for (Index
row=0;
row<nm.outerSize(); ++
row)
276 for (
typename NestedCleaned::InnerIterator it(nm.derived(),
row); it; ++it)
278 for ( ; col<it.index(); ++
col)
280 s << it.value() <<
" ";
293 for (
typename NestedCleaned::InnerIterator it(nm.derived(), 0); it; ++it)
295 for ( ; row<it.index(); ++
row)
296 s <<
"0" << std::endl;
297 s << it.value() << std::endl;
301 s <<
"0" << std::endl;
306 s << static_cast<const SparseMatrixBase<SparseMatrix<Scalar, RowMajorBit> >&>(trans);
312 template<
typename OtherDerived>
314 template<
typename OtherDerived>
320 #define EIGEN_SPARSE_CWISE_PRODUCT_RETURN_TYPE \ 322 internal::scalar_product_op< \ 323 typename internal::scalar_product_traits< \ 324 typename internal::traits<Derived>::Scalar, \ 325 typename internal::traits<OtherDerived>::Scalar \ 332 template<
typename OtherDerived>
337 template<
typename OtherDerived>
342 template<
typename OtherDerived>
347 template<
typename OtherDerived>
friend 353 template<
typename OtherDerived>
friend 359 template<
typename OtherDerived>
369 template<
typename OtherDerived>
372 #ifdef EIGEN2_SUPPORT 374 template<
typename OtherDerived>
379 template<
typename OtherDerived>
381 #endif // EIGEN2_SUPPORT 392 RealScalar
norm()
const;
403 const ConstInnerVectorReturnType
innerVector(Index outer)
const;
410 template<
typename DenseDerived>
415 for (
typename Derived::InnerIterator i(
derived(),j); i; ++i)
416 dst.coeffRef(i.row(),i.col()) = i.
value();
424 template<
typename OtherDerived>
429 template<
typename OtherDerived>
432 {
return toDense().isApprox(other,prec); }
451 #endif // EIGEN_SPARSEMATRIXBASE_H const Derived & derived() const
Generic expression of a matrix where all coefficients are defined by a functor.
const ScalarMultipleReturnType operator*(const Scalar &scalar) const
Block< Derived, Dynamic, Dynamic, true > innerVectors(Index outerStart, Index outerSize)
const int OuterRandomAccessPattern
void evalTo(Dest &dst) const
Block< const Derived, IsRowMajor?1:Dynamic, IsRowMajor?Dynamic:1, true > ConstInnerVectorReturnType
friend std::ostream & operator<<(std::ostream &s, const SparseMatrixBase &m)
friend const DenseSparseProductReturnType< OtherDerived, Derived >::Type operator*(const MatrixBase< OtherDerived > &lhs, const Derived &rhs)
#define EIGEN_STRONG_INLINE
internal::traits< Derived >::StorageKind StorageKind
SparseMatrixBase StorageBaseType
A versatible sparse matrix representation.
RealScalar squaredNorm() const
internal::packet_traits< Scalar >::type PacketScalar
Derived & operator=(const Derived &other)
Expression of the transpose of a matrix.
const unsigned int DirectAccessBit
CwiseNullaryOp< internal::scalar_constant_op< Scalar >, Matrix< Scalar, Dynamic, Dynamic > > ConstantReturnType
Derived & operator+=(const SparseMatrixBase< OtherDerived > &other)
Pseudo expression to manipulate a triangular sparse matrix as a selfadjoint matrix.
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Block< Derived, IsRowMajor?1:Dynamic, IsRowMajor?Dynamic:1, true > InnerVectorReturnType
const unsigned int RowMajorBit
internal::conditional< NumTraits< Scalar >::IsComplex, CwiseUnaryOp< internal::scalar_conjugate_op< Scalar >, Eigen::Transpose< const Derived > >, Transpose< const Derived > >::type AdjointReturnType
EIGEN_STRONG_INLINE const EIGEN_SPARSE_CWISE_PRODUCT_RETURN_TYPE cwiseProduct(const MatrixBase< OtherDerived > &other) const
const SparseSelfAdjointView< Derived, UpLo > selfadjointView() const
Derived & operator=(const EigenBase< OtherDerived > &other)
void evalTo(MatrixBase< DenseDerived > &dst) const
SparseMatrix< Scalar, Flags &RowMajorBit ? RowMajor :ColMajor, Index > PlainObject
friend const SparseDiagonalProduct< OtherDerived, Derived > operator*(const DiagonalBase< OtherDerived > &lhs, const SparseMatrixBase &rhs)
Base class of any sparse matrices or sparse expressions.
Derived & operator=(const SparseMatrixBase< OtherDerived > &other)
internal::traits< Derived >::Scalar Scalar
RealScalar blueNorm() const
Scalar dot(const MatrixBase< OtherDerived > &other) const
InnerVectorReturnType innerVector(Index outer)
DenseTimeSparseProduct< Lhs, Rhs > Type
Transpose< Derived > transpose()
Derived & assign(const OtherDerived &other)
const AdjointReturnType adjoint() const
const Transpose< const Derived > transpose() const
const SparseTriangularView< Derived, Mode > triangularView() const
#define EIGEN_SPARSE_CWISE_PRODUCT_RETURN_TYPE
bool isApprox(const MatrixBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
#define EIGEN_SIZE_MAX(a, b)
Expression of a fixed-size or dynamic-size block.
EigenBase< Derived > Base
Derived & operator*=(const Scalar &other)
Derived & const_cast_derived() const
Derived & operator/=(const Scalar &other)
Derived & operator-=(const SparseMatrixBase< OtherDerived > &other)
internal::conditional< _HasDirectAccess, const Scalar &, Scalar >::type CoeffReturnType
void assignGeneric(const OtherDerived &other)
Matrix< Scalar, EIGEN_SIZE_MAX(RowsAtCompileTime, ColsAtCompileTime), EIGEN_SIZE_MAX(RowsAtCompileTime, ColsAtCompileTime)> SquareMatrixType
const Derived & derived() const
const internal::eval< Derived >::type eval() const
CoeffReturnType value() const
Generic expression where a coefficient-wise unary operator is applied to an expression.
The matrix class, also used for vectors and row-vectors.
NumTraits< Scalar >::Real RealScalar
internal::add_const_on_value_type_if_arithmetic< typename internal::packet_traits< Scalar >::type >::type PacketReturnType
SparseSymmetricPermutationProduct< Derived, Upper|Lower > twistedBy(const PermutationMatrix< Dynamic, Dynamic, Index > &perm) const
Base class for all dense matrices, vectors, and expressions.
Matrix< Scalar, RowsAtCompileTime, ColsAtCompileTime > toDense() const
internal::traits< Derived >::Index Index
bool isApprox(const SparseMatrixBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const