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>
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>
150 for (
Index j=0;
j<outerEvaluationSize; ++
j)
152 func.assignCoeff(dstEval.coeffRef(
i.row(),
i.col()),
i.value());
158 template<
typename DstXprType,
typename DecType,
typename RhsType,
typename Scalar>
166 if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))
167 dst.resize(dstRows, dstCols);
169 src.
dec()._solve_impl(src.
rhs(), dst);
177 template<
typename DstXprType,
typename SrcXprType,
typename Functor>
184 template<
int Options>
187 Index dstRows = src.rows();
188 Index dstCols = src.cols();
189 if((dst.
rows()!=dstRows) || (dst.
cols()!=dstCols))
190 dst.
resize(dstRows, dstCols);
200 template<
typename DstDerived>
203 dst.diagonal() = src.diagonal();
207 { dst.diagonal() += src.diagonal(); }
210 { dst.diagonal() -= src.diagonal(); }
216 #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
A versatible sparse matrix representation.
EIGEN_DEVICE_FUNC Index cols() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void resize_if_allowed(DstXprType &dst, const SrcXprType &src, const Functor &)
A matrix or vector expression mapping an existing array of data.
void resize(Index rows, Index cols)
static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op< typename DstXprType::Scalar, typename SrcXprType::Scalar > &)
Namespace containing all symbols from the Eigen library.
EIGEN_DEVICE_FUNC void evalTo(Dest &dst) const
Derived & operator=(const EigenBase< OtherDerived > &other)
static void run(DstXprType &dst, const SrcXprType &src, const internal::add_assign_op< typename DstXprType::Scalar, typename SrcXprType::Scalar > &)
const Scalar * valuePtr() const
const unsigned int RowMajorBit
void resizeNonZeros(Index size)
Solve< DecType, RhsType > SrcXprType
EIGEN_DEVICE_FUNC Index rows() const
static void run(DstXprType &dst, const SrcXprType &src, const internal::sub_assign_op< typename DstXprType::Scalar, typename SrcXprType::Scalar > &)
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.
v setLinSpaced(5, 0.5f, 1.5f)
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)
EIGEN_DEVICE_FUNC const Decomposition & dec() const
void assign_sparse_to_sparse(DstXprType &dst, const SrcXprType &src)
const StorageIndex * outerIndexPtr() const
static void run(SparseMatrix< Scalar, Options, StorageIndex > &dst, const SrcXprType &src, const internal::assign_op< typename DstXprType::Scalar, typename SrcXprType::Scalar > &)
EIGEN_DEVICE_FUNC const RhsType & rhs() const
const Derived & derived() const
DstXprType::Scalar Scalar
General-purpose arrays with easy API for coefficient-wise operations.
Pseudo expression representing a solving operation.
const StorageIndex * innerIndexPtr() const
static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op< Scalar, Scalar > &)
Array< StorageIndex, Dynamic, 1 > ArrayXI
void run(Expr &expr, Dev &dev)
EIGEN_DEVICE_FUNC Derived & derived()