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
00041 template<typename MatrixType>
00042 struct ei_traits<Minor<MatrixType> >
00043 {
00044 typedef typename MatrixType::Scalar Scalar;
00045 typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
00046 typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
00047 enum {
00048 RowsAtCompileTime = (MatrixType::RowsAtCompileTime != Dynamic) ?
00049 int(MatrixType::RowsAtCompileTime) - 1 : Dynamic,
00050 ColsAtCompileTime = (MatrixType::ColsAtCompileTime != Dynamic) ?
00051 int(MatrixType::ColsAtCompileTime) - 1 : Dynamic,
00052 MaxRowsAtCompileTime = (MatrixType::MaxRowsAtCompileTime != Dynamic) ?
00053 int(MatrixType::MaxRowsAtCompileTime) - 1 : Dynamic,
00054 MaxColsAtCompileTime = (MatrixType::MaxColsAtCompileTime != Dynamic) ?
00055 int(MatrixType::MaxColsAtCompileTime) - 1 : Dynamic,
00056 Flags = _MatrixTypeNested::Flags & HereditaryBits,
00057 CoeffReadCost = _MatrixTypeNested::CoeffReadCost
00058 };
00059 };
00060
00061 template<typename MatrixType> class Minor
00062 : public MatrixBase<Minor<MatrixType> >
00063 {
00064 public:
00065
00066 EIGEN_GENERIC_PUBLIC_INTERFACE(Minor)
00067
00068 inline Minor(const MatrixType& matrix,
00069 int row, int col)
00070 : m_matrix(matrix), m_row(row), m_col(col)
00071 {
00072 ei_assert(row >= 0 && row < matrix.rows()
00073 && col >= 0 && col < matrix.cols());
00074 }
00075
00076 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Minor)
00077
00078 inline int rows() const { return m_matrix.rows() - 1; }
00079 inline int cols() const { return m_matrix.cols() - 1; }
00080
00081 inline Scalar& coeffRef(int row, int col)
00082 {
00083 return m_matrix.const_cast_derived().coeffRef(row + (row >= m_row), col + (col >= m_col));
00084 }
00085
00086 inline const Scalar coeff(int row, int col) const
00087 {
00088 return m_matrix.coeff(row + (row >= m_row), col + (col >= m_col));
00089 }
00090
00091 protected:
00092 const typename MatrixType::Nested m_matrix;
00093 const int m_row, m_col;
00094 };
00095
00106 template<typename Derived>
00107 inline Minor<Derived>
00108 MatrixBase<Derived>::minor(int row, int col)
00109 {
00110 return Minor<Derived>(derived(), row, col);
00111 }
00112
00115 template<typename Derived>
00116 inline const Minor<Derived>
00117 MatrixBase<Derived>::minor(int row, int col) const
00118 {
00119 return Minor<Derived>(derived(), row, col);
00120 }
00121
00122 #endif // EIGEN_MINOR_H