Kernel.h
Go to the documentation of this file.
00001 // This file is part of Eigen, a lightweight C++ template library
00002 // for linear algebra.
00003 //
00004 // Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
00005 //
00006 // Eigen is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 3 of the License, or (at your option) any later version.
00010 //
00011 // Alternatively, you can redistribute it and/or
00012 // modify it under the terms of the GNU General Public License as
00013 // published by the Free Software Foundation; either version 2 of
00014 // the License, or (at your option) any later version.
00015 //
00016 // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
00017 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00018 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
00019 // GNU General Public License for more details.
00020 //
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License and a copy of the GNU General Public License along with
00023 // Eigen. If not, see <http://www.gnu.org/licenses/>.
00024 
00025 #ifndef EIGEN_MISC_KERNEL_H
00026 #define EIGEN_MISC_KERNEL_H
00027 
00028 namespace internal {
00029 
00033 template<typename DecompositionType>
00034 struct traits<kernel_retval_base<DecompositionType> >
00035 {
00036   typedef typename DecompositionType::MatrixType MatrixType;
00037   typedef Matrix<
00038     typename MatrixType::Scalar,
00039     MatrixType::ColsAtCompileTime, // the number of rows in the "kernel matrix"
00040                                    // is the number of cols of the original matrix
00041                                    // so that the product "matrix * kernel = zero" makes sense
00042     Dynamic,                       // we don't know at compile-time the dimension of the kernel
00043     MatrixType::Options,
00044     MatrixType::MaxColsAtCompileTime, // see explanation for 2nd template parameter
00045     MatrixType::MaxColsAtCompileTime // the kernel is a subspace of the domain space,
00046                                      // whose dimension is the number of columns of the original matrix
00047   > ReturnType;
00048 };
00049 
00050 template<typename _DecompositionType> struct kernel_retval_base
00051  : public ReturnByValue<kernel_retval_base<_DecompositionType> >
00052 {
00053   typedef _DecompositionType DecompositionType;
00054   typedef ReturnByValue<kernel_retval_base> Base;
00055   typedef typename Base::Index Index;
00056 
00057   kernel_retval_base(const DecompositionType& dec)
00058     : m_dec(dec),
00059       m_rank(dec.rank()),
00060       m_cols(m_rank==dec.cols() ? 1 : dec.cols() - m_rank)
00061   {}
00062 
00063   inline Index rows() const { return m_dec.cols(); }
00064   inline Index cols() const { return m_cols; }
00065   inline Index rank() const { return m_rank; }
00066   inline const DecompositionType& dec() const { return m_dec; }
00067 
00068   template<typename Dest> inline void evalTo(Dest& dst) const
00069   {
00070     static_cast<const kernel_retval<DecompositionType>*>(this)->evalTo(dst);
00071   }
00072 
00073   protected:
00074     const DecompositionType& m_dec;
00075     Index m_rank, m_cols;
00076 };
00077 
00078 } // end namespace internal
00079 
00080 #define EIGEN_MAKE_KERNEL_HELPERS(DecompositionType) \
00081   typedef typename DecompositionType::MatrixType MatrixType; \
00082   typedef typename MatrixType::Scalar Scalar; \
00083   typedef typename MatrixType::RealScalar RealScalar; \
00084   typedef typename MatrixType::Index Index; \
00085   typedef Eigen::internal::kernel_retval_base<DecompositionType> Base; \
00086   using Base::dec; \
00087   using Base::rank; \
00088   using Base::rows; \
00089   using Base::cols; \
00090   kernel_retval(const DecompositionType& dec) : Base(dec) {}
00091 
00092 #endif // EIGEN_MISC_KERNEL_H


libicr
Author(s): Robert Krug
autogenerated on Mon Jan 6 2014 11:32:55