$darkmode
Eigen  5.0.1-dev
Image.h
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
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_MISC_IMAGE_H
11 #define EIGEN_MISC_IMAGE_H
12 
13 // IWYU pragma: private
14 #include "./InternalHeaderCheck.h"
15 
16 namespace Eigen {
17 
18 namespace internal {
19 
23 template <typename DecompositionType>
24 struct traits<image_retval_base<DecompositionType> > {
25  typedef typename DecompositionType::MatrixType MatrixType;
26  typedef Matrix<typename MatrixType::Scalar,
27  MatrixType::RowsAtCompileTime, // the image is a subspace of the destination space, whose
28  // dimension is the number of rows of the original matrix
29  Dynamic, // we don't know at compile time the dimension of the image (the rank)
30  traits<MatrixType>::Options,
31  MatrixType::MaxRowsAtCompileTime, // the image matrix will consist of columns from the original
32  // matrix,
33  MatrixType::MaxColsAtCompileTime // so it has the same number of rows and at most as many columns.
34  >
35  ReturnType;
36 };
37 
38 template <typename DecompositionType_>
39 struct image_retval_base : public ReturnByValue<image_retval_base<DecompositionType_> > {
40  typedef DecompositionType_ DecompositionType;
41  typedef typename DecompositionType::MatrixType MatrixType;
42  typedef ReturnByValue<image_retval_base> Base;
43 
44  image_retval_base(const DecompositionType& dec, const MatrixType& originalMatrix)
45  : m_dec(dec), m_rank(dec.rank()), m_cols(m_rank == 0 ? 1 : m_rank), m_originalMatrix(originalMatrix) {}
46 
47  inline Index rows() const { return m_dec.rows(); }
48  inline Index cols() const { return m_cols; }
49  inline Index rank() const { return m_rank; }
50  inline const DecompositionType& dec() const { return m_dec; }
51  inline const MatrixType& originalMatrix() const { return m_originalMatrix; }
52 
53  template <typename Dest>
54  inline void evalTo(Dest& dst) const {
55  static_cast<const image_retval<DecompositionType>*>(this)->evalTo(dst);
56  }
57 
58  protected:
59  const DecompositionType& m_dec;
60  Index m_rank, m_cols;
61  const MatrixType& m_originalMatrix;
62 };
63 
64 } // end namespace internal
65 
66 #define EIGEN_MAKE_IMAGE_HELPERS(DecompositionType) \
67  typedef typename DecompositionType::MatrixType MatrixType; \
68  typedef typename MatrixType::Scalar Scalar; \
69  typedef typename MatrixType::RealScalar RealScalar; \
70  typedef Eigen::internal::image_retval_base<DecompositionType> Base; \
71  using Base::dec; \
72  using Base::originalMatrix; \
73  using Base::rank; \
74  using Base::rows; \
75  using Base::cols; \
76  image_retval(const DecompositionType& dec, const MatrixType& originalMatrix) : Base(dec, originalMatrix) {}
77 
78 } // end namespace Eigen
79 
80 #endif // EIGEN_MISC_IMAGE_H
Namespace containing all symbols from the Eigen library.
Definition: B01_Experimental.dox:1
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:82
const int Dynamic
Definition: Constants.h:25