Minor.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2006-2009 Benoit Jacob <jacob.benoit.1@gmail.com>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_MINOR_H
11 #define EIGEN_MINOR_H
12 
13 namespace Eigen {
14 
29 namespace internal {
30 template<typename MatrixType>
31 struct traits<Minor<MatrixType> >
32  : traits<MatrixType>
33 {
36  typedef typename MatrixType::StorageKind StorageKind;
37  enum {
38  RowsAtCompileTime = (MatrixType::RowsAtCompileTime != Dynamic) ?
39  int(MatrixType::RowsAtCompileTime) - 1 : Dynamic,
40  ColsAtCompileTime = (MatrixType::ColsAtCompileTime != Dynamic) ?
41  int(MatrixType::ColsAtCompileTime) - 1 : Dynamic,
42  MaxRowsAtCompileTime = (MatrixType::MaxRowsAtCompileTime != Dynamic) ?
43  int(MatrixType::MaxRowsAtCompileTime) - 1 : Dynamic,
44  MaxColsAtCompileTime = (MatrixType::MaxColsAtCompileTime != Dynamic) ?
45  int(MatrixType::MaxColsAtCompileTime) - 1 : Dynamic,
46  Flags = _MatrixTypeNested::Flags & (HereditaryBits | LvalueBit),
47  CoeffReadCost = _MatrixTypeNested::CoeffReadCost // minor is used typically on tiny matrices,
48  // where loops are unrolled and the 'if' evaluates at compile time
49  };
50 };
51 }
52 
53 template<typename MatrixType> class Minor
54  : public MatrixBase<Minor<MatrixType> >
55 {
56  public:
57 
60 
61  inline Minor(const MatrixType& matrix,
62  Index row, Index col)
63  : m_matrix(matrix), m_row(row), m_col(col)
64  {
65  eigen_assert(row >= 0 && row < matrix.rows()
66  && col >= 0 && col < matrix.cols());
67  }
68 
70 
71  inline Index rows() const { return m_matrix.rows() - 1; }
72  inline Index cols() const { return m_matrix.cols() - 1; }
73 
75  {
76  return m_matrix.const_cast_derived().coeffRef(row + (row >= m_row), col + (col >= m_col));
77  }
78 
79  inline const Scalar coeff(Index row, Index col) const
80  {
81  return m_matrix.coeff(row + (row >= m_row), col + (col >= m_col));
82  }
83 
84  protected:
85  const typename MatrixType::Nested m_matrix;
86  const Index m_row, m_col;
87 };
88 
99 template<typename Derived>
100 inline Minor<Derived>
102 {
103  return Minor<Derived>(derived(), row, col);
104 }
105 
108 template<typename Derived>
109 inline const Minor<Derived>
111 {
112  return Minor<Derived>(derived(), row, col);
113 }
114 
115 } // end namespace Eigen
116 
117 #endif // EIGEN_MINOR_H
internal::traits< Derived >::Scalar Scalar
Definition: DenseBase.h:63
internal::traits< Derived >::Index Index
The type of indices.
Definition: DenseBase.h:61
remove_reference< MatrixTypeNested >::type _MatrixTypeNested
Definition: Minor.h:35
const unsigned int LvalueBit
Definition: Constants.h:131
Definition: LDLT.h:16
nested< MatrixType >::type MatrixTypeNested
Definition: Minor.h:34
Scalar & coeffRef(Index row, Index col)
Definition: Minor.h:74
#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived)
const Scalar coeff(Index row, Index col) const
Definition: Minor.h:79
const unsigned int HereditaryBits
Definition: Constants.h:152
MatrixBase< Minor > Base
Definition: Minor.h:58
MatrixType::StorageKind StorageKind
Definition: Minor.h:36
Expression of a minor.
Definition: Minor.h:53
const Index m_row
Definition: Minor.h:86
Index cols() const
Definition: Minor.h:72
#define EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
RowXpr row(Index i)
Definition: BlockMethods.h:725
const MatrixType::Nested m_matrix
Definition: Minor.h:85
const int Dynamic
Definition: Constants.h:21
ColXpr col(Index i)
Definition: BlockMethods.h:708
#define eigen_assert(x)
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48


tuw_aruco
Author(s): Lukas Pfeifhofer
autogenerated on Mon Jun 10 2019 15:40:54