Kernel.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_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> > {
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
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  >
37 };
38 
39 template <typename DecompositionType_>
40 struct kernel_retval_base : public ReturnByValue<kernel_retval_base<DecompositionType_> > {
41  typedef DecompositionType_ DecompositionType;
43 
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:
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
SCALAR Scalar
Definition: bench_gemm.cpp:45
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
The matrix class, also used for vectors and row-vectors.
Definition: Eigen/Eigen/src/Core/Matrix.h:186
Definition: ReturnByValue.h:50
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
const int Dynamic
Definition: Constants.h:25
Definition: Eigen_Colamd.h:49
const DecompositionType & dec() const
Definition: Kernel.h:50
void evalTo(Dest &dst) const
Definition: Kernel.h:53
kernel_retval_base(const DecompositionType &dec)
Definition: Kernel.h:44
DecompositionType_ DecompositionType
Definition: Kernel.h:41
Index cols() const
Definition: Kernel.h:48
const DecompositionType & m_dec
Definition: Kernel.h:58
Index rows() const
Definition: Kernel.h:47
ReturnByValue< kernel_retval_base > Base
Definition: Kernel.h:42
Index m_cols
Definition: Kernel.h:59
Index m_rank
Definition: Kernel.h:59
Index rank() const
Definition: Kernel.h:49
Definition: ForwardDeclarations.h:203
DecompositionType::MatrixType MatrixType
Definition: Kernel.h:25
Matrix< typename MatrixType::Scalar, MatrixType::ColsAtCompileTime, Dynamic, traits< MatrixType >::Options, MatrixType::MaxColsAtCompileTime, MatrixType::MaxColsAtCompileTime > ReturnType
Definition: Kernel.h:36
Definition: ForwardDeclarations.h:21