Eigne Matrix Class Library
Dependents: MPC_current_control HydraulicControlBoard_SW AHRS Test_ekf ... more
src/Geometry/Homogeneous.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) 2009-2010 Gael Guennebaud <gael.guennebaud@inria.fr> |
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_HOMOGENEOUS_H |
ykuroda | 0:13a5d365ba16 | 11 | #define EIGEN_HOMOGENEOUS_H |
ykuroda | 0:13a5d365ba16 | 12 | |
ykuroda | 0:13a5d365ba16 | 13 | namespace Eigen { |
ykuroda | 0:13a5d365ba16 | 14 | |
ykuroda | 0:13a5d365ba16 | 15 | /** \geometry_module \ingroup Geometry_Module |
ykuroda | 0:13a5d365ba16 | 16 | * |
ykuroda | 0:13a5d365ba16 | 17 | * \class Homogeneous |
ykuroda | 0:13a5d365ba16 | 18 | * |
ykuroda | 0:13a5d365ba16 | 19 | * \brief Expression of one (or a set of) homogeneous vector(s) |
ykuroda | 0:13a5d365ba16 | 20 | * |
ykuroda | 0:13a5d365ba16 | 21 | * \param MatrixType the type of the object in which we are making homogeneous |
ykuroda | 0:13a5d365ba16 | 22 | * |
ykuroda | 0:13a5d365ba16 | 23 | * This class represents an expression of one (or a set of) homogeneous vector(s). |
ykuroda | 0:13a5d365ba16 | 24 | * It is the return type of MatrixBase::homogeneous() and most of the time |
ykuroda | 0:13a5d365ba16 | 25 | * this is the only way it is used. |
ykuroda | 0:13a5d365ba16 | 26 | * |
ykuroda | 0:13a5d365ba16 | 27 | * \sa MatrixBase::homogeneous() |
ykuroda | 0:13a5d365ba16 | 28 | */ |
ykuroda | 0:13a5d365ba16 | 29 | |
ykuroda | 0:13a5d365ba16 | 30 | namespace internal { |
ykuroda | 0:13a5d365ba16 | 31 | |
ykuroda | 0:13a5d365ba16 | 32 | template<typename MatrixType,int Direction> |
ykuroda | 0:13a5d365ba16 | 33 | struct traits<Homogeneous<MatrixType,Direction> > |
ykuroda | 0:13a5d365ba16 | 34 | : traits<MatrixType> |
ykuroda | 0:13a5d365ba16 | 35 | { |
ykuroda | 0:13a5d365ba16 | 36 | typedef typename traits<MatrixType>::StorageKind StorageKind; |
ykuroda | 0:13a5d365ba16 | 37 | typedef typename nested<MatrixType>::type MatrixTypeNested; |
ykuroda | 0:13a5d365ba16 | 38 | typedef typename remove_reference<MatrixTypeNested>::type _MatrixTypeNested; |
ykuroda | 0:13a5d365ba16 | 39 | enum { |
ykuroda | 0:13a5d365ba16 | 40 | RowsPlusOne = (MatrixType::RowsAtCompileTime != Dynamic) ? |
ykuroda | 0:13a5d365ba16 | 41 | int(MatrixType::RowsAtCompileTime) + 1 : Dynamic, |
ykuroda | 0:13a5d365ba16 | 42 | ColsPlusOne = (MatrixType::ColsAtCompileTime != Dynamic) ? |
ykuroda | 0:13a5d365ba16 | 43 | int(MatrixType::ColsAtCompileTime) + 1 : Dynamic, |
ykuroda | 0:13a5d365ba16 | 44 | RowsAtCompileTime = Direction==Vertical ? RowsPlusOne : MatrixType::RowsAtCompileTime, |
ykuroda | 0:13a5d365ba16 | 45 | ColsAtCompileTime = Direction==Horizontal ? ColsPlusOne : MatrixType::ColsAtCompileTime, |
ykuroda | 0:13a5d365ba16 | 46 | MaxRowsAtCompileTime = RowsAtCompileTime, |
ykuroda | 0:13a5d365ba16 | 47 | MaxColsAtCompileTime = ColsAtCompileTime, |
ykuroda | 0:13a5d365ba16 | 48 | TmpFlags = _MatrixTypeNested::Flags & HereditaryBits, |
ykuroda | 0:13a5d365ba16 | 49 | Flags = ColsAtCompileTime==1 ? (TmpFlags & ~RowMajorBit) |
ykuroda | 0:13a5d365ba16 | 50 | : RowsAtCompileTime==1 ? (TmpFlags | RowMajorBit) |
ykuroda | 0:13a5d365ba16 | 51 | : TmpFlags, |
ykuroda | 0:13a5d365ba16 | 52 | CoeffReadCost = _MatrixTypeNested::CoeffReadCost |
ykuroda | 0:13a5d365ba16 | 53 | }; |
ykuroda | 0:13a5d365ba16 | 54 | }; |
ykuroda | 0:13a5d365ba16 | 55 | |
ykuroda | 0:13a5d365ba16 | 56 | template<typename MatrixType,typename Lhs> struct homogeneous_left_product_impl; |
ykuroda | 0:13a5d365ba16 | 57 | template<typename MatrixType,typename Rhs> struct homogeneous_right_product_impl; |
ykuroda | 0:13a5d365ba16 | 58 | |
ykuroda | 0:13a5d365ba16 | 59 | } // end namespace internal |
ykuroda | 0:13a5d365ba16 | 60 | |
ykuroda | 0:13a5d365ba16 | 61 | template<typename MatrixType,int _Direction> class Homogeneous |
ykuroda | 0:13a5d365ba16 | 62 | : internal::no_assignment_operator, public MatrixBase<Homogeneous<MatrixType,_Direction> > |
ykuroda | 0:13a5d365ba16 | 63 | { |
ykuroda | 0:13a5d365ba16 | 64 | public: |
ykuroda | 0:13a5d365ba16 | 65 | |
ykuroda | 0:13a5d365ba16 | 66 | enum { Direction = _Direction }; |
ykuroda | 0:13a5d365ba16 | 67 | |
ykuroda | 0:13a5d365ba16 | 68 | typedef MatrixBase<Homogeneous> Base; |
ykuroda | 0:13a5d365ba16 | 69 | EIGEN_DENSE_PUBLIC_INTERFACE(Homogeneous) |
ykuroda | 0:13a5d365ba16 | 70 | |
ykuroda | 0:13a5d365ba16 | 71 | inline Homogeneous(const MatrixType& matrix) |
ykuroda | 0:13a5d365ba16 | 72 | : m_matrix(matrix) |
ykuroda | 0:13a5d365ba16 | 73 | {} |
ykuroda | 0:13a5d365ba16 | 74 | |
ykuroda | 0:13a5d365ba16 | 75 | inline Index rows() const { return m_matrix.rows() + (int(Direction)==Vertical ? 1 : 0); } |
ykuroda | 0:13a5d365ba16 | 76 | inline Index cols() const { return m_matrix.cols() + (int(Direction)==Horizontal ? 1 : 0); } |
ykuroda | 0:13a5d365ba16 | 77 | |
ykuroda | 0:13a5d365ba16 | 78 | inline Scalar coeff(Index row, Index col) const |
ykuroda | 0:13a5d365ba16 | 79 | { |
ykuroda | 0:13a5d365ba16 | 80 | if( (int(Direction)==Vertical && row==m_matrix.rows()) |
ykuroda | 0:13a5d365ba16 | 81 | || (int(Direction)==Horizontal && col==m_matrix.cols())) |
ykuroda | 0:13a5d365ba16 | 82 | return Scalar(1); |
ykuroda | 0:13a5d365ba16 | 83 | return m_matrix.coeff(row, col); |
ykuroda | 0:13a5d365ba16 | 84 | } |
ykuroda | 0:13a5d365ba16 | 85 | |
ykuroda | 0:13a5d365ba16 | 86 | template<typename Rhs> |
ykuroda | 0:13a5d365ba16 | 87 | inline const internal::homogeneous_right_product_impl<Homogeneous,Rhs> |
ykuroda | 0:13a5d365ba16 | 88 | operator* (const MatrixBase<Rhs>& rhs) const |
ykuroda | 0:13a5d365ba16 | 89 | { |
ykuroda | 0:13a5d365ba16 | 90 | eigen_assert(int(Direction)==Horizontal); |
ykuroda | 0:13a5d365ba16 | 91 | return internal::homogeneous_right_product_impl<Homogeneous,Rhs>(m_matrix,rhs.derived()); |
ykuroda | 0:13a5d365ba16 | 92 | } |
ykuroda | 0:13a5d365ba16 | 93 | |
ykuroda | 0:13a5d365ba16 | 94 | template<typename Lhs> friend |
ykuroda | 0:13a5d365ba16 | 95 | inline const internal::homogeneous_left_product_impl<Homogeneous,Lhs> |
ykuroda | 0:13a5d365ba16 | 96 | operator* (const MatrixBase<Lhs>& lhs, const Homogeneous& rhs) |
ykuroda | 0:13a5d365ba16 | 97 | { |
ykuroda | 0:13a5d365ba16 | 98 | eigen_assert(int(Direction)==Vertical); |
ykuroda | 0:13a5d365ba16 | 99 | return internal::homogeneous_left_product_impl<Homogeneous,Lhs>(lhs.derived(),rhs.m_matrix); |
ykuroda | 0:13a5d365ba16 | 100 | } |
ykuroda | 0:13a5d365ba16 | 101 | |
ykuroda | 0:13a5d365ba16 | 102 | template<typename Scalar, int Dim, int Mode, int Options> friend |
ykuroda | 0:13a5d365ba16 | 103 | inline const internal::homogeneous_left_product_impl<Homogeneous,Transform<Scalar,Dim,Mode,Options> > |
ykuroda | 0:13a5d365ba16 | 104 | operator* (const Transform<Scalar,Dim,Mode,Options>& lhs, const Homogeneous& rhs) |
ykuroda | 0:13a5d365ba16 | 105 | { |
ykuroda | 0:13a5d365ba16 | 106 | eigen_assert(int(Direction)==Vertical); |
ykuroda | 0:13a5d365ba16 | 107 | return internal::homogeneous_left_product_impl<Homogeneous,Transform<Scalar,Dim,Mode,Options> >(lhs,rhs.m_matrix); |
ykuroda | 0:13a5d365ba16 | 108 | } |
ykuroda | 0:13a5d365ba16 | 109 | |
ykuroda | 0:13a5d365ba16 | 110 | protected: |
ykuroda | 0:13a5d365ba16 | 111 | typename MatrixType::Nested m_matrix; |
ykuroda | 0:13a5d365ba16 | 112 | }; |
ykuroda | 0:13a5d365ba16 | 113 | |
ykuroda | 0:13a5d365ba16 | 114 | /** \geometry_module |
ykuroda | 0:13a5d365ba16 | 115 | * |
ykuroda | 0:13a5d365ba16 | 116 | * \return an expression of the equivalent homogeneous vector |
ykuroda | 0:13a5d365ba16 | 117 | * |
ykuroda | 0:13a5d365ba16 | 118 | * \only_for_vectors |
ykuroda | 0:13a5d365ba16 | 119 | * |
ykuroda | 0:13a5d365ba16 | 120 | * Example: \include MatrixBase_homogeneous.cpp |
ykuroda | 0:13a5d365ba16 | 121 | * Output: \verbinclude MatrixBase_homogeneous.out |
ykuroda | 0:13a5d365ba16 | 122 | * |
ykuroda | 0:13a5d365ba16 | 123 | * \sa class Homogeneous |
ykuroda | 0:13a5d365ba16 | 124 | */ |
ykuroda | 0:13a5d365ba16 | 125 | template<typename Derived> |
ykuroda | 0:13a5d365ba16 | 126 | inline typename MatrixBase<Derived>::HomogeneousReturnType |
ykuroda | 0:13a5d365ba16 | 127 | MatrixBase<Derived>::homogeneous() const |
ykuroda | 0:13a5d365ba16 | 128 | { |
ykuroda | 0:13a5d365ba16 | 129 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived); |
ykuroda | 0:13a5d365ba16 | 130 | return derived(); |
ykuroda | 0:13a5d365ba16 | 131 | } |
ykuroda | 0:13a5d365ba16 | 132 | |
ykuroda | 0:13a5d365ba16 | 133 | /** \geometry_module |
ykuroda | 0:13a5d365ba16 | 134 | * |
ykuroda | 0:13a5d365ba16 | 135 | * \returns a matrix expression of homogeneous column (or row) vectors |
ykuroda | 0:13a5d365ba16 | 136 | * |
ykuroda | 0:13a5d365ba16 | 137 | * Example: \include VectorwiseOp_homogeneous.cpp |
ykuroda | 0:13a5d365ba16 | 138 | * Output: \verbinclude VectorwiseOp_homogeneous.out |
ykuroda | 0:13a5d365ba16 | 139 | * |
ykuroda | 0:13a5d365ba16 | 140 | * \sa MatrixBase::homogeneous() */ |
ykuroda | 0:13a5d365ba16 | 141 | template<typename ExpressionType, int Direction> |
ykuroda | 0:13a5d365ba16 | 142 | inline Homogeneous<ExpressionType,Direction> |
ykuroda | 0:13a5d365ba16 | 143 | VectorwiseOp<ExpressionType,Direction>::homogeneous() const |
ykuroda | 0:13a5d365ba16 | 144 | { |
ykuroda | 0:13a5d365ba16 | 145 | return _expression(); |
ykuroda | 0:13a5d365ba16 | 146 | } |
ykuroda | 0:13a5d365ba16 | 147 | |
ykuroda | 0:13a5d365ba16 | 148 | /** \geometry_module |
ykuroda | 0:13a5d365ba16 | 149 | * |
ykuroda | 0:13a5d365ba16 | 150 | * \returns an expression of the homogeneous normalized vector of \c *this |
ykuroda | 0:13a5d365ba16 | 151 | * |
ykuroda | 0:13a5d365ba16 | 152 | * Example: \include MatrixBase_hnormalized.cpp |
ykuroda | 0:13a5d365ba16 | 153 | * Output: \verbinclude MatrixBase_hnormalized.out |
ykuroda | 0:13a5d365ba16 | 154 | * |
ykuroda | 0:13a5d365ba16 | 155 | * \sa VectorwiseOp::hnormalized() */ |
ykuroda | 0:13a5d365ba16 | 156 | template<typename Derived> |
ykuroda | 0:13a5d365ba16 | 157 | inline const typename MatrixBase<Derived>::HNormalizedReturnType |
ykuroda | 0:13a5d365ba16 | 158 | MatrixBase<Derived>::hnormalized() const |
ykuroda | 0:13a5d365ba16 | 159 | { |
ykuroda | 0:13a5d365ba16 | 160 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived); |
ykuroda | 0:13a5d365ba16 | 161 | return ConstStartMinusOne(derived(),0,0, |
ykuroda | 0:13a5d365ba16 | 162 | ColsAtCompileTime==1?size()-1:1, |
ykuroda | 0:13a5d365ba16 | 163 | ColsAtCompileTime==1?1:size()-1) / coeff(size()-1); |
ykuroda | 0:13a5d365ba16 | 164 | } |
ykuroda | 0:13a5d365ba16 | 165 | |
ykuroda | 0:13a5d365ba16 | 166 | /** \geometry_module |
ykuroda | 0:13a5d365ba16 | 167 | * |
ykuroda | 0:13a5d365ba16 | 168 | * \returns an expression of the homogeneous normalized vector of \c *this |
ykuroda | 0:13a5d365ba16 | 169 | * |
ykuroda | 0:13a5d365ba16 | 170 | * Example: \include DirectionWise_hnormalized.cpp |
ykuroda | 0:13a5d365ba16 | 171 | * Output: \verbinclude DirectionWise_hnormalized.out |
ykuroda | 0:13a5d365ba16 | 172 | * |
ykuroda | 0:13a5d365ba16 | 173 | * \sa MatrixBase::hnormalized() */ |
ykuroda | 0:13a5d365ba16 | 174 | template<typename ExpressionType, int Direction> |
ykuroda | 0:13a5d365ba16 | 175 | inline const typename VectorwiseOp<ExpressionType,Direction>::HNormalizedReturnType |
ykuroda | 0:13a5d365ba16 | 176 | VectorwiseOp<ExpressionType,Direction>::hnormalized() const |
ykuroda | 0:13a5d365ba16 | 177 | { |
ykuroda | 0:13a5d365ba16 | 178 | return HNormalized_Block(_expression(),0,0, |
ykuroda | 0:13a5d365ba16 | 179 | Direction==Vertical ? _expression().rows()-1 : _expression().rows(), |
ykuroda | 0:13a5d365ba16 | 180 | Direction==Horizontal ? _expression().cols()-1 : _expression().cols()).cwiseQuotient( |
ykuroda | 0:13a5d365ba16 | 181 | Replicate<HNormalized_Factors, |
ykuroda | 0:13a5d365ba16 | 182 | Direction==Vertical ? HNormalized_SizeMinusOne : 1, |
ykuroda | 0:13a5d365ba16 | 183 | Direction==Horizontal ? HNormalized_SizeMinusOne : 1> |
ykuroda | 0:13a5d365ba16 | 184 | (HNormalized_Factors(_expression(), |
ykuroda | 0:13a5d365ba16 | 185 | Direction==Vertical ? _expression().rows()-1:0, |
ykuroda | 0:13a5d365ba16 | 186 | Direction==Horizontal ? _expression().cols()-1:0, |
ykuroda | 0:13a5d365ba16 | 187 | Direction==Vertical ? 1 : _expression().rows(), |
ykuroda | 0:13a5d365ba16 | 188 | Direction==Horizontal ? 1 : _expression().cols()), |
ykuroda | 0:13a5d365ba16 | 189 | Direction==Vertical ? _expression().rows()-1 : 1, |
ykuroda | 0:13a5d365ba16 | 190 | Direction==Horizontal ? _expression().cols()-1 : 1)); |
ykuroda | 0:13a5d365ba16 | 191 | } |
ykuroda | 0:13a5d365ba16 | 192 | |
ykuroda | 0:13a5d365ba16 | 193 | namespace internal { |
ykuroda | 0:13a5d365ba16 | 194 | |
ykuroda | 0:13a5d365ba16 | 195 | template<typename MatrixOrTransformType> |
ykuroda | 0:13a5d365ba16 | 196 | struct take_matrix_for_product |
ykuroda | 0:13a5d365ba16 | 197 | { |
ykuroda | 0:13a5d365ba16 | 198 | typedef MatrixOrTransformType type; |
ykuroda | 0:13a5d365ba16 | 199 | static const type& run(const type &x) { return x; } |
ykuroda | 0:13a5d365ba16 | 200 | }; |
ykuroda | 0:13a5d365ba16 | 201 | |
ykuroda | 0:13a5d365ba16 | 202 | template<typename Scalar, int Dim, int Mode,int Options> |
ykuroda | 0:13a5d365ba16 | 203 | struct take_matrix_for_product<Transform<Scalar, Dim, Mode, Options> > |
ykuroda | 0:13a5d365ba16 | 204 | { |
ykuroda | 0:13a5d365ba16 | 205 | typedef Transform<Scalar, Dim, Mode, Options> TransformType; |
ykuroda | 0:13a5d365ba16 | 206 | typedef typename internal::add_const<typename TransformType::ConstAffinePart>::type type; |
ykuroda | 0:13a5d365ba16 | 207 | static type run (const TransformType& x) { return x.affine(); } |
ykuroda | 0:13a5d365ba16 | 208 | }; |
ykuroda | 0:13a5d365ba16 | 209 | |
ykuroda | 0:13a5d365ba16 | 210 | template<typename Scalar, int Dim, int Options> |
ykuroda | 0:13a5d365ba16 | 211 | struct take_matrix_for_product<Transform<Scalar, Dim, Projective, Options> > |
ykuroda | 0:13a5d365ba16 | 212 | { |
ykuroda | 0:13a5d365ba16 | 213 | typedef Transform<Scalar, Dim, Projective, Options> TransformType; |
ykuroda | 0:13a5d365ba16 | 214 | typedef typename TransformType::MatrixType type; |
ykuroda | 0:13a5d365ba16 | 215 | static const type& run (const TransformType& x) { return x.matrix(); } |
ykuroda | 0:13a5d365ba16 | 216 | }; |
ykuroda | 0:13a5d365ba16 | 217 | |
ykuroda | 0:13a5d365ba16 | 218 | template<typename MatrixType,typename Lhs> |
ykuroda | 0:13a5d365ba16 | 219 | struct traits<homogeneous_left_product_impl<Homogeneous<MatrixType,Vertical>,Lhs> > |
ykuroda | 0:13a5d365ba16 | 220 | { |
ykuroda | 0:13a5d365ba16 | 221 | typedef typename take_matrix_for_product<Lhs>::type LhsMatrixType; |
ykuroda | 0:13a5d365ba16 | 222 | typedef typename remove_all<MatrixType>::type MatrixTypeCleaned; |
ykuroda | 0:13a5d365ba16 | 223 | typedef typename remove_all<LhsMatrixType>::type LhsMatrixTypeCleaned; |
ykuroda | 0:13a5d365ba16 | 224 | typedef typename make_proper_matrix_type< |
ykuroda | 0:13a5d365ba16 | 225 | typename traits<MatrixTypeCleaned>::Scalar, |
ykuroda | 0:13a5d365ba16 | 226 | LhsMatrixTypeCleaned::RowsAtCompileTime, |
ykuroda | 0:13a5d365ba16 | 227 | MatrixTypeCleaned::ColsAtCompileTime, |
ykuroda | 0:13a5d365ba16 | 228 | MatrixTypeCleaned::PlainObject::Options, |
ykuroda | 0:13a5d365ba16 | 229 | LhsMatrixTypeCleaned::MaxRowsAtCompileTime, |
ykuroda | 0:13a5d365ba16 | 230 | MatrixTypeCleaned::MaxColsAtCompileTime>::type ReturnType; |
ykuroda | 0:13a5d365ba16 | 231 | }; |
ykuroda | 0:13a5d365ba16 | 232 | |
ykuroda | 0:13a5d365ba16 | 233 | template<typename MatrixType,typename Lhs> |
ykuroda | 0:13a5d365ba16 | 234 | struct homogeneous_left_product_impl<Homogeneous<MatrixType,Vertical>,Lhs> |
ykuroda | 0:13a5d365ba16 | 235 | : public ReturnByValue<homogeneous_left_product_impl<Homogeneous<MatrixType,Vertical>,Lhs> > |
ykuroda | 0:13a5d365ba16 | 236 | { |
ykuroda | 0:13a5d365ba16 | 237 | typedef typename traits<homogeneous_left_product_impl>::LhsMatrixType LhsMatrixType; |
ykuroda | 0:13a5d365ba16 | 238 | typedef typename remove_all<LhsMatrixType>::type LhsMatrixTypeCleaned; |
ykuroda | 0:13a5d365ba16 | 239 | typedef typename remove_all<typename LhsMatrixTypeCleaned::Nested>::type LhsMatrixTypeNested; |
ykuroda | 0:13a5d365ba16 | 240 | typedef typename MatrixType::Index Index; |
ykuroda | 0:13a5d365ba16 | 241 | homogeneous_left_product_impl(const Lhs& lhs, const MatrixType& rhs) |
ykuroda | 0:13a5d365ba16 | 242 | : m_lhs(take_matrix_for_product<Lhs>::run(lhs)), |
ykuroda | 0:13a5d365ba16 | 243 | m_rhs(rhs) |
ykuroda | 0:13a5d365ba16 | 244 | {} |
ykuroda | 0:13a5d365ba16 | 245 | |
ykuroda | 0:13a5d365ba16 | 246 | inline Index rows() const { return m_lhs.rows(); } |
ykuroda | 0:13a5d365ba16 | 247 | inline Index cols() const { return m_rhs.cols(); } |
ykuroda | 0:13a5d365ba16 | 248 | |
ykuroda | 0:13a5d365ba16 | 249 | template<typename Dest> void evalTo(Dest& dst) const |
ykuroda | 0:13a5d365ba16 | 250 | { |
ykuroda | 0:13a5d365ba16 | 251 | // FIXME investigate how to allow lazy evaluation of this product when possible |
ykuroda | 0:13a5d365ba16 | 252 | dst = Block<const LhsMatrixTypeNested, |
ykuroda | 0:13a5d365ba16 | 253 | LhsMatrixTypeNested::RowsAtCompileTime, |
ykuroda | 0:13a5d365ba16 | 254 | LhsMatrixTypeNested::ColsAtCompileTime==Dynamic?Dynamic:LhsMatrixTypeNested::ColsAtCompileTime-1> |
ykuroda | 0:13a5d365ba16 | 255 | (m_lhs,0,0,m_lhs.rows(),m_lhs.cols()-1) * m_rhs; |
ykuroda | 0:13a5d365ba16 | 256 | dst += m_lhs.col(m_lhs.cols()-1).rowwise() |
ykuroda | 0:13a5d365ba16 | 257 | .template replicate<MatrixType::ColsAtCompileTime>(m_rhs.cols()); |
ykuroda | 0:13a5d365ba16 | 258 | } |
ykuroda | 0:13a5d365ba16 | 259 | |
ykuroda | 0:13a5d365ba16 | 260 | typename LhsMatrixTypeCleaned::Nested m_lhs; |
ykuroda | 0:13a5d365ba16 | 261 | typename MatrixType::Nested m_rhs; |
ykuroda | 0:13a5d365ba16 | 262 | }; |
ykuroda | 0:13a5d365ba16 | 263 | |
ykuroda | 0:13a5d365ba16 | 264 | template<typename MatrixType,typename Rhs> |
ykuroda | 0:13a5d365ba16 | 265 | struct traits<homogeneous_right_product_impl<Homogeneous<MatrixType,Horizontal>,Rhs> > |
ykuroda | 0:13a5d365ba16 | 266 | { |
ykuroda | 0:13a5d365ba16 | 267 | typedef typename make_proper_matrix_type<typename traits<MatrixType>::Scalar, |
ykuroda | 0:13a5d365ba16 | 268 | MatrixType::RowsAtCompileTime, |
ykuroda | 0:13a5d365ba16 | 269 | Rhs::ColsAtCompileTime, |
ykuroda | 0:13a5d365ba16 | 270 | MatrixType::PlainObject::Options, |
ykuroda | 0:13a5d365ba16 | 271 | MatrixType::MaxRowsAtCompileTime, |
ykuroda | 0:13a5d365ba16 | 272 | Rhs::MaxColsAtCompileTime>::type ReturnType; |
ykuroda | 0:13a5d365ba16 | 273 | }; |
ykuroda | 0:13a5d365ba16 | 274 | |
ykuroda | 0:13a5d365ba16 | 275 | template<typename MatrixType,typename Rhs> |
ykuroda | 0:13a5d365ba16 | 276 | struct homogeneous_right_product_impl<Homogeneous<MatrixType,Horizontal>,Rhs> |
ykuroda | 0:13a5d365ba16 | 277 | : public ReturnByValue<homogeneous_right_product_impl<Homogeneous<MatrixType,Horizontal>,Rhs> > |
ykuroda | 0:13a5d365ba16 | 278 | { |
ykuroda | 0:13a5d365ba16 | 279 | typedef typename remove_all<typename Rhs::Nested>::type RhsNested; |
ykuroda | 0:13a5d365ba16 | 280 | typedef typename MatrixType::Index Index; |
ykuroda | 0:13a5d365ba16 | 281 | homogeneous_right_product_impl(const MatrixType& lhs, const Rhs& rhs) |
ykuroda | 0:13a5d365ba16 | 282 | : m_lhs(lhs), m_rhs(rhs) |
ykuroda | 0:13a5d365ba16 | 283 | {} |
ykuroda | 0:13a5d365ba16 | 284 | |
ykuroda | 0:13a5d365ba16 | 285 | inline Index rows() const { return m_lhs.rows(); } |
ykuroda | 0:13a5d365ba16 | 286 | inline Index cols() const { return m_rhs.cols(); } |
ykuroda | 0:13a5d365ba16 | 287 | |
ykuroda | 0:13a5d365ba16 | 288 | template<typename Dest> void evalTo(Dest& dst) const |
ykuroda | 0:13a5d365ba16 | 289 | { |
ykuroda | 0:13a5d365ba16 | 290 | // FIXME investigate how to allow lazy evaluation of this product when possible |
ykuroda | 0:13a5d365ba16 | 291 | dst = m_lhs * Block<const RhsNested, |
ykuroda | 0:13a5d365ba16 | 292 | RhsNested::RowsAtCompileTime==Dynamic?Dynamic:RhsNested::RowsAtCompileTime-1, |
ykuroda | 0:13a5d365ba16 | 293 | RhsNested::ColsAtCompileTime> |
ykuroda | 0:13a5d365ba16 | 294 | (m_rhs,0,0,m_rhs.rows()-1,m_rhs.cols()); |
ykuroda | 0:13a5d365ba16 | 295 | dst += m_rhs.row(m_rhs.rows()-1).colwise() |
ykuroda | 0:13a5d365ba16 | 296 | .template replicate<MatrixType::RowsAtCompileTime>(m_lhs.rows()); |
ykuroda | 0:13a5d365ba16 | 297 | } |
ykuroda | 0:13a5d365ba16 | 298 | |
ykuroda | 0:13a5d365ba16 | 299 | typename MatrixType::Nested m_lhs; |
ykuroda | 0:13a5d365ba16 | 300 | typename Rhs::Nested m_rhs; |
ykuroda | 0:13a5d365ba16 | 301 | }; |
ykuroda | 0:13a5d365ba16 | 302 | |
ykuroda | 0:13a5d365ba16 | 303 | } // end namespace internal |
ykuroda | 0:13a5d365ba16 | 304 | |
ykuroda | 0:13a5d365ba16 | 305 | } // end namespace Eigen |
ykuroda | 0:13a5d365ba16 | 306 | |
ykuroda | 0:13a5d365ba16 | 307 | #endif // EIGEN_HOMOGENEOUS_H |