25 #ifndef EIGEN_SPARSEMATRIXBASE_H
26 #define EIGEN_SPARSEMATRIXBASE_H
45 typedef typename internal::traits<Derived>::Scalar
Scalar;
46 typedef typename internal::packet_traits<Scalar>::type
PacketScalar;
47 typedef typename internal::traits<Derived>::StorageKind
StorageKind;
48 typedef typename internal::traits<Derived>::Index
Index;
49 typedef typename internal::add_const_on_value_type_if_arithmetic<
50 typename internal::packet_traits<Scalar>::type
56 template<
typename OtherDerived>
78 SizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::RowsAtCompileTime,
79 internal::traits<Derived>::ColsAtCompileTime>::ret),
96 Flags = internal::traits<Derived>::Flags,
108 #ifndef EIGEN_PARSED_BY_DOXYGEN
123 #ifndef EIGEN_PARSED_BY_DOXYGEN
134 typedef typename internal::conditional<_HasDirectAccess, const Scalar&, Scalar>::type CoeffReturnType;
143 inline const Derived&
derived()
const {
return *
static_cast<const Derived*
>(
this); }
144 inline Derived&
derived() {
return *
static_cast<Derived*
>(
this); }
147 #endif // not EIGEN_PARSED_BY_DOXYGEN
149 #define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::SparseMatrixBase
150 # include "../plugins/CommonCwiseUnaryOps.h"
151 # include "../plugins/CommonCwiseBinaryOps.h"
152 # include "../plugins/MatrixCwiseUnaryOps.h"
153 # include "../plugins/MatrixCwiseBinaryOps.h"
154 # ifdef EIGEN_SPARSEMATRIXBASE_PLUGIN
155 # include EIGEN_SPARSEMATRIXBASE_PLUGIN
157 # undef EIGEN_CURRENT_STORAGE_BASE_CLASS
158 #undef EIGEN_CURRENT_STORAGE_BASE_CLASS
189 template<
typename OtherDerived>
197 template<
typename OtherDerived>
208 return assign(other.derived());
213 template<
typename OtherDerived>
214 inline Derived&
assign(
const OtherDerived& other)
218 if ((!transpose) && other.isRValue())
221 derived().resize(other.rows(), other.cols());
227 for (
typename OtherDerived::InnerIterator it(other, j); it; ++it)
229 Scalar v = it.value();
230 derived().insertBackByOuterInner(j,it.index()) = v;
242 template<
typename OtherDerived>
248 "the transpose operation is supposed to be handled in SparseMatrix::operator=");
250 enum { Flip = (
Flags &
RowMajorBit) != (OtherDerived::Flags & RowMajorBit) };
255 Derived temp(other.rows(), other.cols());
257 temp.reserve((std::max)(this->
rows(),this->
cols())*2);
261 for (
typename OtherDerived::InnerIterator it(other.derived(), j); it; ++it)
263 Scalar v = it.value();
264 temp.insertBackByOuterInner(Flip?it.index():j,Flip?j:it.index()) = v;
269 derived() = temp.markAsRValue();
274 template<
typename Lhs,
typename Rhs>
279 typedef typename Derived::Nested Nested;
280 typedef typename internal::remove_all<Nested>::type NestedCleaned;
288 for (
typename NestedCleaned::InnerIterator it(nm.derived(),
row); it; ++it)
290 for ( ; col<it.index(); ++
col)
292 s << it.value() <<
" ";
305 for (
typename NestedCleaned::InnerIterator it(nm.derived(), 0); it; ++it)
307 for ( ; row<it.index(); ++
row)
308 s <<
"0" << std::endl;
309 s << it.value() << std::endl;
313 s <<
"0" << std::endl;
318 s << static_cast<const SparseMatrixBase<SparseMatrix<Scalar, RowMajorBit> >&>(trans);
324 template<
typename OtherDerived>
326 template<
typename OtherDerived>
332 #define EIGEN_SPARSE_CWISE_PRODUCT_RETURN_TYPE \
334 internal::scalar_product_op< \
335 typename internal::scalar_product_traits< \
336 typename internal::traits<Derived>::Scalar, \
337 typename internal::traits<OtherDerived>::Scalar \
344 template<
typename OtherDerived>
346 cwiseProduct(
const MatrixBase<OtherDerived> &other)
const;
349 template<
typename OtherDerived>
351 operator*(
const SparseMatrixBase<OtherDerived> &other)
const;
354 template<
typename OtherDerived>
355 const SparseDiagonalProduct<Derived,OtherDerived>
359 template<
typename OtherDerived>
friend
360 const SparseDiagonalProduct<OtherDerived,Derived>
365 template<
typename OtherDerived>
friend
371 template<
typename OtherDerived>
381 template<
typename OtherDerived>
384 #ifdef EIGEN2_SUPPORT
386 template<
typename OtherDerived>
391 template<
typename OtherDerived>
393 #endif // EIGEN2_SUPPORT
404 RealScalar
norm()
const;
432 template<
typename DenseDerived>
437 for (
typename Derived::InnerIterator i(
derived(),j); i; ++i)
438 dst.coeffRef(i.row(),i.col()) = i.
value();
446 template<
typename OtherDerived>
451 template<
typename OtherDerived>
454 {
return toDense().isApprox(other,prec); }
461 inline const typename internal::eval<Derived>::type
eval()
const
462 {
return typename internal::eval<Derived>::type(
derived()); }
473 #endif // EIGEN_SPARSEMATRIXBASE_H