Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-19 09:52:11

0001 // This file is part of Eigen, a lightweight C++ template library
0002 // for linear algebra.
0003 //
0004 // Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
0005 //
0006 // This Source Code Form is subject to the terms of the Mozilla
0007 // Public License v. 2.0. If a copy of the MPL was not distributed
0008 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
0009 
0010 #ifndef EIGEN_MISC_KERNEL_H
0011 #define EIGEN_MISC_KERNEL_H
0012 
0013 namespace Eigen { 
0014 
0015 namespace internal {
0016 
0017 /** \class kernel_retval_base
0018   *
0019   */
0020 template<typename DecompositionType>
0021 struct traits<kernel_retval_base<DecompositionType> >
0022 {
0023   typedef typename DecompositionType::MatrixType MatrixType;
0024   typedef Matrix<
0025     typename MatrixType::Scalar,
0026     MatrixType::ColsAtCompileTime, // the number of rows in the "kernel matrix"
0027                                    // is the number of cols of the original matrix
0028                                    // so that the product "matrix * kernel = zero" makes sense
0029     Dynamic,                       // we don't know at compile-time the dimension of the kernel
0030     MatrixType::Options,
0031     MatrixType::MaxColsAtCompileTime, // see explanation for 2nd template parameter
0032     MatrixType::MaxColsAtCompileTime // the kernel is a subspace of the domain space,
0033                                      // whose dimension is the number of columns of the original matrix
0034   > ReturnType;
0035 };
0036 
0037 template<typename _DecompositionType> struct kernel_retval_base
0038  : public ReturnByValue<kernel_retval_base<_DecompositionType> >
0039 {
0040   typedef _DecompositionType DecompositionType;
0041   typedef ReturnByValue<kernel_retval_base> Base;
0042 
0043   explicit kernel_retval_base(const DecompositionType& dec)
0044     : m_dec(dec),
0045       m_rank(dec.rank()),
0046       m_cols(m_rank==dec.cols() ? 1 : dec.cols() - m_rank)
0047   {}
0048 
0049   inline Index rows() const { return m_dec.cols(); }
0050   inline Index cols() const { return m_cols; }
0051   inline Index rank() const { return m_rank; }
0052   inline const DecompositionType& dec() const { return m_dec; }
0053 
0054   template<typename Dest> inline void evalTo(Dest& dst) const
0055   {
0056     static_cast<const kernel_retval<DecompositionType>*>(this)->evalTo(dst);
0057   }
0058 
0059   protected:
0060     const DecompositionType& m_dec;
0061     Index m_rank, m_cols;
0062 };
0063 
0064 } // end namespace internal
0065 
0066 #define EIGEN_MAKE_KERNEL_HELPERS(DecompositionType) \
0067   typedef typename DecompositionType::MatrixType MatrixType; \
0068   typedef typename MatrixType::Scalar Scalar; \
0069   typedef typename MatrixType::RealScalar RealScalar; \
0070   typedef Eigen::internal::kernel_retval_base<DecompositionType> Base; \
0071   using Base::dec; \
0072   using Base::rank; \
0073   using Base::rows; \
0074   using Base::cols; \
0075   kernel_retval(const DecompositionType& dec) : Base(dec) {}
0076 
0077 } // end namespace Eigen
0078 
0079 #endif // EIGEN_MISC_KERNEL_H