Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GaussianProcessTuning/HeuristicLab.Eigen/Eigen/src/misc/Kernel.h @ 9562

Last change on this file since 9562 was 9562, checked in by gkronber, 11 years ago

#1967 worked on Gaussian process evolution.

File size: 2.8 KB
Line 
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
13namespace Eigen {
14
15namespace internal {
16
17/** \class kernel_retval_base
18  *
19  */
20template<typename DecompositionType>
21struct traits<kernel_retval_base<DecompositionType> >
22{
23  typedef typename DecompositionType::MatrixType MatrixType;
24  typedef Matrix<
25    typename MatrixType::Scalar,
26    MatrixType::ColsAtCompileTime, // the number of rows in the "kernel matrix"
27                                   // is the number of cols of the original matrix
28                                   // so that the product "matrix * kernel = zero" makes sense
29    Dynamic,                       // we don't know at compile-time the dimension of the kernel
30    MatrixType::Options,
31    MatrixType::MaxColsAtCompileTime, // see explanation for 2nd template parameter
32    MatrixType::MaxColsAtCompileTime // the kernel is a subspace of the domain space,
33                                     // whose dimension is the number of columns of the original matrix
34  > ReturnType;
35};
36
37template<typename _DecompositionType> struct kernel_retval_base
38 : public ReturnByValue<kernel_retval_base<_DecompositionType> >
39{
40  typedef _DecompositionType DecompositionType;
41  typedef ReturnByValue<kernel_retval_base> Base;
42  typedef typename Base::Index Index;
43
44  kernel_retval_base(const DecompositionType& dec)
45    : m_dec(dec),
46      m_rank(dec.rank()),
47      m_cols(m_rank==dec.cols() ? 1 : dec.cols() - m_rank)
48  {}
49
50  inline Index rows() const { return m_dec.cols(); }
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
55  template<typename Dest> inline void evalTo(Dest& dst) const
56  {
57    static_cast<const kernel_retval<DecompositionType>*>(this)->evalTo(dst);
58  }
59
60  protected:
61    const DecompositionType& m_dec;
62    Index m_rank, m_cols;
63};
64
65} // end namespace internal
66
67#define EIGEN_MAKE_KERNEL_HELPERS(DecompositionType) \
68  typedef typename DecompositionType::MatrixType MatrixType; \
69  typedef typename MatrixType::Scalar Scalar; \
70  typedef typename MatrixType::RealScalar RealScalar; \
71  typedef typename MatrixType::Index Index; \
72  typedef Eigen::internal::kernel_retval_base<DecompositionType> Base; \
73  using Base::dec; \
74  using Base::rank; \
75  using Base::rows; \
76  using Base::cols; \
77  kernel_retval(const DecompositionType& dec) : Base(dec) {}
78
79} // end namespace Eigen
80
81#endif // EIGEN_MISC_KERNEL_H
Note: See TracBrowser for help on using the repository browser.