1
// This file is part of Eigen, a lightweight C++ template library
4
// Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
6
// Eigen is free software; you can redistribute it and/or
7
// modify it under the terms of the GNU Lesser General Public
8
// License as published by the Free Software Foundation; either
9
// version 3 of the License, or (at your option) any later version.
11
// Alternatively, you can redistribute it and/or
12
// modify it under the terms of the GNU General Public License as
13
// published by the Free Software Foundation; either version 2 of
14
// the License, or (at your option) any later version.
16
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
17
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
19
// GNU General Public License for more details.
21
// You should have received a copy of the GNU Lesser General Public
22
// License and a copy of the GNU General Public License along with
23
// Eigen. If not, see <http://www.gnu.org/licenses/>.
25
#ifndef EIGEN_MISC_KERNEL_H
26
#define EIGEN_MISC_KERNEL_H
30
/** \class kernel_retval_base
33
template<typename DecompositionType>
34
struct traits<kernel_retval_base<DecompositionType> >
36
typedef typename DecompositionType::MatrixType MatrixType;
38
typename MatrixType::Scalar,
39
MatrixType::ColsAtCompileTime, // the number of rows in the "kernel matrix"
40
// is the number of cols of the original matrix
41
// so that the product "matrix * kernel = zero" makes sense
42
Dynamic, // we don't know at compile-time the dimension of the kernel
44
MatrixType::MaxColsAtCompileTime, // see explanation for 2nd template parameter
45
MatrixType::MaxColsAtCompileTime // the kernel is a subspace of the domain space,
46
// whose dimension is the number of columns of the original matrix
50
template<typename _DecompositionType> struct kernel_retval_base
51
: public ReturnByValue<kernel_retval_base<_DecompositionType> >
53
typedef _DecompositionType DecompositionType;
54
typedef ReturnByValue<kernel_retval_base> Base;
55
typedef typename Base::Index Index;
57
kernel_retval_base(const DecompositionType& dec)
60
m_cols(m_rank==dec.cols() ? 1 : dec.cols() - m_rank)
63
inline Index rows() const { return m_dec.cols(); }
64
inline Index cols() const { return m_cols; }
65
inline Index rank() const { return m_rank; }
66
inline const DecompositionType& dec() const { return m_dec; }
68
template<typename Dest> inline void evalTo(Dest& dst) const
70
static_cast<const kernel_retval<DecompositionType>*>(this)->evalTo(dst);
74
const DecompositionType& m_dec;
78
} // end namespace internal
80
#define EIGEN_MAKE_KERNEL_HELPERS(DecompositionType) \
81
typedef typename DecompositionType::MatrixType MatrixType; \
82
typedef typename MatrixType::Scalar Scalar; \
83
typedef typename MatrixType::RealScalar RealScalar; \
84
typedef typename MatrixType::Index Index; \
85
typedef Eigen::internal::kernel_retval_base<DecompositionType> Base; \
90
kernel_retval(const DecompositionType& dec) : Base(dec) {}
92
#endif // EIGEN_MISC_KERNEL_H