Eigne Matrix Class Library
Dependents: Eigen_test Odometry_test AttitudeEstimation_usingTicker MPU9250_Quaternion_Binary_Serial ... more
Eigen Matrix Class Library for mbed.
Finally, you can use Eigen on your mbed!!!
src/Core/ReturnByValue.h@0:13a5d365ba16, 2016-10-13 (annotated)
- Committer:
- ykuroda
- Date:
- Thu Oct 13 04:07:23 2016 +0000
- Revision:
- 0:13a5d365ba16
First commint, Eigne Matrix Class Library
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 | // Copyright (C) 2009-2010 Benoit Jacob <jacob.benoit.1@gmail.com> |
ykuroda | 0:13a5d365ba16 | 6 | // |
ykuroda | 0:13a5d365ba16 | 7 | // This Source Code Form is subject to the terms of the Mozilla |
ykuroda | 0:13a5d365ba16 | 8 | // Public License v. 2.0. If a copy of the MPL was not distributed |
ykuroda | 0:13a5d365ba16 | 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. |
ykuroda | 0:13a5d365ba16 | 10 | |
ykuroda | 0:13a5d365ba16 | 11 | #ifndef EIGEN_RETURNBYVALUE_H |
ykuroda | 0:13a5d365ba16 | 12 | #define EIGEN_RETURNBYVALUE_H |
ykuroda | 0:13a5d365ba16 | 13 | |
ykuroda | 0:13a5d365ba16 | 14 | namespace Eigen { |
ykuroda | 0:13a5d365ba16 | 15 | |
ykuroda | 0:13a5d365ba16 | 16 | /** \class ReturnByValue |
ykuroda | 0:13a5d365ba16 | 17 | * \ingroup Core_Module |
ykuroda | 0:13a5d365ba16 | 18 | * |
ykuroda | 0:13a5d365ba16 | 19 | */ |
ykuroda | 0:13a5d365ba16 | 20 | |
ykuroda | 0:13a5d365ba16 | 21 | namespace internal { |
ykuroda | 0:13a5d365ba16 | 22 | |
ykuroda | 0:13a5d365ba16 | 23 | template<typename Derived> |
ykuroda | 0:13a5d365ba16 | 24 | struct traits<ReturnByValue<Derived> > |
ykuroda | 0:13a5d365ba16 | 25 | : public traits<typename traits<Derived>::ReturnType> |
ykuroda | 0:13a5d365ba16 | 26 | { |
ykuroda | 0:13a5d365ba16 | 27 | enum { |
ykuroda | 0:13a5d365ba16 | 28 | // We're disabling the DirectAccess because e.g. the constructor of |
ykuroda | 0:13a5d365ba16 | 29 | // the Block-with-DirectAccess expression requires to have a coeffRef method. |
ykuroda | 0:13a5d365ba16 | 30 | // Also, we don't want to have to implement the stride stuff. |
ykuroda | 0:13a5d365ba16 | 31 | Flags = (traits<typename traits<Derived>::ReturnType>::Flags |
ykuroda | 0:13a5d365ba16 | 32 | | EvalBeforeNestingBit) & ~DirectAccessBit |
ykuroda | 0:13a5d365ba16 | 33 | }; |
ykuroda | 0:13a5d365ba16 | 34 | }; |
ykuroda | 0:13a5d365ba16 | 35 | |
ykuroda | 0:13a5d365ba16 | 36 | /* The ReturnByValue object doesn't even have a coeff() method. |
ykuroda | 0:13a5d365ba16 | 37 | * So the only way that nesting it in an expression can work, is by evaluating it into a plain matrix. |
ykuroda | 0:13a5d365ba16 | 38 | * So internal::nested always gives the plain return matrix type. |
ykuroda | 0:13a5d365ba16 | 39 | * |
ykuroda | 0:13a5d365ba16 | 40 | * FIXME: I don't understand why we need this specialization: isn't this taken care of by the EvalBeforeNestingBit ?? |
ykuroda | 0:13a5d365ba16 | 41 | */ |
ykuroda | 0:13a5d365ba16 | 42 | template<typename Derived,int n,typename PlainObject> |
ykuroda | 0:13a5d365ba16 | 43 | struct nested<ReturnByValue<Derived>, n, PlainObject> |
ykuroda | 0:13a5d365ba16 | 44 | { |
ykuroda | 0:13a5d365ba16 | 45 | typedef typename traits<Derived>::ReturnType type; |
ykuroda | 0:13a5d365ba16 | 46 | }; |
ykuroda | 0:13a5d365ba16 | 47 | |
ykuroda | 0:13a5d365ba16 | 48 | } // end namespace internal |
ykuroda | 0:13a5d365ba16 | 49 | |
ykuroda | 0:13a5d365ba16 | 50 | template<typename Derived> class ReturnByValue |
ykuroda | 0:13a5d365ba16 | 51 | : internal::no_assignment_operator, public internal::dense_xpr_base< ReturnByValue<Derived> >::type |
ykuroda | 0:13a5d365ba16 | 52 | { |
ykuroda | 0:13a5d365ba16 | 53 | public: |
ykuroda | 0:13a5d365ba16 | 54 | typedef typename internal::traits<Derived>::ReturnType ReturnType; |
ykuroda | 0:13a5d365ba16 | 55 | |
ykuroda | 0:13a5d365ba16 | 56 | typedef typename internal::dense_xpr_base<ReturnByValue>::type Base; |
ykuroda | 0:13a5d365ba16 | 57 | EIGEN_DENSE_PUBLIC_INTERFACE(ReturnByValue) |
ykuroda | 0:13a5d365ba16 | 58 | |
ykuroda | 0:13a5d365ba16 | 59 | template<typename Dest> |
ykuroda | 0:13a5d365ba16 | 60 | inline void evalTo(Dest& dst) const |
ykuroda | 0:13a5d365ba16 | 61 | { static_cast<const Derived*>(this)->evalTo(dst); } |
ykuroda | 0:13a5d365ba16 | 62 | inline Index rows() const { return static_cast<const Derived*>(this)->rows(); } |
ykuroda | 0:13a5d365ba16 | 63 | inline Index cols() const { return static_cast<const Derived*>(this)->cols(); } |
ykuroda | 0:13a5d365ba16 | 64 | |
ykuroda | 0:13a5d365ba16 | 65 | #ifndef EIGEN_PARSED_BY_DOXYGEN |
ykuroda | 0:13a5d365ba16 | 66 | #define Unusable YOU_ARE_TRYING_TO_ACCESS_A_SINGLE_COEFFICIENT_IN_A_SPECIAL_EXPRESSION_WHERE_THAT_IS_NOT_ALLOWED_BECAUSE_THAT_WOULD_BE_INEFFICIENT |
ykuroda | 0:13a5d365ba16 | 67 | class Unusable{ |
ykuroda | 0:13a5d365ba16 | 68 | Unusable(const Unusable&) {} |
ykuroda | 0:13a5d365ba16 | 69 | Unusable& operator=(const Unusable&) {return *this;} |
ykuroda | 0:13a5d365ba16 | 70 | }; |
ykuroda | 0:13a5d365ba16 | 71 | const Unusable& coeff(Index) const { return *reinterpret_cast<const Unusable*>(this); } |
ykuroda | 0:13a5d365ba16 | 72 | const Unusable& coeff(Index,Index) const { return *reinterpret_cast<const Unusable*>(this); } |
ykuroda | 0:13a5d365ba16 | 73 | Unusable& coeffRef(Index) { return *reinterpret_cast<Unusable*>(this); } |
ykuroda | 0:13a5d365ba16 | 74 | Unusable& coeffRef(Index,Index) { return *reinterpret_cast<Unusable*>(this); } |
ykuroda | 0:13a5d365ba16 | 75 | template<int LoadMode> Unusable& packet(Index) const; |
ykuroda | 0:13a5d365ba16 | 76 | template<int LoadMode> Unusable& packet(Index, Index) const; |
ykuroda | 0:13a5d365ba16 | 77 | #endif |
ykuroda | 0:13a5d365ba16 | 78 | }; |
ykuroda | 0:13a5d365ba16 | 79 | |
ykuroda | 0:13a5d365ba16 | 80 | template<typename Derived> |
ykuroda | 0:13a5d365ba16 | 81 | template<typename OtherDerived> |
ykuroda | 0:13a5d365ba16 | 82 | Derived& DenseBase<Derived>::operator=(const ReturnByValue<OtherDerived>& other) |
ykuroda | 0:13a5d365ba16 | 83 | { |
ykuroda | 0:13a5d365ba16 | 84 | other.evalTo(derived()); |
ykuroda | 0:13a5d365ba16 | 85 | return derived(); |
ykuroda | 0:13a5d365ba16 | 86 | } |
ykuroda | 0:13a5d365ba16 | 87 | |
ykuroda | 0:13a5d365ba16 | 88 | template<typename Derived> |
ykuroda | 0:13a5d365ba16 | 89 | template<typename OtherDerived> |
ykuroda | 0:13a5d365ba16 | 90 | Derived& DenseBase<Derived>::lazyAssign(const ReturnByValue<OtherDerived>& other) |
ykuroda | 0:13a5d365ba16 | 91 | { |
ykuroda | 0:13a5d365ba16 | 92 | other.evalTo(derived()); |
ykuroda | 0:13a5d365ba16 | 93 | return derived(); |
ykuroda | 0:13a5d365ba16 | 94 | } |
ykuroda | 0:13a5d365ba16 | 95 | |
ykuroda | 0:13a5d365ba16 | 96 | |
ykuroda | 0:13a5d365ba16 | 97 | } // end namespace Eigen |
ykuroda | 0:13a5d365ba16 | 98 | |
ykuroda | 0:13a5d365ba16 | 99 | #endif // EIGEN_RETURNBYVALUE_H |