Minor.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) 2006-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_MINOR_H
00011 #define EIGEN_MINOR_H
00012 
00013 namespace Eigen { 
00014 
00029 namespace internal {
00030 template<typename MatrixType>
00031 struct traits<Minor<MatrixType> >
00032  : traits<MatrixType>
00033 {
00034   typedef typename nested<MatrixType>::type MatrixTypeNested;
00035   typedef typename remove_reference<MatrixTypeNested>::type _MatrixTypeNested;
00036   typedef typename MatrixType::StorageKind StorageKind;
00037   enum {
00038     RowsAtCompileTime = (MatrixType::RowsAtCompileTime != Dynamic) ?
00039                           int(MatrixType::RowsAtCompileTime) - 1 : Dynamic,
00040     ColsAtCompileTime = (MatrixType::ColsAtCompileTime != Dynamic) ?
00041                           int(MatrixType::ColsAtCompileTime) - 1 : Dynamic,
00042     MaxRowsAtCompileTime = (MatrixType::MaxRowsAtCompileTime != Dynamic) ?
00043                              int(MatrixType::MaxRowsAtCompileTime) - 1 : Dynamic,
00044     MaxColsAtCompileTime = (MatrixType::MaxColsAtCompileTime != Dynamic) ?
00045                              int(MatrixType::MaxColsAtCompileTime) - 1 : Dynamic,
00046     Flags = _MatrixTypeNested::Flags & (HereditaryBits | LvalueBit),
00047     CoeffReadCost = _MatrixTypeNested::CoeffReadCost // minor is used typically on tiny matrices,
00048       // where loops are unrolled and the 'if' evaluates at compile time
00049   };
00050 };
00051 }
00052 
00053 template<typename MatrixType> class Minor
00054   : public MatrixBase<Minor<MatrixType> >
00055 {
00056   public:
00057 
00058     typedef MatrixBase<Minor> Base;
00059     EIGEN_DENSE_PUBLIC_INTERFACE(Minor)
00060 
00061     inline Minor(const MatrixType& matrix,
00062                        Index row, Index col)
00063       : m_matrix(matrix), m_row(row), m_col(col)
00064     {
00065       eigen_assert(row >= 0 && row < matrix.rows()
00066           && col >= 0 && col < matrix.cols());
00067     }
00068 
00069     EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Minor)
00070 
00071     inline Index rows() const { return m_matrix.rows() - 1; }
00072     inline Index cols() const { return m_matrix.cols() - 1; }
00073 
00074     inline Scalar& coeffRef(Index row, Index col)
00075     {
00076       return m_matrix.const_cast_derived().coeffRef(row + (row >= m_row), col + (col >= m_col));
00077     }
00078 
00079     inline const Scalar coeff(Index row, Index col) const
00080     {
00081       return m_matrix.coeff(row + (row >= m_row), col + (col >= m_col));
00082     }
00083 
00084   protected:
00085     const typename MatrixType::Nested m_matrix;
00086     const Index m_row, m_col;
00087 };
00088 
00099 template<typename Derived>
00100 inline Minor<Derived>
00101 MatrixBase<Derived>::minor(Index row, Index col)
00102 {
00103   return Minor<Derived>(derived(), row, col);
00104 }
00105 
00108 template<typename Derived>
00109 inline const Minor<Derived>
00110 MatrixBase<Derived>::minor(Index row, Index col) const
00111 {
00112   return Minor<Derived>(derived(), row, col);
00113 }
00114 
00115 } // end namespace Eigen
00116 
00117 #endif // EIGEN_MINOR_H


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Sat Jun 8 2019 19:38:13