SparseSelfAdjointView.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2009-2014 Gael Guennebaud <gael.guennebaud@inria.fr>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_SPARSE_SELFADJOINTVIEW_H
11 #define EIGEN_SPARSE_SELFADJOINTVIEW_H
12 
13 // IWYU pragma: private
14 #include "./InternalHeaderCheck.h"
15 
16 namespace Eigen {
17 
32 namespace internal {
33 
34 template <typename MatrixType, unsigned int Mode>
35 struct traits<SparseSelfAdjointView<MatrixType, Mode> > : traits<MatrixType> {};
36 
37 template <int SrcMode, int DstMode, bool NonHermitian, typename MatrixType, int DestOrder>
39  const MatrixType& mat,
41  const typename MatrixType::StorageIndex* perm = 0);
42 
43 template <int Mode, bool NonHermitian, typename MatrixType, int DestOrder>
45  const MatrixType& mat,
47  const typename MatrixType::StorageIndex* perm = 0);
48 
49 } // namespace internal
50 
51 template <typename MatrixType, unsigned int Mode_>
52 class SparseSelfAdjointView : public EigenBase<SparseSelfAdjointView<MatrixType, Mode_> > {
53  public:
54  enum {
55  Mode = Mode_,
56  TransposeMode = ((int(Mode) & int(Upper)) ? Lower : 0) | ((int(Mode) & int(Lower)) ? Upper : 0),
59  };
60 
62  typedef typename MatrixType::Scalar Scalar;
63  typedef typename MatrixType::StorageIndex StorageIndex;
67 
69  eigen_assert(rows() == cols() && "SelfAdjointView is only for squared matrices");
70  }
71 
72  inline Index rows() const { return m_matrix.rows(); }
73  inline Index cols() const { return m_matrix.cols(); }
74 
76  const MatrixTypeNested_& matrix() const { return m_matrix; }
77  std::remove_reference_t<MatrixTypeNested>& matrix() { return m_matrix; }
78 
86  template <typename OtherDerived>
89  }
90 
98  template <typename OtherDerived>
100  const SparseSelfAdjointView& rhs) {
102  }
103 
105  template <typename OtherDerived>
107  return Product<SparseSelfAdjointView, OtherDerived>(*this, rhs.derived());
108  }
109 
111  template <typename OtherDerived>
113  const SparseSelfAdjointView& rhs) {
114  return Product<OtherDerived, SparseSelfAdjointView>(lhs.derived(), rhs);
115  }
116 
125  template <typename DerivedU>
127 
129  // TODO implement twists in a more evaluator friendly fashion
133  }
134 
135  template <typename SrcMatrixType, int SrcMode>
138  return *this;
139  }
140 
143  return *this = src.twistedBy(pnull);
144  }
145 
146  // Since we override the copy-assignment operator, we need to explicitly redeclare the copy-constructor
148 
149  template <typename SrcMatrixType, unsigned int SrcMode>
152  return *this = src.twistedBy(pnull);
153  }
154 
158  eigen_assert(rows == this->rows() && cols == this->cols() &&
159  "SparseSelfadjointView::resize() does not actually allow to resize.");
160  }
161 
162  protected:
163  MatrixTypeNested m_matrix;
164  // mutable VectorI m_countPerRow;
165  // mutable VectorI m_countPerCol;
166  private:
167  template <typename Dest>
168  void evalTo(Dest&) const;
169 };
170 
171 /***************************************************************************
172  * Implementation of SparseMatrixBase methods
173  ***************************************************************************/
174 
175 template <typename Derived>
176 template <unsigned int UpLo>
180 }
181 
182 template <typename Derived>
183 template <unsigned int UpLo>
186  return SparseSelfAdjointView<Derived, UpLo>(derived());
187 }
188 
189 /***************************************************************************
190  * Implementation of SparseSelfAdjointView methods
191  ***************************************************************************/
192 
193 template <typename MatrixType, unsigned int Mode>
194 template <typename DerivedU>
196  const SparseMatrixBase<DerivedU>& u, const Scalar& alpha) {
197  SparseMatrix<Scalar, (MatrixType::Flags & RowMajorBit) ? RowMajor : ColMajor> tmp = u * u.adjoint();
198  if (alpha == Scalar(0))
199  m_matrix = tmp.template triangularView<Mode>();
200  else
201  m_matrix += alpha * tmp.template triangularView<Mode>();
202 
203  return *this;
204 }
205 
206 namespace internal {
207 
208 // TODO currently a selfadjoint expression has the form SelfAdjointView<.,.>
209 // in the future selfadjoint-ness should be defined by the expression traits
210 // such that Transpose<SelfAdjointView<.,.> > is valid. (currently TriangularBase::transpose() is overloaded to
211 // make it work)
212 template <typename MatrixType, unsigned int Mode>
216 };
217 
219 
220 template <>
223 };
224 template <>
227 };
228 
229 template <typename DstXprType, typename SrcXprType, typename Functor>
230 struct Assignment<DstXprType, SrcXprType, Functor, SparseSelfAdjoint2Sparse> {
231  typedef typename DstXprType::StorageIndex StorageIndex;
233 
234  template <typename DestScalar, int StorageOrder>
235  static void run(SparseMatrix<DestScalar, StorageOrder, StorageIndex>& dst, const SrcXprType& src,
236  const AssignOpType& /*func*/) {
237  internal::permute_symm_to_fullsymm<SrcXprType::Mode, false>(src.matrix(), dst);
238  }
239 
240  // FIXME: the handling of += and -= in sparse matrices should be cleanup so that next two overloads could be reduced
241  // to:
242  template <typename DestScalar, int StorageOrder, typename AssignFunc>
243  static void run(SparseMatrix<DestScalar, StorageOrder, StorageIndex>& dst, const SrcXprType& src,
244  const AssignFunc& func) {
246  run(tmp, src, AssignOpType());
248  }
249 
250  template <typename DestScalar, int StorageOrder>
251  static void run(SparseMatrix<DestScalar, StorageOrder, StorageIndex>& dst, const SrcXprType& src,
254  run(tmp, src, AssignOpType());
255  dst += tmp;
256  }
257 
258  template <typename DestScalar, int StorageOrder>
259  static void run(SparseMatrix<DestScalar, StorageOrder, StorageIndex>& dst, const SrcXprType& src,
262  run(tmp, src, AssignOpType());
263  dst -= tmp;
264  }
265 };
266 
267 } // end namespace internal
268 
269 /***************************************************************************
270  * Implementation of sparse self-adjoint time dense matrix
271  ***************************************************************************/
272 
273 namespace internal {
274 
275 template <int Mode, typename SparseLhsType, typename DenseRhsType, typename DenseResType, typename AlphaType>
276 inline void sparse_selfadjoint_time_dense_product(const SparseLhsType& lhs, const DenseRhsType& rhs, DenseResType& res,
277  const AlphaType& alpha) {
279 
281  typedef internal::remove_all_t<SparseLhsTypeNested> SparseLhsTypeNestedCleaned;
283  typedef typename LhsEval::InnerIterator LhsIterator;
284  typedef typename SparseLhsType::Scalar LhsScalar;
285 
286  enum {
287  LhsIsRowMajor = (LhsEval::Flags & RowMajorBit) == RowMajorBit,
288  ProcessFirstHalf = ((Mode & (Upper | Lower)) == (Upper | Lower)) || ((Mode & Upper) && !LhsIsRowMajor) ||
289  ((Mode & Lower) && LhsIsRowMajor),
290  ProcessSecondHalf = !ProcessFirstHalf
291  };
292 
293  SparseLhsTypeNested lhs_nested(lhs);
294  LhsEval lhsEval(lhs_nested);
295 
296  // work on one column at once
297  for (Index k = 0; k < rhs.cols(); ++k) {
298  for (Index j = 0; j < lhs.outerSize(); ++j) {
299  LhsIterator i(lhsEval, j);
300  // handle diagonal coeff
301  if (ProcessSecondHalf) {
302  while (i && i.index() < j) ++i;
303  if (i && i.index() == j) {
304  res.coeffRef(j, k) += alpha * i.value() * rhs.coeff(j, k);
305  ++i;
306  }
307  }
308 
309  // premultiplied rhs for scatters
311  // accumulator for partial scalar product
312  typename DenseResType::Scalar res_j(0);
313  for (; (ProcessFirstHalf ? i && i.index() < j : i); ++i) {
314  LhsScalar lhs_ij = i.value();
315  if (!LhsIsRowMajor) lhs_ij = numext::conj(lhs_ij);
316  res_j += lhs_ij * rhs.coeff(i.index(), k);
317  res(i.index(), k) += numext::conj(lhs_ij) * rhs_j;
318  }
319  res.coeffRef(j, k) += alpha * res_j;
320 
321  // handle diagonal coeff
322  if (ProcessFirstHalf && i && (i.index() == j)) res.coeffRef(j, k) += alpha * i.value() * rhs.coeff(j, k);
323  }
324  }
325 }
326 
327 template <typename LhsView, typename Rhs, int ProductType>
329  : generic_product_impl_base<LhsView, Rhs,
330  generic_product_impl<LhsView, Rhs, SparseSelfAdjointShape, DenseShape, ProductType> > {
331  template <typename Dest>
332  static void scaleAndAddTo(Dest& dst, const LhsView& lhsView, const Rhs& rhs, const typename Dest::Scalar& alpha) {
333  typedef typename LhsView::MatrixTypeNested_ Lhs;
334  typedef typename nested_eval<Lhs, Dynamic>::type LhsNested;
335  typedef typename nested_eval<Rhs, Dynamic>::type RhsNested;
336  LhsNested lhsNested(lhsView.matrix());
337  RhsNested rhsNested(rhs);
338 
339  internal::sparse_selfadjoint_time_dense_product<LhsView::Mode>(lhsNested, rhsNested, dst, alpha);
340  }
341 };
342 
343 template <typename Lhs, typename RhsView, int ProductType>
345  : generic_product_impl_base<Lhs, RhsView,
346  generic_product_impl<Lhs, RhsView, DenseShape, SparseSelfAdjointShape, ProductType> > {
347  template <typename Dest>
348  static void scaleAndAddTo(Dest& dst, const Lhs& lhs, const RhsView& rhsView, const typename Dest::Scalar& alpha) {
349  typedef typename RhsView::MatrixTypeNested_ Rhs;
350  typedef typename nested_eval<Lhs, Dynamic>::type LhsNested;
351  typedef typename nested_eval<Rhs, Dynamic>::type RhsNested;
352  LhsNested lhsNested(lhs);
353  RhsNested rhsNested(rhsView.matrix());
354 
355  // transpose everything
356  Transpose<Dest> dstT(dst);
357  internal::sparse_selfadjoint_time_dense_product<RhsView::TransposeMode>(rhsNested.transpose(),
358  lhsNested.transpose(), dstT, alpha);
359  }
360 };
361 
362 // NOTE: these two overloads are needed to evaluate the sparse selfadjoint view into a full sparse matrix
363 // TODO: maybe the copy could be handled by generic_product_impl so that these overloads would not be needed anymore
364 
365 template <typename LhsView, typename Rhs, int ProductTag>
367  : public evaluator<typename Product<typename Rhs::PlainObject, Rhs, DefaultProduct>::PlainObject> {
369  typedef typename XprType::PlainObject PlainObject;
371 
372  product_evaluator(const XprType& xpr) : m_lhs(xpr.lhs()), m_result(xpr.rows(), xpr.cols()) {
373  internal::construct_at<Base>(this, m_result);
375  xpr.rhs());
376  }
377 
378  protected:
379  typename Rhs::PlainObject m_lhs;
381 };
382 
383 template <typename Lhs, typename RhsView, int ProductTag>
385  : public evaluator<typename Product<Lhs, typename Lhs::PlainObject, DefaultProduct>::PlainObject> {
387  typedef typename XprType::PlainObject PlainObject;
389 
390  product_evaluator(const XprType& xpr) : m_rhs(xpr.rhs()), m_result(xpr.rows(), xpr.cols()) {
391  ::new (static_cast<Base*>(this)) Base(m_result);
393  m_result, xpr.lhs(), m_rhs);
394  }
395 
396  protected:
397  typename Lhs::PlainObject m_rhs;
399 };
400 
401 } // namespace internal
402 
403 /***************************************************************************
404  * Implementation of symmetric copies and permutations
405  ***************************************************************************/
406 namespace internal {
407 
408 template <int Mode, bool NonHermitian, typename MatrixType, int DestOrder>
410  const MatrixType& mat,
412  const typename MatrixType::StorageIndex* perm) {
413  typedef typename MatrixType::StorageIndex StorageIndex;
414  typedef typename MatrixType::Scalar Scalar;
416  typedef Matrix<StorageIndex, Dynamic, 1> VectorI;
417  typedef evaluator<MatrixType> MatEval;
418  typedef typename evaluator<MatrixType>::InnerIterator MatIterator;
419 
420  MatEval matEval(mat);
421  Dest& dest(_dest.derived());
422  enum { StorageOrderMatch = int(Dest::IsRowMajor) == int(MatrixType::IsRowMajor) };
423 
424  Index size = mat.rows();
425  VectorI count;
426  count.resize(size);
427  count.setZero();
428  dest.resize(size, size);
429  for (Index j = 0; j < size; ++j) {
430  Index jp = perm ? perm[j] : j;
431  for (MatIterator it(matEval, j); it; ++it) {
432  Index i = it.index();
433  Index r = it.row();
434  Index c = it.col();
435  Index ip = perm ? perm[i] : i;
436  if (Mode == int(Upper | Lower))
437  count[StorageOrderMatch ? jp : ip]++;
438  else if (r == c)
439  count[ip]++;
440  else if ((Mode == Lower && r > c) || (Mode == Upper && r < c)) {
441  count[ip]++;
442  count[jp]++;
443  }
444  }
445  }
446  Index nnz = count.sum();
447 
448  // reserve space
449  dest.resizeNonZeros(nnz);
450  dest.outerIndexPtr()[0] = 0;
451  for (Index j = 0; j < size; ++j) dest.outerIndexPtr()[j + 1] = dest.outerIndexPtr()[j] + count[j];
452  for (Index j = 0; j < size; ++j) count[j] = dest.outerIndexPtr()[j];
453 
454  // copy data
455  for (StorageIndex j = 0; j < size; ++j) {
456  for (MatIterator it(matEval, j); it; ++it) {
457  StorageIndex i = internal::convert_index<StorageIndex>(it.index());
458  Index r = it.row();
459  Index c = it.col();
460 
461  StorageIndex jp = perm ? perm[j] : j;
462  StorageIndex ip = perm ? perm[i] : i;
463 
464  if (Mode == int(Upper | Lower)) {
465  Index k = count[StorageOrderMatch ? jp : ip]++;
466  dest.innerIndexPtr()[k] = StorageOrderMatch ? ip : jp;
467  dest.valuePtr()[k] = it.value();
468  } else if (r == c) {
469  Index k = count[ip]++;
470  dest.innerIndexPtr()[k] = ip;
471  dest.valuePtr()[k] = it.value();
472  } else if (((Mode & Lower) == Lower && r > c) || ((Mode & Upper) == Upper && r < c)) {
473  if (!StorageOrderMatch) std::swap(ip, jp);
474  Index k = count[jp]++;
475  dest.innerIndexPtr()[k] = ip;
476  dest.valuePtr()[k] = it.value();
477  k = count[ip]++;
478  dest.innerIndexPtr()[k] = jp;
479  dest.valuePtr()[k] = (NonHermitian ? it.value() : numext::conj(it.value()));
480  }
481  }
482  }
483 }
484 
485 template <int SrcMode_, int DstMode_, bool NonHermitian, typename MatrixType, int DstOrder>
488  const typename MatrixType::StorageIndex* perm) {
489  typedef typename MatrixType::StorageIndex StorageIndex;
490  typedef typename MatrixType::Scalar Scalar;
492  typedef Matrix<StorageIndex, Dynamic, 1> VectorI;
493  typedef evaluator<MatrixType> MatEval;
494  typedef typename evaluator<MatrixType>::InnerIterator MatIterator;
495 
496  enum {
497  SrcOrder = MatrixType::IsRowMajor ? RowMajor : ColMajor,
498  StorageOrderMatch = int(SrcOrder) == int(DstOrder),
499  DstMode = DstOrder == RowMajor ? (DstMode_ == Upper ? Lower : Upper) : DstMode_,
500  SrcMode = SrcOrder == RowMajor ? (SrcMode_ == Upper ? Lower : Upper) : SrcMode_
501  };
502 
503  MatEval matEval(mat);
504 
505  Index size = mat.rows();
506  VectorI count(size);
507  count.setZero();
508  dest.resize(size, size);
509  for (StorageIndex j = 0; j < size; ++j) {
510  StorageIndex jp = perm ? perm[j] : j;
511  for (MatIterator it(matEval, j); it; ++it) {
512  StorageIndex i = it.index();
513  if ((int(SrcMode) == int(Lower) && i < j) || (int(SrcMode) == int(Upper) && i > j)) continue;
514 
515  StorageIndex ip = perm ? perm[i] : i;
516  count[int(DstMode) == int(Lower) ? (std::min)(ip, jp) : (std::max)(ip, jp)]++;
517  }
518  }
519  dest.outerIndexPtr()[0] = 0;
520  for (Index j = 0; j < size; ++j) dest.outerIndexPtr()[j + 1] = dest.outerIndexPtr()[j] + count[j];
521  dest.resizeNonZeros(dest.outerIndexPtr()[size]);
522  for (Index j = 0; j < size; ++j) count[j] = dest.outerIndexPtr()[j];
523 
524  for (StorageIndex j = 0; j < size; ++j) {
525  for (MatIterator it(matEval, j); it; ++it) {
526  StorageIndex i = it.index();
527  if ((int(SrcMode) == int(Lower) && i < j) || (int(SrcMode) == int(Upper) && i > j)) continue;
528 
529  StorageIndex jp = perm ? perm[j] : j;
530  StorageIndex ip = perm ? perm[i] : i;
531 
532  Index k = count[int(DstMode) == int(Lower) ? (std::min)(ip, jp) : (std::max)(ip, jp)]++;
533  dest.innerIndexPtr()[k] = int(DstMode) == int(Lower) ? (std::max)(ip, jp) : (std::min)(ip, jp);
534 
535  if (!StorageOrderMatch) std::swap(ip, jp);
536  if (((int(DstMode) == int(Lower) && ip < jp) || (int(DstMode) == int(Upper) && ip > jp)))
537  dest.valuePtr()[k] = (NonHermitian ? it.value() : numext::conj(it.value()));
538  else
539  dest.valuePtr()[k] = it.value();
540  }
541  }
542 }
543 
544 } // namespace internal
545 
546 // TODO implement twists in a more evaluator friendly fashion
547 
548 namespace internal {
549 
550 template <typename MatrixType, int Mode>
552 
553 } // namespace internal
554 
555 template <typename MatrixType, int Mode>
556 class SparseSymmetricPermutationProduct : public EigenBase<SparseSymmetricPermutationProduct<MatrixType, Mode> > {
557  public:
558  typedef typename MatrixType::Scalar Scalar;
559  typedef typename MatrixType::StorageIndex StorageIndex;
560  enum {
563  };
564 
565  protected:
567 
568  public:
570  typedef typename MatrixType::Nested MatrixTypeNested;
572 
574 
575  inline Index rows() const { return m_matrix.rows(); }
576  inline Index cols() const { return m_matrix.cols(); }
577 
578  const NestedExpression& matrix() const { return m_matrix; }
579  const Perm& perm() const { return m_perm; }
580 
581  protected:
583  const Perm& m_perm;
584 };
585 
586 namespace internal {
587 
588 template <typename DstXprType, typename MatrixType, int Mode, typename Scalar>
590  internal::assign_op<Scalar, typename MatrixType::Scalar>, Sparse2Sparse> {
592  typedef typename DstXprType::StorageIndex DstIndex;
593  template <int Options>
596  // internal::permute_symm_to_fullsymm<Mode>(m_matrix,_dest,m_perm.indices().data());
598  internal::permute_symm_to_fullsymm<Mode, false>(src.matrix(), tmp, src.perm().indices().data());
599  dst = tmp;
600  }
601 
602  template <typename DestType, unsigned int DestMode>
605  internal::permute_symm_to_symm<Mode, DestMode, false>(src.matrix(), dst.matrix(), src.perm().indices().data());
606  }
607 };
608 
609 } // end namespace internal
610 
611 } // end namespace Eigen
612 
613 #endif // EIGEN_SPARSE_SELFADJOINTVIEW_H
AnnoyingScalar conj(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:133
int i
Definition: BiCGSTAB_step_by_step.cpp:9
#define EIGEN_DEFAULT_COPY_CONSTRUCTOR(CLASS)
Macro to explicitly define the default copy constructor. This is necessary, because the implicit defi...
Definition: Macros.h:1119
#define EIGEN_ONLY_USED_FOR_DEBUG(x)
Definition: Macros.h:922
#define eigen_assert(x)
Definition: Macros.h:910
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
Definition: PartialRedux_count.cpp:3
int rows
Definition: Tutorial_commainit_02.cpp:1
int cols
Definition: Tutorial_commainit_02.cpp:1
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
SCALAR Scalar
Definition: bench_gemm.cpp:45
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:52
const IndicesType & indices() const
Definition: PermutationMatrix.h:334
Expression of the product of two arbitrary matrices or vectors.
Definition: Product.h:202
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const LhsNestedCleaned & lhs() const
Definition: Product.h:230
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const RhsNestedCleaned & rhs() const
Definition: Product.h:231
Base class of any sparse matrices or sparse expressions.
Definition: SparseMatrixBase.h:30
const Derived & derived() const
Definition: SparseMatrixBase.h:144
ConstSelfAdjointViewReturnType< UpLo >::Type selfadjointView() const
const AdjointReturnType adjoint() const
Definition: SparseMatrixBase.h:360
const Scalar * valuePtr() const
Definition: SparseMatrix.h:171
void resize(Index rows, Index cols)
Definition: SparseMatrix.h:734
Index rows() const
Definition: SparseMatrix.h:159
void resizeNonZeros(Index size)
Definition: SparseMatrix.h:754
const StorageIndex * outerIndexPtr() const
Definition: SparseMatrix.h:189
const StorageIndex * innerIndexPtr() const
Definition: SparseMatrix.h:180
Pseudo expression to manipulate a triangular sparse matrix as a selfadjoint matrix.
Definition: SparseSelfAdjointView.h:52
std::remove_reference_t< MatrixTypeNested > & matrix()
Definition: SparseSelfAdjointView.h:77
Product< SparseSelfAdjointView, OtherDerived > operator*(const SparseMatrixBase< OtherDerived > &rhs) const
Definition: SparseSelfAdjointView.h:87
SparseSelfAdjointView & operator=(const SparseSelfAdjointView &src)
Definition: SparseSelfAdjointView.h:141
Product< SparseSelfAdjointView, OtherDerived > operator*(const MatrixBase< OtherDerived > &rhs) const
Definition: SparseSelfAdjointView.h:106
MatrixType::Scalar Scalar
Definition: SparseSelfAdjointView.h:62
const MatrixTypeNested_ & matrix() const
Definition: SparseSelfAdjointView.h:76
SparseSelfAdjointView & rankUpdate(const SparseMatrixBase< DerivedU > &u, const Scalar &alpha=Scalar(1))
friend Product< OtherDerived, SparseSelfAdjointView > operator*(const SparseMatrixBase< OtherDerived > &lhs, const SparseSelfAdjointView &rhs)
Definition: SparseSelfAdjointView.h:99
SparseSelfAdjointView & operator=(const SparseSelfAdjointView< SrcMatrixType, SrcMode > &src)
Definition: SparseSelfAdjointView.h:150
internal::ref_selector< MatrixType >::non_const_type MatrixTypeNested
Definition: SparseSelfAdjointView.h:65
void evalTo(Dest &) const
Index cols() const
Definition: SparseSelfAdjointView.h:73
friend Product< OtherDerived, SparseSelfAdjointView > operator*(const MatrixBase< OtherDerived > &lhs, const SparseSelfAdjointView &rhs)
Definition: SparseSelfAdjointView.h:112
MatrixTypeNested m_matrix
Definition: SparseSelfAdjointView.h:163
SparseSelfAdjointView & operator=(const SparseSymmetricPermutationProduct< SrcMatrixType, SrcMode > &permutedMatrix)
Definition: SparseSelfAdjointView.h:136
Index rows() const
Definition: SparseSelfAdjointView.h:72
SparseSelfAdjointView(MatrixType &matrix)
Definition: SparseSelfAdjointView.h:68
Matrix< StorageIndex, Dynamic, 1 > VectorI
Definition: SparseSelfAdjointView.h:64
SparseSymmetricPermutationProduct< MatrixTypeNested_, Mode > twistedBy(const PermutationMatrix< Dynamic, Dynamic, StorageIndex > &perm) const
Definition: SparseSelfAdjointView.h:130
EigenBase< SparseSelfAdjointView > Base
Definition: SparseSelfAdjointView.h:61
internal::remove_all_t< MatrixTypeNested > MatrixTypeNested_
Definition: SparseSelfAdjointView.h:66
void resize(Index rows, Index cols)
Definition: SparseSelfAdjointView.h:155
@ Mode
Definition: SparseSelfAdjointView.h:55
@ RowsAtCompileTime
Definition: SparseSelfAdjointView.h:57
@ TransposeMode
Definition: SparseSelfAdjointView.h:56
@ ColsAtCompileTime
Definition: SparseSelfAdjointView.h:58
MatrixType::StorageIndex StorageIndex
Definition: SparseSelfAdjointView.h:63
Definition: SparseSelfAdjointView.h:556
MatrixType::Nested MatrixTypeNested
Definition: SparseSelfAdjointView.h:570
MatrixType::StorageIndex StorageIndex
Definition: SparseSelfAdjointView.h:559
SparseSymmetricPermutationProduct(const MatrixType &mat, const Perm &perm)
Definition: SparseSelfAdjointView.h:573
const Perm & perm() const
Definition: SparseSelfAdjointView.h:579
MatrixType::Scalar Scalar
Definition: SparseSelfAdjointView.h:558
const NestedExpression & matrix() const
Definition: SparseSelfAdjointView.h:578
internal::remove_all_t< MatrixTypeNested > NestedExpression
Definition: SparseSelfAdjointView.h:571
PermutationMatrix< Dynamic, Dynamic, StorageIndex > Perm
Definition: SparseSelfAdjointView.h:566
MatrixTypeNested m_matrix
Definition: SparseSelfAdjointView.h:582
Index cols() const
Definition: SparseSelfAdjointView.h:576
@ RowsAtCompileTime
Definition: SparseSelfAdjointView.h:561
@ ColsAtCompileTime
Definition: SparseSelfAdjointView.h:562
Matrix< StorageIndex, Dynamic, 1 > VectorI
Definition: SparseSelfAdjointView.h:569
Index rows() const
Definition: SparseSelfAdjointView.h:575
const Perm & m_perm
Definition: SparseSelfAdjointView.h:583
Expression of the transpose of a matrix.
Definition: Transpose.h:56
#define min(a, b)
Definition: datatypes.h:22
#define max(a, b)
Definition: datatypes.h:23
@ DefaultProduct
Definition: Constants.h:503
@ Lower
Definition: Constants.h:211
@ Upper
Definition: Constants.h:213
@ ColMajor
Definition: Constants.h:318
@ RowMajor
Definition: Constants.h:320
const unsigned int RowMajorBit
Definition: Constants.h:70
return int(ret)+1
RealScalar alpha
Definition: level1_cplx_impl.h:151
EIGEN_BLAS_FUNC() swap(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy)
Definition: level1_impl.h:117
char char char int int * k
Definition: level2_impl.h:374
Eigen::Matrix< Scalar, Dynamic, Dynamic, ColMajor > tmp
Definition: level3_impl.h:365
void sparse_selfadjoint_time_dense_product(const SparseLhsType &lhs, const DenseRhsType &rhs, DenseResType &res, const AlphaType &alpha)
Definition: SparseSelfAdjointView.h:276
@ Lhs
Definition: TensorContractionMapper.h:20
@ Rhs
Definition: TensorContractionMapper.h:20
void permute_symm_to_fullsymm(const MatrixType &mat, SparseMatrix< typename MatrixType::Scalar, DestOrder, typename MatrixType::StorageIndex > &_dest, const typename MatrixType::StorageIndex *perm=0)
Definition: SparseSelfAdjointView.h:409
void permute_symm_to_symm(const MatrixType &mat, SparseMatrix< typename MatrixType::Scalar, DestOrder, typename MatrixType::StorageIndex > &_dest, const typename MatrixType::StorageIndex *perm=0)
typename remove_all< T >::type remove_all_t
Definition: Meta.h:142
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR void call_assignment_no_alias_no_transpose(Dst &dst, const Src &src, const Func &func)
Definition: AssignEvaluator.h:857
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
auto run(Kernel kernel, Args &&... args) -> decltype(kernel(args...))
Definition: gpu_test_helper.h:414
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
r
Definition: UniformPSDSelfTest.py:20
int c
Definition: calibrate.py:100
Definition: Eigen_Colamd.h:49
Type
Type of JSON value.
Definition: rapidjson.h:513
Definition: Constants.h:540
Definition: EigenBase.h:33
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:43
Determines whether the given binary operation of two numeric types is allowed and what the scalar ret...
Definition: XprHelper.h:1043
Definition: Constants.h:570
Sparse2Sparse Kind
Definition: SparseSelfAdjointView.h:226
SparseSelfAdjoint2Sparse Kind
Definition: SparseSelfAdjointView.h:222
Definition: AssignEvaluator.h:760
static void run(SparseSelfAdjointView< DestType, DestMode > &dst, const SrcXprType &src, const internal::assign_op< Scalar, typename MatrixType::Scalar > &)
Definition: SparseSelfAdjointView.h:603
static void run(SparseMatrix< Scalar, Options, DstIndex > &dst, const SrcXprType &src, const internal::assign_op< Scalar, typename MatrixType::Scalar > &)
Definition: SparseSelfAdjointView.h:594
static void run(SparseMatrix< DestScalar, StorageOrder, StorageIndex > &dst, const SrcXprType &src, const internal::add_assign_op< typename DstXprType::Scalar, typename SrcXprType::Scalar > &)
Definition: SparseSelfAdjointView.h:251
DstXprType::StorageIndex StorageIndex
Definition: SparseSelfAdjointView.h:231
static void run(SparseMatrix< DestScalar, StorageOrder, StorageIndex > &dst, const SrcXprType &src, const AssignOpType &)
Definition: SparseSelfAdjointView.h:235
internal::assign_op< typename DstXprType::Scalar, typename SrcXprType::Scalar > AssignOpType
Definition: SparseSelfAdjointView.h:232
static void run(SparseMatrix< DestScalar, StorageOrder, StorageIndex > &dst, const SrcXprType &src, const AssignFunc &func)
Definition: SparseSelfAdjointView.h:243
static void run(SparseMatrix< DestScalar, StorageOrder, StorageIndex > &dst, const SrcXprType &src, const internal::sub_assign_op< typename DstXprType::Scalar, typename SrcXprType::Scalar > &)
Definition: SparseSelfAdjointView.h:259
Definition: AssignEvaluator.h:773
Definition: Constants.h:577
Definition: SparseAssign.h:60
Definition: SparseSelfAdjointView.h:218
Definition: SparseUtil.h:155
Template functor for scalar/packet assignment with addition.
Definition: AssignmentFunctors.h:52
Template functor for scalar/packet assignment.
Definition: AssignmentFunctors.h:25
storage_kind_to_evaluator_kind< typename MatrixType::StorageKind >::Kind Kind
Definition: SparseSelfAdjointView.h:214
SparseSelfAdjointShape Shape
Definition: SparseSelfAdjointView.h:215
Definition: CoreEvaluators.h:95
Definition: CoreEvaluators.h:104
static void scaleAndAddTo(Dest &dst, const LhsView &lhsView, const Rhs &rhs, const typename Dest::Scalar &alpha)
Definition: SparseSelfAdjointView.h:332
static void scaleAndAddTo(Dest &dst, const Lhs &lhs, const RhsView &rhsView, const typename Dest::Scalar &alpha)
Definition: SparseSelfAdjointView.h:348
Definition: ProductEvaluators.h:341
Definition: ProductEvaluators.h:78
std::conditional_t< Evaluate, PlainObject, typename ref_selector< T >::type > type
Definition: XprHelper.h:549
Definition: ForwardDeclarations.h:221
std::conditional_t< bool(traits< T >::Flags &NestByRefBit), T &, T > non_const_type
Definition: XprHelper.h:509
Template functor for scalar/packet assignment with subtraction.
Definition: AssignmentFunctors.h:73
Definition: ForwardDeclarations.h:21
Definition: NonLinearOptimization.cpp:97
Definition: benchGeometry.cpp:21
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2