Eigen  3.3.3
Image.h
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 // This Source Code Form is subject to the terms of the Mozilla
00007 // Public License v. 2.0. If a copy of the MPL was not distributed
00008 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
00009 
00010 #ifndef EIGEN_MISC_IMAGE_H
00011 #define EIGEN_MISC_IMAGE_H
00012 
00013 namespace Eigen { 
00014 
00015 namespace internal {
00016 
00020 template<typename DecompositionType>
00021 struct traits<image_retval_base<DecompositionType> >
00022 {
00023   typedef typename DecompositionType::MatrixType MatrixType;
00024   typedef Matrix<
00025     typename MatrixType::Scalar,
00026     MatrixType::RowsAtCompileTime, // the image is a subspace of the destination space, whose
00027                                    // dimension is the number of rows of the original matrix
00028     Dynamic,                       // we don't know at compile time the dimension of the image (the rank)
00029     MatrixType::Options,
00030     MatrixType::MaxRowsAtCompileTime, // the image matrix will consist of columns from the original matrix,
00031     MatrixType::MaxColsAtCompileTime  // so it has the same number of rows and at most as many columns.
00032   > ReturnType;
00033 };
00034 
00035 template<typename _DecompositionType> struct image_retval_base
00036  : public ReturnByValue<image_retval_base<_DecompositionType> >
00037 {
00038   typedef _DecompositionType DecompositionType;
00039   typedef typename DecompositionType::MatrixType MatrixType;
00040   typedef ReturnByValue<image_retval_base> Base;
00041 
00042   image_retval_base(const DecompositionType& dec, const MatrixType& originalMatrix)
00043     : m_dec(dec), m_rank(dec.rank()),
00044       m_cols(m_rank == 0 ? 1 : m_rank),
00045       m_originalMatrix(originalMatrix)
00046   {}
00047 
00048   inline Index rows() const { return m_dec.rows(); }
00049   inline Index cols() const { return m_cols; }
00050   inline Index rank() const { return m_rank; }
00051   inline const DecompositionType& dec() const { return m_dec; }
00052   inline const MatrixType& originalMatrix() const { return m_originalMatrix; }
00053 
00054   template<typename Dest> inline void evalTo(Dest& dst) const
00055   {
00056     static_cast<const image_retval<DecompositionType>*>(this)->evalTo(dst);
00057   }
00058 
00059   protected:
00060     const DecompositionType& m_dec;
00061     Index m_rank, m_cols;
00062     const MatrixType& m_originalMatrix;
00063 };
00064 
00065 } // end namespace internal
00066 
00067 #define EIGEN_MAKE_IMAGE_HELPERS(DecompositionType) \
00068   typedef typename DecompositionType::MatrixType MatrixType; \
00069   typedef typename MatrixType::Scalar Scalar; \
00070   typedef typename MatrixType::RealScalar RealScalar; \
00071   typedef Eigen::internal::image_retval_base<DecompositionType> Base; \
00072   using Base::dec; \
00073   using Base::originalMatrix; \
00074   using Base::rank; \
00075   using Base::rows; \
00076   using Base::cols; \
00077   image_retval(const DecompositionType& dec, const MatrixType& originalMatrix) \
00078     : Base(dec, originalMatrix) {}
00079 
00080 } // end namespace Eigen
00081 
00082 #endif // EIGEN_MISC_IMAGE_H
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends