Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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
00061
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