Matrix.h
Go to the documentation of this file.
00001 // This file is part of Eigen, a lightweight C++ template library
00002 // for linear algebra.
00003 //
00004 // Copyright (C) 2006-2010 Benoit Jacob <jacob.benoit.1@gmail.com>
00005 // Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>
00006 //
00007 // This Source Code Form is subject to the terms of the Mozilla
00008 // Public License v. 2.0. If a copy of the MPL was not distributed
00009 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
00010 
00011 #ifndef EIGEN_MATRIX_H
00012 #define EIGEN_MATRIX_H
00013 
00014 namespace Eigen {
00015 
00104 namespace internal {
00105 template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
00106 struct traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
00107 {
00108   typedef _Scalar Scalar;
00109   typedef Dense StorageKind;
00110   typedef DenseIndex Index;
00111   typedef MatrixXpr XprKind;
00112   enum {
00113     RowsAtCompileTime = _Rows,
00114     ColsAtCompileTime = _Cols,
00115     MaxRowsAtCompileTime = _MaxRows,
00116     MaxColsAtCompileTime = _MaxCols,
00117     Flags = compute_matrix_flags<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::ret,
00118     CoeffReadCost = NumTraits<Scalar>::ReadCost,
00119     Options = _Options,
00120     InnerStrideAtCompileTime = 1,
00121     OuterStrideAtCompileTime = (Options&RowMajor) ? ColsAtCompileTime : RowsAtCompileTime
00122   };
00123 };
00124 }
00125 
00126 template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
00127 class Matrix
00128   : public PlainObjectBase<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
00129 {
00130   public:
00131 
00135     typedef PlainObjectBase<Matrix> Base;
00136 
00137     enum { Options = _Options };
00138 
00139     EIGEN_DENSE_PUBLIC_INTERFACE(Matrix)
00140 
00141     typedef typename Base::PlainObject PlainObject;
00142 
00143     using Base::base;
00144     using Base::coeffRef;
00145 
00154     EIGEN_STRONG_INLINE Matrix& operator=(const Matrix& other)
00155     {
00156       return Base::_set(other);
00157     }
00158 
00169     template<typename OtherDerived>
00170     EIGEN_STRONG_INLINE Matrix& operator=(const MatrixBase<OtherDerived>& other)
00171     {
00172       return Base::_set(other);
00173     }
00174 
00175     /* Here, doxygen failed to copy the brief information when using \copydoc */
00176 
00181     template<typename OtherDerived>
00182     EIGEN_STRONG_INLINE Matrix& operator=(const EigenBase<OtherDerived> &other)
00183     {
00184       return Base::operator=(other);
00185     }
00186 
00187     template<typename OtherDerived>
00188     EIGEN_STRONG_INLINE Matrix& operator=(const ReturnByValue<OtherDerived>& func)
00189     {
00190       return Base::operator=(func);
00191     }
00192 
00203     EIGEN_STRONG_INLINE Matrix() : Base()
00204     {
00205       Base::_check_template_params();
00206       EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
00207     }
00208 
00209     // FIXME is it still needed
00210     Matrix(internal::constructor_without_unaligned_array_assert)
00211       : Base(internal::constructor_without_unaligned_array_assert())
00212     { Base::_check_template_params(); EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED }
00213 
00220     EIGEN_STRONG_INLINE explicit Matrix(Index dim)
00221       : Base(dim, RowsAtCompileTime == 1 ? 1 : dim, ColsAtCompileTime == 1 ? 1 : dim)
00222     {
00223       Base::_check_template_params();
00224       EIGEN_STATIC_ASSERT_VECTOR_ONLY(Matrix)
00225       eigen_assert(dim >= 0);
00226       eigen_assert(SizeAtCompileTime == Dynamic || SizeAtCompileTime == dim);
00227       EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
00228     }
00229 
00230     #ifndef EIGEN_PARSED_BY_DOXYGEN
00231     template<typename T0, typename T1>
00232     EIGEN_STRONG_INLINE Matrix(const T0& x, const T1& y)
00233     {
00234       Base::_check_template_params();
00235       Base::template _init2<T0,T1>(x, y);
00236     }
00237     #else
00238 
00243     Matrix(Index rows, Index cols);
00245     Matrix(const Scalar& x, const Scalar& y);
00246     #endif
00247 
00249     EIGEN_STRONG_INLINE Matrix(const Scalar& x, const Scalar& y, const Scalar& z)
00250     {
00251       Base::_check_template_params();
00252       EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Matrix, 3)
00253       m_storage.data()[0] = x;
00254       m_storage.data()[1] = y;
00255       m_storage.data()[2] = z;
00256     }
00258     EIGEN_STRONG_INLINE Matrix(const Scalar& x, const Scalar& y, const Scalar& z, const Scalar& w)
00259     {
00260       Base::_check_template_params();
00261       EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Matrix, 4)
00262       m_storage.data()[0] = x;
00263       m_storage.data()[1] = y;
00264       m_storage.data()[2] = z;
00265       m_storage.data()[3] = w;
00266     }
00267 
00268     explicit Matrix(const Scalar *data);
00269 
00271     template<typename OtherDerived>
00272     EIGEN_STRONG_INLINE Matrix(const MatrixBase<OtherDerived>& other)
00273              : Base(other.rows() * other.cols(), other.rows(), other.cols())
00274     {
00275       // This test resides here, to bring the error messages closer to the user. Normally, these checks
00276       // are performed deeply within the library, thus causing long and scary error traces.
00277       EIGEN_STATIC_ASSERT((internal::is_same<Scalar, typename OtherDerived::Scalar>::value),
00278         YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
00279 
00280       Base::_check_template_params();
00281       Base::_set_noalias(other);
00282     }
00284     EIGEN_STRONG_INLINE Matrix(const Matrix& other)
00285             : Base(other.rows() * other.cols(), other.rows(), other.cols())
00286     {
00287       Base::_check_template_params();
00288       Base::_set_noalias(other);
00289     }
00291     template<typename OtherDerived>
00292     EIGEN_STRONG_INLINE Matrix(const ReturnByValue<OtherDerived>& other)
00293     {
00294       Base::_check_template_params();
00295       Base::resize(other.rows(), other.cols());
00296       other.evalTo(*this);
00297     }
00298 
00302     template<typename OtherDerived>
00303     EIGEN_STRONG_INLINE Matrix(const EigenBase<OtherDerived> &other)
00304       : Base(other.derived().rows() * other.derived().cols(), other.derived().rows(), other.derived().cols())
00305     {
00306       Base::_check_template_params();
00307       Base::_resize_to_match(other);
00308       // FIXME/CHECK: isn't *this = other.derived() more efficient. it allows to
00309       //              go for pure _set() implementations, right?
00310       *this = other;
00311     }
00312 
00317     template<typename OtherDerived>
00318     void swap(MatrixBase<OtherDerived> const & other)
00319     { this->_swap(other.derived()); }
00320 
00321     inline Index innerStride() const { return 1; }
00322     inline Index outerStride() const { return this->innerSize(); }
00323 
00325 
00326     template<typename OtherDerived>
00327     explicit Matrix(const RotationBase<OtherDerived,ColsAtCompileTime>& r);
00328     template<typename OtherDerived>
00329     Matrix& operator=(const RotationBase<OtherDerived,ColsAtCompileTime>& r);
00330 
00331     #ifdef EIGEN2_SUPPORT
00332     template<typename OtherDerived>
00333     explicit Matrix(const eigen2_RotationBase<OtherDerived,ColsAtCompileTime>& r);
00334     template<typename OtherDerived>
00335     Matrix& operator=(const eigen2_RotationBase<OtherDerived,ColsAtCompileTime>& r);
00336     #endif
00337 
00338     // allow to extend Matrix outside Eigen
00339     #ifdef EIGEN_MATRIX_PLUGIN
00340     #include EIGEN_MATRIX_PLUGIN
00341     #endif
00342 
00343   protected:
00344     template <typename Derived, typename OtherDerived, bool IsVector>
00345     friend struct internal::conservative_resize_like_impl;
00346 
00347     using Base::m_storage;
00348 };
00349 
00370 #define EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix)   \
00371                                     \
00372 typedef Matrix<Type, Size, Size> Matrix##SizeSuffix##TypeSuffix;  \
00373                                     \
00374 typedef Matrix<Type, Size, 1>    Vector##SizeSuffix##TypeSuffix;  \
00375                                     \
00376 typedef Matrix<Type, 1, Size>    RowVector##SizeSuffix##TypeSuffix;
00377 
00378 #define EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, Size)         \
00379                                     \
00380 typedef Matrix<Type, Size, Dynamic> Matrix##Size##X##TypeSuffix;  \
00381                                     \
00382 typedef Matrix<Type, Dynamic, Size> Matrix##X##Size##TypeSuffix;
00383 
00384 #define EIGEN_MAKE_TYPEDEFS_ALL_SIZES(Type, TypeSuffix) \
00385 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 2, 2) \
00386 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 3, 3) \
00387 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 4, 4) \
00388 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Dynamic, X) \
00389 EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 2) \
00390 EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 3) \
00391 EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 4)
00392 
00393 EIGEN_MAKE_TYPEDEFS_ALL_SIZES(int,                  i)
00394 EIGEN_MAKE_TYPEDEFS_ALL_SIZES(float,                f)
00395 EIGEN_MAKE_TYPEDEFS_ALL_SIZES(double,               d)
00396 EIGEN_MAKE_TYPEDEFS_ALL_SIZES(std::complex<float>,  cf)
00397 EIGEN_MAKE_TYPEDEFS_ALL_SIZES(std::complex<double>, cd)
00398 
00399 #undef EIGEN_MAKE_TYPEDEFS_ALL_SIZES
00400 #undef EIGEN_MAKE_TYPEDEFS
00401 #undef EIGEN_MAKE_FIXED_TYPEDEFS
00402 
00403 } // end namespace Eigen
00404 
00405 #endif // EIGEN_MATRIX_H


turtlebot_exploration_3d
Author(s): Bona , Shawn
autogenerated on Thu Jun 6 2019 20:59:04