Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-15 09:36:46

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_IMAGE_H
0011 #define EIGEN_MISC_IMAGE_H
0012 
0013 namespace Eigen { 
0014 
0015 namespace internal {
0016 
0017 /** \class image_retval_base
0018   *
0019   */
0020 template<typename DecompositionType>
0021 struct traits<image_retval_base<DecompositionType> >
0022 {
0023   typedef typename DecompositionType::MatrixType MatrixType;
0024   typedef Matrix<
0025     typename MatrixType::Scalar,
0026     MatrixType::RowsAtCompileTime, // the image is a subspace of the destination space, whose
0027                                    // dimension is the number of rows of the original matrix
0028     Dynamic,                       // we don't know at compile time the dimension of the image (the rank)
0029     MatrixType::Options,
0030     MatrixType::MaxRowsAtCompileTime, // the image matrix will consist of columns from the original matrix,
0031     MatrixType::MaxColsAtCompileTime  // so it has the same number of rows and at most as many columns.
0032   > ReturnType;
0033 };
0034 
0035 template<typename _DecompositionType> struct image_retval_base
0036  : public ReturnByValue<image_retval_base<_DecompositionType> >
0037 {
0038   typedef _DecompositionType DecompositionType;
0039   typedef typename DecompositionType::MatrixType MatrixType;
0040   typedef ReturnByValue<image_retval_base> Base;
0041 
0042   image_retval_base(const DecompositionType& dec, const MatrixType& originalMatrix)
0043     : m_dec(dec), m_rank(dec.rank()),
0044       m_cols(m_rank == 0 ? 1 : m_rank),
0045       m_originalMatrix(originalMatrix)
0046   {}
0047 
0048   inline Index rows() const { return m_dec.rows(); }
0049   inline Index cols() const { return m_cols; }
0050   inline Index rank() const { return m_rank; }
0051   inline const DecompositionType& dec() const { return m_dec; }
0052   inline const MatrixType& originalMatrix() const { return m_originalMatrix; }
0053 
0054   template<typename Dest> inline void evalTo(Dest& dst) const
0055   {
0056     static_cast<const image_retval<DecompositionType>*>(this)->evalTo(dst);
0057   }
0058 
0059   protected:
0060     const DecompositionType& m_dec;
0061     Index m_rank, m_cols;
0062     const MatrixType& m_originalMatrix;
0063 };
0064 
0065 } // end namespace internal
0066 
0067 #define EIGEN_MAKE_IMAGE_HELPERS(DecompositionType) \
0068   typedef typename DecompositionType::MatrixType MatrixType; \
0069   typedef typename MatrixType::Scalar Scalar; \
0070   typedef typename MatrixType::RealScalar RealScalar; \
0071   typedef Eigen::internal::image_retval_base<DecompositionType> Base; \
0072   using Base::dec; \
0073   using Base::originalMatrix; \
0074   using Base::rank; \
0075   using Base::rows; \
0076   using Base::cols; \
0077   image_retval(const DecompositionType& dec, const MatrixType& originalMatrix) \
0078     : Base(dec, originalMatrix) {}
0079 
0080 } // end namespace Eigen
0081 
0082 #endif // EIGEN_MISC_IMAGE_H