10#ifndef EIGEN_SPARSEASSIGN_H
11#define EIGEN_SPARSEASSIGN_H
15template<
typename Derived>
16template<
typename OtherDerived>
17Derived& SparseMatrixBase<Derived>::operator=(
const EigenBase<OtherDerived> &other)
19 internal::call_assignment_no_alias(derived(), other.derived());
23template<
typename Derived>
24template<
typename OtherDerived>
25Derived& SparseMatrixBase<Derived>::operator=(
const ReturnByValue<OtherDerived>& other)
28 other.evalTo(derived());
32template<
typename Derived>
33template<
typename OtherDerived>
34inline Derived& SparseMatrixBase<Derived>::operator=(
const SparseMatrixBase<OtherDerived>& other)
37 internal::Assignment<Derived,OtherDerived,internal::assign_op<Scalar> >
38 ::run(derived(), other.derived(), internal::assign_op<Scalar>());
42template<
typename Derived>
43inline Derived& SparseMatrixBase<Derived>::operator=(
const Derived& other)
45 internal::call_assignment_no_alias(derived(), other.derived());
70template<
typename DstXprType,
typename SrcXprType>
71void assign_sparse_to_sparse(DstXprType &
dst,
const SrcXprType &
src)
73 typedef typename DstXprType::Scalar Scalar;
77 SrcEvaluatorType srcEvaluator(
src);
81 if ((!transpose) &&
src.isRValue())
86 dst.reserve((std::max)(
src.rows(),
src.cols())*2);
90 for (
typename SrcEvaluatorType::InnerIterator it(srcEvaluator,
j); it; ++it)
92 Scalar v = it.value();
93 dst.insertBackByOuterInner(
j,it.index()) = v;
101 eigen_assert(( ((internal::traits<DstXprType>::SupportedAccessPatterns & OuterRandomAccessPattern)==OuterRandomAccessPattern) ||
103 "the transpose operation is supposed to be handled in SparseMatrix::operator=");
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();
127template<
typename DstXprType,
typename SrcXprType,
typename Functor,
typename Scalar>
132 assign_sparse_to_sparse(
dst.derived(),
src.derived());
137template<
typename DstXprType,
typename SrcXprType,
typename Functor,
typename Scalar>
140 static void run(DstXprType &
dst,
const SrcXprType &
src,
const Functor &func)
142 eigen_assert(
dst.rows() ==
src.rows() &&
dst.cols() ==
src.cols());
152 func.assignCoeff(
dstEval.coeffRef(i.row(),i.col()), i.value());
158template<
typename DstXprType,
typename DecType,
typename RhsType,
typename Scalar>
172template<
typename DstXprType,
typename SrcXprType,
typename Functor,
typename Scalar>
175 typedef typename DstXprType::StorageIndex StorageIndex;
178 template<
int Options>
181 Index size =
src.diagonal().size();
182 dst.makeCompressed();
183 dst.resizeNonZeros(size);
184 Map<ArrayXI>(
dst.innerIndexPtr(), size).setLinSpaced(0,StorageIndex(size)-1);
185 Map<ArrayXI>(
dst.outerIndexPtr(), size+1).setLinSpaced(0,StorageIndex(size));
189 template<
typename DstDerived>
192 dst.diagonal() =
src.diagonal();
196 {
dst.diagonal() +=
src.diagonal(); }
199 {
dst.diagonal() -=
src.diagonal(); }
Pseudo expression representing a solving operation.
Definition Solve.h:63
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition Constants.h:61
Definition Constants.h:511
Definition Constants.h:514
Definition Constants.h:520
The type used to identify a general sparse storage.
Definition Constants.h:493
Definition AssignEvaluator.h:677
Definition AssignEvaluator.h:684
Definition SparseAssign.h:168
Definition Constants.h:528
Definition SparseAssign.h:62
Definition SparseAssign.h:61
Definition SparseUtil.h:137
Definition AssignmentFunctors.h:42
Definition AssignmentFunctors.h:21
Definition CoreEvaluators.h:82
Definition CoreEvaluators.h:23
Definition CoreEvaluators.h:29
Definition AssignmentFunctors.h:63