$darkmode
Eigen  5.0.1-dev
Kernel.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_KERNEL_H
11 #define EIGEN_MISC_KERNEL_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<kernel_retval_base<DecompositionType> > {
25  typedef typename DecompositionType::MatrixType MatrixType;
26  typedef Matrix<typename MatrixType::Scalar,
27  MatrixType::ColsAtCompileTime, // the number of rows in the "kernel matrix"
28  // is the number of cols of the original matrix
29  // so that the product "matrix * kernel = zero" makes sense
30  Dynamic, // we don't know at compile-time the dimension of the kernel
31  traits<MatrixType>::Options,
32  MatrixType::MaxColsAtCompileTime, // see explanation for 2nd template parameter
33  MatrixType::MaxColsAtCompileTime // the kernel is a subspace of the domain space,
34  // whose dimension is the number of columns of the original matrix
35  >
36  ReturnType;
37 };
38 
39 template <typename DecompositionType_>
40 struct kernel_retval_base : public ReturnByValue<kernel_retval_base<DecompositionType_> > {
41  typedef DecompositionType_ DecompositionType;
42  typedef ReturnByValue<kernel_retval_base> Base;
43 
44  explicit kernel_retval_base(const DecompositionType& dec)
45  : m_dec(dec), m_rank(dec.rank()), m_cols(m_rank == dec.cols() ? 1 : dec.cols() - m_rank) {}
46 
47  inline Index rows() const { return m_dec.cols(); }
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 
52  template <typename Dest>
53  inline void evalTo(Dest& dst) const {
54  static_cast<const kernel_retval<DecompositionType>*>(this)->evalTo(dst);
55  }
56 
57  protected:
58  const DecompositionType& m_dec;
59  Index m_rank, m_cols;
60 };
61 
62 } // end namespace internal
63 
64 #define EIGEN_MAKE_KERNEL_HELPERS(DecompositionType) \
65  typedef typename DecompositionType::MatrixType MatrixType; \
66  typedef typename MatrixType::Scalar Scalar; \
67  typedef typename MatrixType::RealScalar RealScalar; \
68  typedef Eigen::internal::kernel_retval_base<DecompositionType> Base; \
69  using Base::dec; \
70  using Base::rank; \
71  using Base::rows; \
72  using Base::cols; \
73  kernel_retval(const DecompositionType& dec) : Base(dec) {}
74 
75 } // end namespace Eigen
76 
77 #endif // EIGEN_MISC_KERNEL_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