Image.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 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 #include "./InternalHeaderCheck.h"
14 
15 namespace Eigen {
16 
17 namespace internal {
18 
22 template<typename DecompositionType>
23 struct traits<image_retval_base<DecompositionType> >
24 {
26  typedef Matrix<
27  typename MatrixType::Scalar,
28  MatrixType::RowsAtCompileTime, // the image is a subspace of the destination space, whose
29  // dimension is the number of rows of the original matrix
30  Dynamic, // we don't know at compile time the dimension of the image (the rank)
31  MatrixType::Options,
32  MatrixType::MaxRowsAtCompileTime, // the image matrix will consist of columns from the original matrix,
33  MatrixType::MaxColsAtCompileTime // so it has the same number of rows and at most as many columns.
34  > ReturnType;
35 };
36 
37 template<typename DecompositionType_> struct image_retval_base
38  : public ReturnByValue<image_retval_base<DecompositionType_> >
39 {
40  typedef DecompositionType_ DecompositionType;
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()),
46  m_cols(m_rank == 0 ? 1 : m_rank),
47  m_originalMatrix(originalMatrix)
48  {}
49 
50  inline Index rows() const { return m_dec.rows(); }
51  inline Index cols() const { return m_cols; }
52  inline Index rank() const { return m_rank; }
53  inline const DecompositionType& dec() const { return m_dec; }
54  inline const MatrixType& originalMatrix() const { return m_originalMatrix; }
55 
56  template<typename Dest> inline void evalTo(Dest& dst) const
57  {
58  static_cast<const image_retval<DecompositionType>*>(this)->evalTo(dst);
59  }
60 
61  protected:
62  const DecompositionType& m_dec;
63  Index m_rank, m_cols;
64  const MatrixType& m_originalMatrix;
65 };
66 
67 } // end namespace internal
68 
69 #define EIGEN_MAKE_IMAGE_HELPERS(DecompositionType) \
70  typedef typename DecompositionType::MatrixType MatrixType; \
71  typedef typename MatrixType::Scalar Scalar; \
72  typedef typename MatrixType::RealScalar RealScalar; \
73  typedef Eigen::internal::image_retval_base<DecompositionType> Base; \
74  using Base::dec; \
75  using Base::originalMatrix; \
76  using Base::rank; \
77  using Base::rows; \
78  using Base::cols; \
79  image_retval(const DecompositionType& dec, const MatrixType& originalMatrix) \
80  : Base(dec, originalMatrix) {}
81 
82 } // end namespace Eigen
83 
84 #endif // EIGEN_MISC_IMAGE_H
Matrix< float, 1, Dynamic > MatrixType
internal::traits< Derived >::Scalar Scalar
Definition: DenseBase.h:61
internal::dense_xpr_base< ReturnByValue >::type Base
Definition: ReturnByValue.h:58
: InteropHeaders
Definition: Core:139
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:82
const int Dynamic
Definition: Constants.h:24