10 #ifndef EIGEN_SPARSEASSIGN_H 11 #define EIGEN_SPARSEASSIGN_H 15 template<
typename Derived>
16 template<
typename OtherDerived>
23 template<
typename Derived>
24 template<
typename OtherDerived>
32 template<
typename Derived>
33 template<
typename OtherDerived>
42 template<
typename Derived>
70 template<
typename DstXprType,
typename SrcXprType>
73 typedef typename DstXprType::Scalar Scalar;
77 SrcEvaluatorType srcEvaluator(src);
80 const Index outerEvaluationSize = (SrcEvaluatorType::Flags&
RowMajorBit) ? src.rows() : src.cols();
81 if ((!transpose) && src.isRValue())
84 dst.resize(src.rows(), src.cols());
86 dst.reserve((
std::max)(src.rows(),src.cols())*2);
87 for (
Index j=0; j<outerEvaluationSize; ++j)
90 for (
typename SrcEvaluatorType::InnerIterator it(srcEvaluator, j); it; ++it)
92 Scalar v = it.value();
93 dst.insertBackByOuterInner(j,it.index()) = v;
102 (!((DstEvaluatorType::Flags & RowMajorBit) != (SrcEvaluatorType::Flags & RowMajorBit)))) &&
103 "the transpose operation is supposed to be handled in SparseMatrix::operator=");
105 enum { Flip = (DstEvaluatorType::Flags &
RowMajorBit) != (SrcEvaluatorType::Flags & RowMajorBit) };
108 DstXprType temp(src.rows(), src.cols());
110 temp.reserve((
std::max)(src.rows(),src.cols())*2);
111 for (
Index j=0; j<outerEvaluationSize; ++j)
114 for (
typename SrcEvaluatorType::InnerIterator it(srcEvaluator, j); it; ++it)
116 Scalar v = it.value();
117 temp.insertBackByOuterInner(Flip?it.index():j,Flip?j:it.index()) = v;
122 dst = temp.markAsRValue();
127 template<
typename DstXprType,
typename SrcXprType,
typename Functor>
137 template<
typename DstXprType,
typename SrcXprType,
typename Functor>
140 static void run(DstXprType &dst,
const SrcXprType &src,
const Functor &func)
146 Index dstRows = src.rows();
147 Index dstCols = src.cols();
148 if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))
149 dst.resize(dstRows, dstCols);
153 for (
Index j=0; j<outerEvaluationSize; ++j)
155 func.assignCoeff(dstEval.coeffRef(i.row(),i.col()), i.value());
161 template<
typename DstXprType,
typename DecType,
typename RhsType,
typename Scalar>
169 if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))
170 dst.resize(dstRows, dstCols);
172 src.
dec()._solve_impl(src.
rhs(), dst);
180 template<
typename DstXprType,
typename SrcXprType,
typename Functor>
184 typedef typename DstXprType::Scalar
Scalar;
187 template<
int Options>
190 Index dstRows = src.rows();
191 Index dstCols = src.cols();
192 if((dst.
rows()!=dstRows) || (dst.
cols()!=dstCols))
193 dst.
resize(dstRows, dstCols);
195 Index size = src.diagonal().size();
203 template<
typename DstDerived>
206 dst.diagonal() = src.diagonal();
210 { dst.diagonal() += src.diagonal(); }
213 { dst.diagonal() -= src.diagonal(); }
219 #endif // EIGEN_SPARSEASSIGN_H
const int OuterRandomAccessPattern
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void call_assignment_no_alias(Dst &dst, const Src &src, const Func &func)
DstXprType::StorageIndex StorageIndex
Array< Scalar, Dynamic, 1 > ArrayXS
const Scalar * valuePtr() const
A versatible sparse matrix representation.
A matrix or vector expression mapping an existing array of data.
void resizeNonZeros(Index size)
static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op< typename DstXprType::Scalar, typename SrcXprType::Scalar > &)
Derived & operator=(const EigenBase< OtherDerived > &other)
EIGEN_DEVICE_FUNC Index cols() const
static void run(DstXprType &dst, const SrcXprType &src, const internal::add_assign_op< typename DstXprType::Scalar, typename SrcXprType::Scalar > &)
const unsigned int RowMajorBit
Solve< DecType, RhsType > SrcXprType
static void run(DstXprType &dst, const SrcXprType &src, const internal::sub_assign_op< typename DstXprType::Scalar, typename SrcXprType::Scalar > &)
EIGEN_DEVICE_FUNC const Decomposition & dec() const
static void run(SparseMatrixBase< DstDerived > &dst, const SrcXprType &src, const internal::assign_op< typename DstXprType::Scalar, typename SrcXprType::Scalar > &)
Base class of any sparse matrices or sparse expressions.
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
static void run(DstXprType &dst, const SrcXprType &src, const Functor &func)
void resize(Index rows, Index cols)
EIGEN_DEVICE_FUNC void evalTo(Dest &dst) const
void assign_sparse_to_sparse(DstXprType &dst, const SrcXprType &src)
const StorageIndex * innerIndexPtr() const
static void run(SparseMatrix< Scalar, Options, StorageIndex > &dst, const SrcXprType &src, const internal::assign_op< typename DstXprType::Scalar, typename SrcXprType::Scalar > &)
int64_t max(int64_t a, const int b)
const StorageIndex * outerIndexPtr() const
DstXprType::Scalar Scalar
General-purpose arrays with easy API for coefficient-wise operations.
const Derived & derived() const
EIGEN_DEVICE_FUNC Index rows() const
EIGEN_DEVICE_FUNC const RhsType & rhs() const
Pseudo expression representing a solving operation.
static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op< Scalar, Scalar > &)
Array< StorageIndex, Dynamic, 1 > ArrayXI
EIGEN_DEVICE_FUNC Derived & derived()