Eigne Matrix Class Library
Dependents: MPC_current_control HydraulicControlBoard_SW AHRS Test_ekf ... more
src/Core/Flagged.h@1:3b8049da21b8, 2019-09-24 (annotated)
- Committer:
- jsoh91
- Date:
- Tue Sep 24 00:18:23 2019 +0000
- Revision:
- 1:3b8049da21b8
- Parent:
- 0:13a5d365ba16
ignore and revise some of error parts
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ykuroda | 0:13a5d365ba16 | 1 | // This file is part of Eigen, a lightweight C++ template library |
ykuroda | 0:13a5d365ba16 | 2 | // for linear algebra. |
ykuroda | 0:13a5d365ba16 | 3 | // |
ykuroda | 0:13a5d365ba16 | 4 | // Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com> |
ykuroda | 0:13a5d365ba16 | 5 | // |
ykuroda | 0:13a5d365ba16 | 6 | // This Source Code Form is subject to the terms of the Mozilla |
ykuroda | 0:13a5d365ba16 | 7 | // Public License v. 2.0. If a copy of the MPL was not distributed |
ykuroda | 0:13a5d365ba16 | 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. |
ykuroda | 0:13a5d365ba16 | 9 | |
ykuroda | 0:13a5d365ba16 | 10 | #ifndef EIGEN_FLAGGED_H |
ykuroda | 0:13a5d365ba16 | 11 | #define EIGEN_FLAGGED_H |
ykuroda | 0:13a5d365ba16 | 12 | |
ykuroda | 0:13a5d365ba16 | 13 | namespace Eigen { |
ykuroda | 0:13a5d365ba16 | 14 | |
ykuroda | 0:13a5d365ba16 | 15 | /** \class Flagged |
ykuroda | 0:13a5d365ba16 | 16 | * \ingroup Core_Module |
ykuroda | 0:13a5d365ba16 | 17 | * |
ykuroda | 0:13a5d365ba16 | 18 | * \brief Expression with modified flags |
ykuroda | 0:13a5d365ba16 | 19 | * |
ykuroda | 0:13a5d365ba16 | 20 | * \param ExpressionType the type of the object of which we are modifying the flags |
ykuroda | 0:13a5d365ba16 | 21 | * \param Added the flags added to the expression |
ykuroda | 0:13a5d365ba16 | 22 | * \param Removed the flags removed from the expression (has priority over Added). |
ykuroda | 0:13a5d365ba16 | 23 | * |
ykuroda | 0:13a5d365ba16 | 24 | * This class represents an expression whose flags have been modified. |
ykuroda | 0:13a5d365ba16 | 25 | * It is the return type of MatrixBase::flagged() |
ykuroda | 0:13a5d365ba16 | 26 | * and most of the time this is the only way it is used. |
ykuroda | 0:13a5d365ba16 | 27 | * |
ykuroda | 0:13a5d365ba16 | 28 | * \sa MatrixBase::flagged() |
ykuroda | 0:13a5d365ba16 | 29 | */ |
ykuroda | 0:13a5d365ba16 | 30 | |
ykuroda | 0:13a5d365ba16 | 31 | namespace internal { |
ykuroda | 0:13a5d365ba16 | 32 | template<typename ExpressionType, unsigned int Added, unsigned int Removed> |
ykuroda | 0:13a5d365ba16 | 33 | struct traits<Flagged<ExpressionType, Added, Removed> > : traits<ExpressionType> |
ykuroda | 0:13a5d365ba16 | 34 | { |
ykuroda | 0:13a5d365ba16 | 35 | enum { Flags = (ExpressionType::Flags | Added) & ~Removed }; |
ykuroda | 0:13a5d365ba16 | 36 | }; |
ykuroda | 0:13a5d365ba16 | 37 | } |
ykuroda | 0:13a5d365ba16 | 38 | |
ykuroda | 0:13a5d365ba16 | 39 | template<typename ExpressionType, unsigned int Added, unsigned int Removed> class Flagged |
ykuroda | 0:13a5d365ba16 | 40 | : public MatrixBase<Flagged<ExpressionType, Added, Removed> > |
ykuroda | 0:13a5d365ba16 | 41 | { |
ykuroda | 0:13a5d365ba16 | 42 | public: |
ykuroda | 0:13a5d365ba16 | 43 | |
ykuroda | 0:13a5d365ba16 | 44 | typedef MatrixBase<Flagged> Base; |
ykuroda | 0:13a5d365ba16 | 45 | |
ykuroda | 0:13a5d365ba16 | 46 | EIGEN_DENSE_PUBLIC_INTERFACE(Flagged) |
ykuroda | 0:13a5d365ba16 | 47 | typedef typename internal::conditional<internal::must_nest_by_value<ExpressionType>::ret, |
ykuroda | 0:13a5d365ba16 | 48 | ExpressionType, const ExpressionType&>::type ExpressionTypeNested; |
ykuroda | 0:13a5d365ba16 | 49 | typedef typename ExpressionType::InnerIterator InnerIterator; |
ykuroda | 0:13a5d365ba16 | 50 | |
ykuroda | 0:13a5d365ba16 | 51 | inline Flagged(const ExpressionType& matrix) : m_matrix(matrix) {} |
ykuroda | 0:13a5d365ba16 | 52 | |
ykuroda | 0:13a5d365ba16 | 53 | inline Index rows() const { return m_matrix.rows(); } |
ykuroda | 0:13a5d365ba16 | 54 | inline Index cols() const { return m_matrix.cols(); } |
ykuroda | 0:13a5d365ba16 | 55 | inline Index outerStride() const { return m_matrix.outerStride(); } |
ykuroda | 0:13a5d365ba16 | 56 | inline Index innerStride() const { return m_matrix.innerStride(); } |
ykuroda | 0:13a5d365ba16 | 57 | |
ykuroda | 0:13a5d365ba16 | 58 | inline CoeffReturnType coeff(Index row, Index col) const |
ykuroda | 0:13a5d365ba16 | 59 | { |
ykuroda | 0:13a5d365ba16 | 60 | return m_matrix.coeff(row, col); |
ykuroda | 0:13a5d365ba16 | 61 | } |
ykuroda | 0:13a5d365ba16 | 62 | |
ykuroda | 0:13a5d365ba16 | 63 | inline CoeffReturnType coeff(Index index) const |
ykuroda | 0:13a5d365ba16 | 64 | { |
ykuroda | 0:13a5d365ba16 | 65 | return m_matrix.coeff(index); |
ykuroda | 0:13a5d365ba16 | 66 | } |
ykuroda | 0:13a5d365ba16 | 67 | |
ykuroda | 0:13a5d365ba16 | 68 | inline const Scalar& coeffRef(Index row, Index col) const |
ykuroda | 0:13a5d365ba16 | 69 | { |
ykuroda | 0:13a5d365ba16 | 70 | return m_matrix.const_cast_derived().coeffRef(row, col); |
ykuroda | 0:13a5d365ba16 | 71 | } |
ykuroda | 0:13a5d365ba16 | 72 | |
ykuroda | 0:13a5d365ba16 | 73 | inline const Scalar& coeffRef(Index index) const |
ykuroda | 0:13a5d365ba16 | 74 | { |
ykuroda | 0:13a5d365ba16 | 75 | return m_matrix.const_cast_derived().coeffRef(index); |
ykuroda | 0:13a5d365ba16 | 76 | } |
ykuroda | 0:13a5d365ba16 | 77 | |
ykuroda | 0:13a5d365ba16 | 78 | inline Scalar& coeffRef(Index row, Index col) |
ykuroda | 0:13a5d365ba16 | 79 | { |
ykuroda | 0:13a5d365ba16 | 80 | return m_matrix.const_cast_derived().coeffRef(row, col); |
ykuroda | 0:13a5d365ba16 | 81 | } |
ykuroda | 0:13a5d365ba16 | 82 | |
ykuroda | 0:13a5d365ba16 | 83 | inline Scalar& coeffRef(Index index) |
ykuroda | 0:13a5d365ba16 | 84 | { |
ykuroda | 0:13a5d365ba16 | 85 | return m_matrix.const_cast_derived().coeffRef(index); |
ykuroda | 0:13a5d365ba16 | 86 | } |
ykuroda | 0:13a5d365ba16 | 87 | |
ykuroda | 0:13a5d365ba16 | 88 | template<int LoadMode> |
ykuroda | 0:13a5d365ba16 | 89 | inline const PacketScalar packet(Index row, Index col) const |
ykuroda | 0:13a5d365ba16 | 90 | { |
ykuroda | 0:13a5d365ba16 | 91 | return m_matrix.template packet<LoadMode>(row, col); |
ykuroda | 0:13a5d365ba16 | 92 | } |
ykuroda | 0:13a5d365ba16 | 93 | |
ykuroda | 0:13a5d365ba16 | 94 | template<int LoadMode> |
ykuroda | 0:13a5d365ba16 | 95 | inline void writePacket(Index row, Index col, const PacketScalar& x) |
ykuroda | 0:13a5d365ba16 | 96 | { |
ykuroda | 0:13a5d365ba16 | 97 | m_matrix.const_cast_derived().template writePacket<LoadMode>(row, col, x); |
ykuroda | 0:13a5d365ba16 | 98 | } |
ykuroda | 0:13a5d365ba16 | 99 | |
ykuroda | 0:13a5d365ba16 | 100 | template<int LoadMode> |
ykuroda | 0:13a5d365ba16 | 101 | inline const PacketScalar packet(Index index) const |
ykuroda | 0:13a5d365ba16 | 102 | { |
ykuroda | 0:13a5d365ba16 | 103 | return m_matrix.template packet<LoadMode>(index); |
ykuroda | 0:13a5d365ba16 | 104 | } |
ykuroda | 0:13a5d365ba16 | 105 | |
ykuroda | 0:13a5d365ba16 | 106 | template<int LoadMode> |
ykuroda | 0:13a5d365ba16 | 107 | inline void writePacket(Index index, const PacketScalar& x) |
ykuroda | 0:13a5d365ba16 | 108 | { |
ykuroda | 0:13a5d365ba16 | 109 | m_matrix.const_cast_derived().template writePacket<LoadMode>(index, x); |
ykuroda | 0:13a5d365ba16 | 110 | } |
ykuroda | 0:13a5d365ba16 | 111 | |
ykuroda | 0:13a5d365ba16 | 112 | const ExpressionType& _expression() const { return m_matrix; } |
ykuroda | 0:13a5d365ba16 | 113 | |
ykuroda | 0:13a5d365ba16 | 114 | template<typename OtherDerived> |
ykuroda | 0:13a5d365ba16 | 115 | typename ExpressionType::PlainObject solveTriangular(const MatrixBase<OtherDerived>& other) const; |
ykuroda | 0:13a5d365ba16 | 116 | |
ykuroda | 0:13a5d365ba16 | 117 | template<typename OtherDerived> |
ykuroda | 0:13a5d365ba16 | 118 | void solveTriangularInPlace(const MatrixBase<OtherDerived>& other) const; |
ykuroda | 0:13a5d365ba16 | 119 | |
ykuroda | 0:13a5d365ba16 | 120 | protected: |
ykuroda | 0:13a5d365ba16 | 121 | ExpressionTypeNested m_matrix; |
ykuroda | 0:13a5d365ba16 | 122 | }; |
ykuroda | 0:13a5d365ba16 | 123 | |
ykuroda | 0:13a5d365ba16 | 124 | /** \returns an expression of *this with added and removed flags |
ykuroda | 0:13a5d365ba16 | 125 | * |
ykuroda | 0:13a5d365ba16 | 126 | * This is mostly for internal use. |
ykuroda | 0:13a5d365ba16 | 127 | * |
ykuroda | 0:13a5d365ba16 | 128 | * \sa class Flagged |
ykuroda | 0:13a5d365ba16 | 129 | */ |
ykuroda | 0:13a5d365ba16 | 130 | template<typename Derived> |
ykuroda | 0:13a5d365ba16 | 131 | template<unsigned int Added,unsigned int Removed> |
ykuroda | 0:13a5d365ba16 | 132 | inline const Flagged<Derived, Added, Removed> |
ykuroda | 0:13a5d365ba16 | 133 | DenseBase<Derived>::flagged() const |
ykuroda | 0:13a5d365ba16 | 134 | { |
ykuroda | 0:13a5d365ba16 | 135 | return derived(); |
ykuroda | 0:13a5d365ba16 | 136 | } |
ykuroda | 0:13a5d365ba16 | 137 | |
ykuroda | 0:13a5d365ba16 | 138 | } // end namespace Eigen |
ykuroda | 0:13a5d365ba16 | 139 | |
ykuroda | 0:13a5d365ba16 | 140 | #endif // EIGEN_FLAGGED_H |