10#ifndef EIGEN_SPARSEASSIGN_H
11#define EIGEN_SPARSEASSIGN_H
15template<
typename Derived>
16template<
typename OtherDerived>
23template<
typename Derived>
24template<
typename OtherDerived>
32template<
typename Derived>
33template<
typename OtherDerived>
42template<
typename Derived>
70template<
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::min)(src.rows()*src.cols(), (
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;
103 "the transpose operation is supposed to be handled in SparseMatrix::operator=");
108 DstXprType temp(src.rows(), src.cols());
110 temp.reserve((
std::min)(src.rows()*src.cols(), (
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();
127template<
typename DstXprType,
typename SrcXprType,
typename Functor>
137template<
typename DstXprType,
typename SrcXprType,
typename Functor,
typename Weak>
140 static void run(DstXprType &dst,
const SrcXprType &src,
const Functor &func)
150 for (
Index j=0; j<outerEvaluationSize; ++j)
152 func.assignCoeff(dstEval.coeffRef(i.row(),i.col()), i.value());
157template<
typename DstXprType,
typename Func1,
typename Func2>
160 template<
typename SrcXprType,
typename InitialFunc>
162 void run(DstXprType &dst,
const SrcXprType &src,
const InitialFunc& )
164 #ifdef EIGEN_SPARSE_ASSIGNMENT_FROM_DENSE_OP_SPARSE_PLUGIN
165 EIGEN_SPARSE_ASSIGNMENT_FROM_DENSE_OP_SPARSE_PLUGIN
173 template<
typename Lhs,
typename Rhs,
typename Scalar>
179 #ifdef EIGEN_SPARSE_ASSIGNMENT_FROM_SPARSE_ADD_DENSE_PLUGIN
180 EIGEN_SPARSE_ASSIGNMENT_FROM_SPARSE_ADD_DENSE_PLUGIN
189 template<
typename Lhs,
typename Rhs,
typename Scalar>
195 #ifdef EIGEN_SPARSE_ASSIGNMENT_FROM_SPARSE_SUB_DENSE_PLUGIN
196 EIGEN_SPARSE_ASSIGNMENT_FROM_SPARSE_SUB_DENSE_PLUGIN
205#define EIGEN_CATCH_ASSIGN_DENSE_OP_SPARSE(ASSIGN_OP,BINOP,ASSIGN_OP2) \
206 template< typename DstXprType, typename Lhs, typename Rhs, typename Scalar> \
207 struct Assignment<DstXprType, CwiseBinaryOp<internal::BINOP<Scalar,Scalar>, const Lhs, const Rhs>, internal::ASSIGN_OP<typename DstXprType::Scalar,Scalar>, \
209 typename internal::enable_if< internal::is_same<typename internal::evaluator_traits<Lhs>::Shape,DenseShape>::value \
210 || internal::is_same<typename internal::evaluator_traits<Rhs>::Shape,DenseShape>::value>::type> \
211 : assignment_from_dense_op_sparse<DstXprType, internal::ASSIGN_OP<typename DstXprType::Scalar,typename Lhs::Scalar>, internal::ASSIGN_OP2<typename DstXprType::Scalar,typename Rhs::Scalar> > \
225template<
typename DstXprType,
typename DecType,
typename RhsType,
typename Scalar>
233 if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))
234 dst.resize(dstRows, dstCols);
236 src.
dec()._solve_impl(src.
rhs(), dst);
244template<
typename DstXprType,
typename SrcXprType,
typename Functor>
248 typedef typename DstXprType::Scalar
Scalar;
250 template<
int Options,
typename AssignFunc>
254 template<
typename DstDerived>
256 { dst.
derived().diagonal() = src.diagonal(); }
258 template<
typename DstDerived>
260 { dst.
derived().diagonal() += src.diagonal(); }
262 template<
typename DstDerived>
264 { dst.
derived().diagonal() -= src.diagonal(); }
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:986
#define eigen_assert(x)
Definition: Macros.h:1047
#define EIGEN_STRONG_INLINE
Definition: Macros.h:927
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Definition: CwiseBinaryOp.h:84
Definition: ReturnByValue.h:52
EIGEN_DEVICE_FUNC void evalTo(Dest &dst) const
Definition: ReturnByValue.h:61
Pseudo expression representing a solving operation.
Definition: Solve.h:63
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: Solve.h:73
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: Solve.h:72
EIGEN_DEVICE_FUNC const RhsType & rhs() const
Definition: Solve.h:76
EIGEN_DEVICE_FUNC const Decomposition & dec() const
Definition: Solve.h:75
Base class of any sparse matrices or sparse expressions.
Definition: SparseMatrixBase.h:28
const Derived & derived() const
Definition: SparseMatrixBase.h:143
Derived & operator=(const EigenBase< OtherDerived > &other)
Definition: SparseAssign.h:17
A versatible sparse matrix representation.
Definition: SparseMatrix.h:98
void assignDiagonal(const DiagXpr diagXpr, const Func &assignFunc)
Definition: SparseMatrix.h:927
type
Definition: core.h:575
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition: Constants.h:66
constexpr common_t< T1, T2 > max(const T1 x, const T2 y) noexcept
Compile-time pairwise maximum function.
Definition: max.hpp:35
constexpr common_t< T1, T2 > min(const T1 x, const T2 y) noexcept
Compile-time pairwise minimum function.
Definition: min.hpp:35
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void resize_if_allowed(DstXprType &dst, const SrcXprType &src, const Functor &)
Definition: AssignEvaluator.h:750
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void call_assignment_no_alias(Dst &dst, const Src &src, const Func &func)
Definition: AssignEvaluator.h:873
void assign_sparse_to_sparse(DstXprType &dst, const SrcXprType &src)
Definition: SparseAssign.h:71
EIGEN_CATCH_ASSIGN_DENSE_OP_SPARSE(assign_op, scalar_sum_op, add_assign_op)
Namespace containing all symbols from the Eigen library.
Definition: MatrixExponential.h:16
const int OuterRandomAccessPattern
Definition: SparseUtil.h:49
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
Definition: Eigen_Colamd.h:50
Definition: Constants.h:528
Definition: Constants.h:531
Common base class for all classes T such that MatrixBase has an operator=(T) and a constructor Matrix...
Definition: EigenBase.h:30
EIGEN_DEVICE_FUNC Derived & derived()
Definition: EigenBase.h:46
The type used to identify a general sparse storage.
Definition: Constants.h:510
Definition: Constants.h:537
Solve< DecType, RhsType > SrcXprType
Definition: SparseAssign.h:228
static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op< Scalar, Scalar > &)
Definition: SparseAssign.h:229
DstXprType::Scalar Scalar
Definition: SparseAssign.h:248
static void run(SparseMatrixBase< DstDerived > &dst, const SrcXprType &src, const internal::add_assign_op< typename DstXprType::Scalar, typename SrcXprType::Scalar > &)
Definition: SparseAssign.h:259
static void run(SparseMatrixBase< DstDerived > &dst, const SrcXprType &src, const internal::sub_assign_op< typename DstXprType::Scalar, typename SrcXprType::Scalar > &)
Definition: SparseAssign.h:263
DstXprType::StorageIndex StorageIndex
Definition: SparseAssign.h:247
static void run(SparseMatrixBase< DstDerived > &dst, const SrcXprType &src, const internal::assign_op< typename DstXprType::Scalar, typename SrcXprType::Scalar > &)
Definition: SparseAssign.h:255
static void run(SparseMatrix< Scalar, Options, StorageIndex > &dst, const SrcXprType &src, const AssignFunc &func)
Definition: SparseAssign.h:251
static void run(DstXprType &dst, const SrcXprType &src, const Functor &func)
Definition: SparseAssign.h:140
static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op< typename DstXprType::Scalar, typename SrcXprType::Scalar > &)
Definition: SparseAssign.h:130
Definition: AssignEvaluator.h:824
Sparse2Dense Kind
Definition: SparseAssign.h:66
Sparse2Dense Kind
Definition: SparseAssign.h:67
Diagonal2Sparse Kind
Definition: SparseAssign.h:242
Sparse2Sparse Kind
Definition: SparseAssign.h:64
Sparse2Sparse Kind
Definition: SparseAssign.h:65
Definition: AssignEvaluator.h:817
Definition: SparseAssign.h:240
Definition: Constants.h:545
Definition: SparseAssign.h:62
Definition: SparseAssign.h:61
Definition: SparseUtil.h:137
Definition: AssignmentFunctors.h:46
Definition: AssignmentFunctors.h:21
Definition: SparseAssign.h:159
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(DstXprType &dst, const SrcXprType &src, const InitialFunc &)
Definition: SparseAssign.h:162
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE internal::enable_if< internal::is_same< typenameinternal::evaluator_traits< Rhs >::Shape, DenseShape >::value >::type run(DstXprType &dst, const CwiseBinaryOp< internal::scalar_sum_op< Scalar, Scalar >, const Lhs, const Rhs > &src, const internal::assign_op< typename DstXprType::Scalar, Scalar > &)
Definition: SparseAssign.h:176
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE internal::enable_if< internal::is_same< typenameinternal::evaluator_traits< Rhs >::Shape, DenseShape >::value >::type run(DstXprType &dst, const CwiseBinaryOp< internal::scalar_difference_op< Scalar, Scalar >, const Lhs, const Rhs > &src, const internal::assign_op< typename DstXprType::Scalar, Scalar > &)
Definition: SparseAssign.h:192
Definition: CoreEvaluators.h:91
Definition: BinaryFunctors.h:350
Definition: BinaryFunctors.h:33
IteratorBased Kind
Definition: SparseAssign.h:53
Definition: CoreEvaluators.h:23
SparseShape Shape
Definition: SparseAssign.h:58
Definition: CoreEvaluators.h:29
Definition: AssignmentFunctors.h:67
Definition: ForwardDeclarations.h:17