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::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;
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::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();
127 template<
typename DstXprType,
typename SrcXprType,
typename Functor>
137 template<
typename DstXprType,
typename SrcXprType,
typename Functor,
typename Weak>
150 for (
Index j=0;
j<outerEvaluationSize; ++
j)
152 func.assignCoeff(dstEval.coeffRef(
i.row(),
i.col()),
i.value());
157 template<
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 173 template<
typename Lhs,
typename Rhs,
typename Scalar>
179 #ifdef EIGEN_SPARSE_ASSIGNMENT_FROM_SPARSE_ADD_DENSE_PLUGIN 189 template<
typename Lhs,
typename Rhs,
typename Scalar>
191 typename internal::enable_if<internal::is_same<typename internal::evaluator_traits<Rhs>::Shape,
DenseShape>
::value>
::type 195 #ifdef 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> > \ 225 template<
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);
244 template<
typename DstXprType,
typename SrcXprType,
typename Functor>
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(); }
270 #endif // EIGEN_SPARSEASSIGN_H static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE internal::enable_if< internal::is_same< typename internal::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 > &)
const int OuterRandomAccessPattern
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void call_assignment_no_alias(Dst &dst, const Src &src, const Func &func)
#define EIGEN_STRONG_INLINE
DstXprType::StorageIndex StorageIndex
void assignDiagonal(const DiagXpr diagXpr, const Func &assignFunc)
A versatible sparse matrix representation.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void resize_if_allowed(DstXprType &dst, const SrcXprType &src, const Functor &)
static void run(SparseMatrixBase< DstDerived > &dst, const SrcXprType &src, const internal::add_assign_op< typename DstXprType::Scalar, typename SrcXprType::Scalar > &)
static void run(SparseMatrixBase< DstDerived > &dst, const SrcXprType &src, const internal::sub_assign_op< typename DstXprType::Scalar, typename SrcXprType::Scalar > &)
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.
#define EIGEN_SPARSE_ASSIGNMENT_FROM_SPARSE_ADD_DENSE_PLUGIN
#define EIGEN_SPARSE_ASSIGNMENT_FROM_DENSE_OP_SPARSE_PLUGIN
Derived & operator=(const EigenBase< OtherDerived > &other)
const unsigned int RowMajorBit
Solve< DecType, RhsType > SrcXprType
static void run(SparseMatrix< Scalar, Options, StorageIndex > &dst, const SrcXprType &src, const AssignFunc &func)
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 > &)
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Base class of any sparse matrices or sparse expressions.
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Array< int, Dynamic, 1 > v
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(DstXprType &dst, const SrcXprType &src, const InitialFunc &)
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE internal::enable_if< internal::is_same< typename internal::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 > &)
EIGEN_DEVICE_FUNC void evalTo(Dest &dst) const
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
void assign_sparse_to_sparse(DstXprType &dst, const SrcXprType &src)
#define EIGEN_DEVICE_FUNC
#define EIGEN_SPARSE_ASSIGNMENT_FROM_SPARSE_SUB_DENSE_PLUGIN
DstXprType::Scalar Scalar
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
const Derived & derived() 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 > &)
static void run(DstXprType &dst, const SrcXprType &src, const Functor &func)
EIGEN_DEVICE_FUNC Derived & derived()
EIGEN_CATCH_ASSIGN_DENSE_OP_SPARSE(assign_op, scalar_sum_op, add_assign_op)