Map.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) 2007-2010 Benoit Jacob <jacob.benoit.1@gmail.com>
00005 // Copyright (C) 2008 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_MAP_H
00012 #define EIGEN_MAP_H
00013 
00014 namespace Eigen { 
00015 
00067 namespace internal {
00068 template<typename PlainObjectType, int MapOptions, typename StrideType>
00069 struct traits<Map<PlainObjectType, MapOptions, StrideType> >
00070   : public traits<PlainObjectType>
00071 {
00072   typedef traits<PlainObjectType> TraitsBase;
00073   typedef typename PlainObjectType::Index Index;
00074   typedef typename PlainObjectType::Scalar Scalar;
00075   enum {
00076     InnerStrideAtCompileTime = StrideType::InnerStrideAtCompileTime == 0
00077                              ? int(PlainObjectType::InnerStrideAtCompileTime)
00078                              : int(StrideType::InnerStrideAtCompileTime),
00079     OuterStrideAtCompileTime = StrideType::OuterStrideAtCompileTime == 0
00080                              ? int(PlainObjectType::OuterStrideAtCompileTime)
00081                              : int(StrideType::OuterStrideAtCompileTime),
00082     HasNoInnerStride = InnerStrideAtCompileTime == 1,
00083     HasNoOuterStride = StrideType::OuterStrideAtCompileTime == 0,
00084     HasNoStride = HasNoInnerStride && HasNoOuterStride,
00085     IsAligned = bool(EIGEN_ALIGN) && ((int(MapOptions)&Aligned)==Aligned),
00086     IsDynamicSize = PlainObjectType::SizeAtCompileTime==Dynamic,
00087     KeepsPacketAccess = bool(HasNoInnerStride)
00088                         && ( bool(IsDynamicSize)
00089                            || HasNoOuterStride
00090                            || ( OuterStrideAtCompileTime!=Dynamic
00091                            && ((static_cast<int>(sizeof(Scalar))*OuterStrideAtCompileTime)%16)==0 ) ),
00092     Flags0 = TraitsBase::Flags & (~NestByRefBit),
00093     Flags1 = IsAligned ? (int(Flags0) | AlignedBit) : (int(Flags0) & ~AlignedBit),
00094     Flags2 = (bool(HasNoStride) || bool(PlainObjectType::IsVectorAtCompileTime))
00095            ? int(Flags1) : int(Flags1 & ~LinearAccessBit),
00096     Flags3 = is_lvalue<PlainObjectType>::value ? int(Flags2) : (int(Flags2) & ~LvalueBit),
00097     Flags = KeepsPacketAccess ? int(Flags3) : (int(Flags3) & ~PacketAccessBit)
00098   };
00099 private:
00100   enum { Options }; // Expressions don't have Options
00101 };
00102 }
00103 
00104 template<typename PlainObjectType, int MapOptions, typename StrideType> class Map
00105   : public MapBase<Map<PlainObjectType, MapOptions, StrideType> >
00106 {
00107   public:
00108 
00109     typedef MapBase<Map> Base;
00110     EIGEN_DENSE_PUBLIC_INTERFACE(Map)
00111 
00112     typedef typename Base::PointerType PointerType;
00113 #if EIGEN2_SUPPORT_STAGE <= STAGE30_FULL_EIGEN3_API
00114     typedef const Scalar* PointerArgType;
00115     inline PointerType cast_to_pointer_type(PointerArgType ptr) { return const_cast<PointerType>(ptr); }
00116 #else
00117     typedef PointerType PointerArgType;
00118     inline PointerType cast_to_pointer_type(PointerArgType ptr) { return ptr; }
00119 #endif
00120 
00121     inline Index innerStride() const
00122     {
00123       return StrideType::InnerStrideAtCompileTime != 0 ? m_stride.inner() : 1;
00124     }
00125 
00126     inline Index outerStride() const
00127     {
00128       return StrideType::OuterStrideAtCompileTime != 0 ? m_stride.outer()
00129            : IsVectorAtCompileTime ? this->size()
00130            : int(Flags)&RowMajorBit ? this->cols()
00131            : this->rows();
00132     }
00133 
00139     inline Map(PointerArgType data, const StrideType& stride = StrideType())
00140       : Base(cast_to_pointer_type(data)), m_stride(stride)
00141     {
00142       PlainObjectType::Base::_check_template_params();
00143     }
00144 
00151     inline Map(PointerArgType data, Index size, const StrideType& stride = StrideType())
00152       : Base(cast_to_pointer_type(data), size), m_stride(stride)
00153     {
00154       PlainObjectType::Base::_check_template_params();
00155     }
00156 
00164     inline Map(PointerArgType data, Index rows, Index cols, const StrideType& stride = StrideType())
00165       : Base(cast_to_pointer_type(data), rows, cols), m_stride(stride)
00166     {
00167       PlainObjectType::Base::_check_template_params();
00168     }
00169 
00170     EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map)
00171 
00172   protected:
00173     StrideType m_stride;
00174 };
00175 
00176 template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
00177 inline Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>
00178   ::Array(const Scalar *data)
00179 {
00180   this->_set_noalias(Eigen::Map<const Array>(data));
00181 }
00182 
00183 template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
00184 inline Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>
00185   ::Matrix(const Scalar *data)
00186 {
00187   this->_set_noalias(Eigen::Map<const Matrix>(data));
00188 }
00189 
00190 } // end namespace Eigen
00191 
00192 #endif // EIGEN_MAP_H


win_eigen
Author(s): Daniel Stonier
autogenerated on Wed Sep 16 2015 07:11:09