Array.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) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>
00005 //
00006 // This Source Code Form is subject to the terms of the Mozilla
00007 // Public License v. 2.0. If a copy of the MPL was not distributed
00008 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
00009 
00010 #ifndef EIGEN_ARRAY_H
00011 #define EIGEN_ARRAY_H
00012 
00013 namespace Eigen {
00014 
00032 namespace internal {
00033 template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
00034 struct traits<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > : traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
00035 {
00036   typedef ArrayXpr XprKind;
00037   typedef ArrayBase<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > XprBase;
00038 };
00039 }
00040 
00041 template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
00042 class Array
00043   : public PlainObjectBase<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
00044 {
00045   public:
00046 
00047     typedef PlainObjectBase<Array> Base;
00048     EIGEN_DENSE_PUBLIC_INTERFACE(Array)
00049 
00050     enum { Options = _Options };
00051     typedef typename Base::PlainObject PlainObject;
00052 
00053   protected:
00054     template <typename Derived, typename OtherDerived, bool IsVector>
00055     friend struct internal::conservative_resize_like_impl;
00056 
00057     using Base::m_storage;
00058 
00059   public:
00060 
00061     using Base::base;
00062     using Base::coeff;
00063     using Base::coeffRef;
00064 
00071     template<typename OtherDerived>
00072     EIGEN_STRONG_INLINE Array& operator=(const EigenBase<OtherDerived> &other)
00073     {
00074       return Base::operator=(other);
00075     }
00076 
00086     template<typename OtherDerived>
00087     EIGEN_STRONG_INLINE Array& operator=(const ArrayBase<OtherDerived>& other)
00088     {
00089       return Base::_set(other);
00090     }
00091 
00095     EIGEN_STRONG_INLINE Array& operator=(const Array& other)
00096     {
00097       return Base::_set(other);
00098     }
00099 
00110     EIGEN_STRONG_INLINE Array() : Base()
00111     {
00112       Base::_check_template_params();
00113       EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
00114     }
00115 
00116 #ifndef EIGEN_PARSED_BY_DOXYGEN
00117     // FIXME is it still needed ??
00119     Array(internal::constructor_without_unaligned_array_assert)
00120       : Base(internal::constructor_without_unaligned_array_assert())
00121     {
00122       Base::_check_template_params();
00123       EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
00124     }
00125 #endif
00126 
00133     EIGEN_STRONG_INLINE explicit Array(Index dim)
00134       : Base(dim, RowsAtCompileTime == 1 ? 1 : dim, ColsAtCompileTime == 1 ? 1 : dim)
00135     {
00136       Base::_check_template_params();
00137       EIGEN_STATIC_ASSERT_VECTOR_ONLY(Array)
00138       eigen_assert(dim >= 0);
00139       eigen_assert(SizeAtCompileTime == Dynamic || SizeAtCompileTime == dim);
00140       EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
00141     }
00142 
00143     #ifndef EIGEN_PARSED_BY_DOXYGEN
00144     template<typename T0, typename T1>
00145     EIGEN_STRONG_INLINE Array(const T0& val0, const T1& val1)
00146     {
00147       Base::_check_template_params();
00148       this->template _init2<T0,T1>(val0, val1);
00149     }
00150     #else
00151 
00156     Array(Index rows, Index cols);
00158     Array(const Scalar& val0, const Scalar& val1);
00159     #endif
00160 
00162     EIGEN_STRONG_INLINE Array(const Scalar& val0, const Scalar& val1, const Scalar& val2)
00163     {
00164       Base::_check_template_params();
00165       EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Array, 3)
00166       m_storage.data()[0] = val0;
00167       m_storage.data()[1] = val1;
00168       m_storage.data()[2] = val2;
00169     }
00171     EIGEN_STRONG_INLINE Array(const Scalar& val0, const Scalar& val1, const Scalar& val2, const Scalar& val3)
00172     {
00173       Base::_check_template_params();
00174       EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Array, 4)
00175       m_storage.data()[0] = val0;
00176       m_storage.data()[1] = val1;
00177       m_storage.data()[2] = val2;
00178       m_storage.data()[3] = val3;
00179     }
00180 
00181     explicit Array(const Scalar *data);
00182 
00184     template<typename OtherDerived>
00185     EIGEN_STRONG_INLINE Array(const ArrayBase<OtherDerived>& other)
00186              : Base(other.rows() * other.cols(), other.rows(), other.cols())
00187     {
00188       Base::_check_template_params();
00189       Base::_set_noalias(other);
00190     }
00192     EIGEN_STRONG_INLINE Array(const Array& other)
00193             : Base(other.rows() * other.cols(), other.rows(), other.cols())
00194     {
00195       Base::_check_template_params();
00196       Base::_set_noalias(other);
00197     }
00199     template<typename OtherDerived>
00200     EIGEN_STRONG_INLINE Array(const ReturnByValue<OtherDerived>& other)
00201     {
00202       Base::_check_template_params();
00203       Base::resize(other.rows(), other.cols());
00204       other.evalTo(*this);
00205     }
00206 
00208     template<typename OtherDerived>
00209     EIGEN_STRONG_INLINE Array(const EigenBase<OtherDerived> &other)
00210       : Base(other.derived().rows() * other.derived().cols(), other.derived().rows(), other.derived().cols())
00211     {
00212       Base::_check_template_params();
00213       Base::resize(other.rows(), other.cols());
00214       *this = other;
00215     }
00216 
00220     template<typename OtherDerived>
00221     void swap(ArrayBase<OtherDerived> const & other)
00222     { this->_swap(other.derived()); }
00223 
00224     inline Index innerStride() const { return 1; }
00225     inline Index outerStride() const { return this->innerSize(); }
00226 
00227     #ifdef EIGEN_ARRAY_PLUGIN
00228     #include EIGEN_ARRAY_PLUGIN
00229     #endif
00230 
00231   private:
00232 
00233     template<typename MatrixType, typename OtherDerived, bool SwapPointers>
00234     friend struct internal::matrix_swap_impl;
00235 };
00236 
00256 #define EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix)   \
00257                                     \
00258 typedef Array<Type, Size, Size> Array##SizeSuffix##SizeSuffix##TypeSuffix;  \
00259                                     \
00260 typedef Array<Type, Size, 1>    Array##SizeSuffix##TypeSuffix;
00261 
00262 #define EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Type, TypeSuffix, Size)         \
00263                                     \
00264 typedef Array<Type, Size, Dynamic> Array##Size##X##TypeSuffix;  \
00265                                     \
00266 typedef Array<Type, Dynamic, Size> Array##X##Size##TypeSuffix;
00267 
00268 #define EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(Type, TypeSuffix) \
00269 EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, 2, 2) \
00270 EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, 3, 3) \
00271 EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, 4, 4) \
00272 EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, Dynamic, X) \
00273 EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Type, TypeSuffix, 2) \
00274 EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Type, TypeSuffix, 3) \
00275 EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Type, TypeSuffix, 4)
00276 
00277 EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(int,                  i)
00278 EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(float,                f)
00279 EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(double,               d)
00280 EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(std::complex<float>,  cf)
00281 EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(std::complex<double>, cd)
00282 
00283 #undef EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES
00284 #undef EIGEN_MAKE_ARRAY_TYPEDEFS
00285 
00286 #undef EIGEN_MAKE_ARRAY_TYPEDEFS_LARGE
00287 
00288 #define EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, SizeSuffix) \
00289 using Eigen::Matrix##SizeSuffix##TypeSuffix; \
00290 using Eigen::Vector##SizeSuffix##TypeSuffix; \
00291 using Eigen::RowVector##SizeSuffix##TypeSuffix;
00292 
00293 #define EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(TypeSuffix) \
00294 EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 2) \
00295 EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 3) \
00296 EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 4) \
00297 EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, X) \
00298 
00299 #define EIGEN_USING_ARRAY_TYPEDEFS \
00300 EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(i) \
00301 EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(f) \
00302 EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(d) \
00303 EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(cf) \
00304 EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(cd)
00305 
00306 } // end namespace Eigen
00307 
00308 #endif // EIGEN_ARRAY_H


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Sat Jun 8 2019 19:36:42