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 // 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_MINOR_H
00026 #define EIGEN_MINOR_H
00027 
00042 namespace internal {
00043 template<typename MatrixType>
00044 struct traits<Minor<MatrixType> >
00045  : traits<MatrixType>
00046 {
00047   typedef typename nested<MatrixType>::type MatrixTypeNested;
00048   typedef typename remove_reference<MatrixTypeNested>::type _MatrixTypeNested;
00049   typedef typename MatrixType::StorageKind StorageKind;
00050   enum {
00051     RowsAtCompileTime = (MatrixType::RowsAtCompileTime != Dynamic) ?
00052                           int(MatrixType::RowsAtCompileTime) - 1 : Dynamic,
00053     ColsAtCompileTime = (MatrixType::ColsAtCompileTime != Dynamic) ?
00054                           int(MatrixType::ColsAtCompileTime) - 1 : Dynamic,
00055     MaxRowsAtCompileTime = (MatrixType::MaxRowsAtCompileTime != Dynamic) ?
00056                              int(MatrixType::MaxRowsAtCompileTime) - 1 : Dynamic,
00057     MaxColsAtCompileTime = (MatrixType::MaxColsAtCompileTime != Dynamic) ?
00058                              int(MatrixType::MaxColsAtCompileTime) - 1 : Dynamic,
00059     Flags = _MatrixTypeNested::Flags & (HereditaryBits | LvalueBit),
00060     CoeffReadCost = _MatrixTypeNested::CoeffReadCost // minor is used typically on tiny matrices,
00061       // where loops are unrolled and the 'if' evaluates at compile time
00062   };
00063 };
00064 }
00065 
00066 template<typename MatrixType> class Minor
00067   : public MatrixBase<Minor<MatrixType> >
00068 {
00069   public:
00070 
00071     typedef MatrixBase<Minor> Base;
00072     EIGEN_DENSE_PUBLIC_INTERFACE(Minor)
00073 
00074     inline Minor(const MatrixType& matrix,
00075                        Index row, Index col)
00076       : m_matrix(matrix), m_row(row), m_col(col)
00077     {
00078       eigen_assert(row >= 0 && row < matrix.rows()
00079           && col >= 0 && col < matrix.cols());
00080     }
00081 
00082     EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Minor)
00083 
00084     inline Index rows() const { return m_matrix.rows() - 1; }
00085     inline Index cols() const { return m_matrix.cols() - 1; }
00086 
00087     inline Scalar& coeffRef(Index row, Index col)
00088     {
00089       return m_matrix.const_cast_derived().coeffRef(row + (row >= m_row), col + (col >= m_col));
00090     }
00091 
00092     inline const Scalar coeff(Index row, Index col) const
00093     {
00094       return m_matrix.coeff(row + (row >= m_row), col + (col >= m_col));
00095     }
00096 
00097   protected:
00098     const typename MatrixType::Nested m_matrix;
00099     const Index m_row, m_col;
00100 };
00101 
00112 template<typename Derived>
00113 inline Minor<Derived>
00114 MatrixBase<Derived>::minor(Index row, Index col)
00115 {
00116   return Minor<Derived>(derived(), row, col);
00117 }
00118 
00121 template<typename Derived>
00122 inline const Minor<Derived>
00123 MatrixBase<Derived>::minor(Index row, Index col) const
00124 {
00125   return Minor<Derived>(derived(), row, col);
00126 }
00127 
00128 #endif // EIGEN_MINOR_H


re_vision
Author(s): Dorian Galvez-Lopez
autogenerated on Sun Jan 5 2014 11:31:59