Eigne Matrix Class Library

Dependents:   MPC_current_control HydraulicControlBoard_SW AHRS Test_ekf ... more

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?

UserRevisionLine numberNew 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-2009 Gael Guennebaud <gael.guennebaud@inria.fr>
ykuroda 0:13a5d365ba16 5 // Copyright (C) 2006-2008 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 // This file is a base class plugin containing common coefficient wise functions.
ykuroda 0:13a5d365ba16 12
ykuroda 0:13a5d365ba16 13 #ifndef EIGEN_PARSED_BY_DOXYGEN
ykuroda 0:13a5d365ba16 14
ykuroda 0:13a5d365ba16 15 /** \internal Represents a scalar multiple of an expression */
ykuroda 0:13a5d365ba16 16 typedef CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, const Derived> ScalarMultipleReturnType;
ykuroda 0:13a5d365ba16 17 /** \internal Represents a quotient of an expression by a scalar*/
ykuroda 0:13a5d365ba16 18 typedef CwiseUnaryOp<internal::scalar_quotient1_op<Scalar>, const Derived> ScalarQuotient1ReturnType;
ykuroda 0:13a5d365ba16 19 /** \internal the return type of conjugate() */
ykuroda 0:13a5d365ba16 20 typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
ykuroda 0:13a5d365ba16 21 const CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>, const Derived>,
ykuroda 0:13a5d365ba16 22 const Derived&
ykuroda 0:13a5d365ba16 23 >::type ConjugateReturnType;
ykuroda 0:13a5d365ba16 24 /** \internal the return type of real() const */
ykuroda 0:13a5d365ba16 25 typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
ykuroda 0:13a5d365ba16 26 const CwiseUnaryOp<internal::scalar_real_op<Scalar>, const Derived>,
ykuroda 0:13a5d365ba16 27 const Derived&
ykuroda 0:13a5d365ba16 28 >::type RealReturnType;
ykuroda 0:13a5d365ba16 29 /** \internal the return type of real() */
ykuroda 0:13a5d365ba16 30 typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
ykuroda 0:13a5d365ba16 31 CwiseUnaryView<internal::scalar_real_ref_op<Scalar>, Derived>,
ykuroda 0:13a5d365ba16 32 Derived&
ykuroda 0:13a5d365ba16 33 >::type NonConstRealReturnType;
ykuroda 0:13a5d365ba16 34 /** \internal the return type of imag() const */
ykuroda 0:13a5d365ba16 35 typedef CwiseUnaryOp<internal::scalar_imag_op<Scalar>, const Derived> ImagReturnType;
ykuroda 0:13a5d365ba16 36 /** \internal the return type of imag() */
ykuroda 0:13a5d365ba16 37 typedef CwiseUnaryView<internal::scalar_imag_ref_op<Scalar>, Derived> NonConstImagReturnType;
ykuroda 0:13a5d365ba16 38
ykuroda 0:13a5d365ba16 39 #endif // not EIGEN_PARSED_BY_DOXYGEN
ykuroda 0:13a5d365ba16 40
ykuroda 0:13a5d365ba16 41 /** \returns an expression of the opposite of \c *this
ykuroda 0:13a5d365ba16 42 */
ykuroda 0:13a5d365ba16 43 inline const CwiseUnaryOp<internal::scalar_opposite_op<typename internal::traits<Derived>::Scalar>, const Derived>
ykuroda 0:13a5d365ba16 44 operator-() const { return derived(); }
ykuroda 0:13a5d365ba16 45
ykuroda 0:13a5d365ba16 46
ykuroda 0:13a5d365ba16 47 /** \returns an expression of \c *this scaled by the scalar factor \a scalar */
ykuroda 0:13a5d365ba16 48 inline const ScalarMultipleReturnType
ykuroda 0:13a5d365ba16 49 operator*(const Scalar& scalar) const
ykuroda 0:13a5d365ba16 50 {
ykuroda 0:13a5d365ba16 51 return CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, const Derived>
ykuroda 0:13a5d365ba16 52 (derived(), internal::scalar_multiple_op<Scalar>(scalar));
ykuroda 0:13a5d365ba16 53 }
ykuroda 0:13a5d365ba16 54
ykuroda 0:13a5d365ba16 55 #ifdef EIGEN_PARSED_BY_DOXYGEN
ykuroda 0:13a5d365ba16 56 const ScalarMultipleReturnType operator*(const RealScalar& scalar) const;
ykuroda 0:13a5d365ba16 57 #endif
ykuroda 0:13a5d365ba16 58
ykuroda 0:13a5d365ba16 59 /** \returns an expression of \c *this divided by the scalar value \a scalar */
ykuroda 0:13a5d365ba16 60 inline const CwiseUnaryOp<internal::scalar_quotient1_op<typename internal::traits<Derived>::Scalar>, const Derived>
ykuroda 0:13a5d365ba16 61 operator/(const Scalar& scalar) const
ykuroda 0:13a5d365ba16 62 {
ykuroda 0:13a5d365ba16 63 return CwiseUnaryOp<internal::scalar_quotient1_op<Scalar>, const Derived>
ykuroda 0:13a5d365ba16 64 (derived(), internal::scalar_quotient1_op<Scalar>(scalar));
ykuroda 0:13a5d365ba16 65 }
ykuroda 0:13a5d365ba16 66
ykuroda 0:13a5d365ba16 67 /** Overloaded for efficient real matrix times complex scalar value */
ykuroda 0:13a5d365ba16 68 inline const CwiseUnaryOp<internal::scalar_multiple2_op<Scalar,std::complex<Scalar> >, const Derived>
ykuroda 0:13a5d365ba16 69 operator*(const std::complex<Scalar>& scalar) const
ykuroda 0:13a5d365ba16 70 {
ykuroda 0:13a5d365ba16 71 return CwiseUnaryOp<internal::scalar_multiple2_op<Scalar,std::complex<Scalar> >, const Derived>
ykuroda 0:13a5d365ba16 72 (*static_cast<const Derived*>(this), internal::scalar_multiple2_op<Scalar,std::complex<Scalar> >(scalar));
ykuroda 0:13a5d365ba16 73 }
ykuroda 0:13a5d365ba16 74
ykuroda 0:13a5d365ba16 75 inline friend const ScalarMultipleReturnType
ykuroda 0:13a5d365ba16 76 operator*(const Scalar& scalar, const StorageBaseType& matrix)
ykuroda 0:13a5d365ba16 77 { return matrix*scalar; }
ykuroda 0:13a5d365ba16 78
ykuroda 0:13a5d365ba16 79 inline friend const CwiseUnaryOp<internal::scalar_multiple2_op<Scalar,std::complex<Scalar> >, const Derived>
ykuroda 0:13a5d365ba16 80 operator*(const std::complex<Scalar>& scalar, const StorageBaseType& matrix)
ykuroda 0:13a5d365ba16 81 { return matrix*scalar; }
ykuroda 0:13a5d365ba16 82
ykuroda 0:13a5d365ba16 83 /** \returns an expression of *this with the \a Scalar type casted to
ykuroda 0:13a5d365ba16 84 * \a NewScalar.
ykuroda 0:13a5d365ba16 85 *
ykuroda 0:13a5d365ba16 86 * The template parameter \a NewScalar is the type we are casting the scalars to.
ykuroda 0:13a5d365ba16 87 *
ykuroda 0:13a5d365ba16 88 * \sa class CwiseUnaryOp
ykuroda 0:13a5d365ba16 89 */
ykuroda 0:13a5d365ba16 90 template<typename NewType>
ykuroda 0:13a5d365ba16 91 typename internal::cast_return_type<Derived,const CwiseUnaryOp<internal::scalar_cast_op<typename internal::traits<Derived>::Scalar, NewType>, const Derived> >::type
ykuroda 0:13a5d365ba16 92 cast() const
ykuroda 0:13a5d365ba16 93 {
ykuroda 0:13a5d365ba16 94 return derived();
ykuroda 0:13a5d365ba16 95 }
ykuroda 0:13a5d365ba16 96
ykuroda 0:13a5d365ba16 97 /** \returns an expression of the complex conjugate of \c *this.
ykuroda 0:13a5d365ba16 98 *
ykuroda 0:13a5d365ba16 99 * \sa adjoint() */
ykuroda 0:13a5d365ba16 100 inline ConjugateReturnType
ykuroda 0:13a5d365ba16 101 conjugate() const
ykuroda 0:13a5d365ba16 102 {
ykuroda 0:13a5d365ba16 103 return ConjugateReturnType(derived());
ykuroda 0:13a5d365ba16 104 }
ykuroda 0:13a5d365ba16 105
ykuroda 0:13a5d365ba16 106 /** \returns a read-only expression of the real part of \c *this.
ykuroda 0:13a5d365ba16 107 *
ykuroda 0:13a5d365ba16 108 * \sa imag() */
ykuroda 0:13a5d365ba16 109 inline RealReturnType
ykuroda 0:13a5d365ba16 110 real() const { return derived(); }
ykuroda 0:13a5d365ba16 111
ykuroda 0:13a5d365ba16 112 /** \returns an read-only expression of the imaginary part of \c *this.
ykuroda 0:13a5d365ba16 113 *
ykuroda 0:13a5d365ba16 114 * \sa real() */
ykuroda 0:13a5d365ba16 115 inline const ImagReturnType
ykuroda 0:13a5d365ba16 116 imag() const { return derived(); }
ykuroda 0:13a5d365ba16 117
ykuroda 0:13a5d365ba16 118 /** \brief Apply a unary operator coefficient-wise
ykuroda 0:13a5d365ba16 119 * \param[in] func Functor implementing the unary operator
ykuroda 0:13a5d365ba16 120 * \tparam CustomUnaryOp Type of \a func
ykuroda 0:13a5d365ba16 121 * \returns An expression of a custom coefficient-wise unary operator \a func of *this
ykuroda 0:13a5d365ba16 122 *
ykuroda 0:13a5d365ba16 123 * The function \c ptr_fun() from the C++ standard library can be used to make functors out of normal functions.
ykuroda 0:13a5d365ba16 124 *
ykuroda 0:13a5d365ba16 125 * Example:
ykuroda 0:13a5d365ba16 126 * \include class_CwiseUnaryOp_ptrfun.cpp
ykuroda 0:13a5d365ba16 127 * Output: \verbinclude class_CwiseUnaryOp_ptrfun.out
ykuroda 0:13a5d365ba16 128 *
ykuroda 0:13a5d365ba16 129 * Genuine functors allow for more possibilities, for instance it may contain a state.
ykuroda 0:13a5d365ba16 130 *
ykuroda 0:13a5d365ba16 131 * Example:
ykuroda 0:13a5d365ba16 132 * \include class_CwiseUnaryOp.cpp
ykuroda 0:13a5d365ba16 133 * Output: \verbinclude class_CwiseUnaryOp.out
ykuroda 0:13a5d365ba16 134 *
ykuroda 0:13a5d365ba16 135 * \sa class CwiseUnaryOp, class CwiseBinaryOp
ykuroda 0:13a5d365ba16 136 */
ykuroda 0:13a5d365ba16 137 template<typename CustomUnaryOp>
ykuroda 0:13a5d365ba16 138 inline const CwiseUnaryOp<CustomUnaryOp, const Derived>
ykuroda 0:13a5d365ba16 139 unaryExpr(const CustomUnaryOp& func = CustomUnaryOp()) const
ykuroda 0:13a5d365ba16 140 {
ykuroda 0:13a5d365ba16 141 return CwiseUnaryOp<CustomUnaryOp, const Derived>(derived(), func);
ykuroda 0:13a5d365ba16 142 }
ykuroda 0:13a5d365ba16 143
ykuroda 0:13a5d365ba16 144 /** \returns an expression of a custom coefficient-wise unary operator \a func of *this
ykuroda 0:13a5d365ba16 145 *
ykuroda 0:13a5d365ba16 146 * The template parameter \a CustomUnaryOp is the type of the functor
ykuroda 0:13a5d365ba16 147 * of the custom unary operator.
ykuroda 0:13a5d365ba16 148 *
ykuroda 0:13a5d365ba16 149 * Example:
ykuroda 0:13a5d365ba16 150 * \include class_CwiseUnaryOp.cpp
ykuroda 0:13a5d365ba16 151 * Output: \verbinclude class_CwiseUnaryOp.out
ykuroda 0:13a5d365ba16 152 *
ykuroda 0:13a5d365ba16 153 * \sa class CwiseUnaryOp, class CwiseBinaryOp
ykuroda 0:13a5d365ba16 154 */
ykuroda 0:13a5d365ba16 155 template<typename CustomViewOp>
ykuroda 0:13a5d365ba16 156 inline const CwiseUnaryView<CustomViewOp, const Derived>
ykuroda 0:13a5d365ba16 157 unaryViewExpr(const CustomViewOp& func = CustomViewOp()) const
ykuroda 0:13a5d365ba16 158 {
ykuroda 0:13a5d365ba16 159 return CwiseUnaryView<CustomViewOp, const Derived>(derived(), func);
ykuroda 0:13a5d365ba16 160 }
ykuroda 0:13a5d365ba16 161
ykuroda 0:13a5d365ba16 162 /** \returns a non const expression of the real part of \c *this.
ykuroda 0:13a5d365ba16 163 *
ykuroda 0:13a5d365ba16 164 * \sa imag() */
ykuroda 0:13a5d365ba16 165 inline NonConstRealReturnType
ykuroda 0:13a5d365ba16 166 real() { return derived(); }
ykuroda 0:13a5d365ba16 167
ykuroda 0:13a5d365ba16 168 /** \returns a non const expression of the imaginary part of \c *this.
ykuroda 0:13a5d365ba16 169 *
ykuroda 0:13a5d365ba16 170 * \sa real() */
ykuroda 0:13a5d365ba16 171 inline NonConstImagReturnType
ykuroda 0:13a5d365ba16 172 imag() { return derived(); }