00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef EIGEN_MAP_H
00027 #define EIGEN_MAP_H
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080 namespace internal {
00081 template<typename PlainObjectType, int MapOptions, typename StrideType>
00082 struct traits<Map<PlainObjectType, MapOptions, StrideType> >
00083 : public traits<PlainObjectType>
00084 {
00085 typedef traits<PlainObjectType> TraitsBase;
00086 typedef typename PlainObjectType::Index Index;
00087 typedef typename PlainObjectType::Scalar Scalar;
00088 enum {
00089 InnerStrideAtCompileTime = StrideType::InnerStrideAtCompileTime == 0
00090 ? int(PlainObjectType::InnerStrideAtCompileTime)
00091 : int(StrideType::InnerStrideAtCompileTime),
00092 OuterStrideAtCompileTime = StrideType::OuterStrideAtCompileTime == 0
00093 ? int(PlainObjectType::OuterStrideAtCompileTime)
00094 : int(StrideType::OuterStrideAtCompileTime),
00095 HasNoInnerStride = InnerStrideAtCompileTime == 1,
00096 HasNoOuterStride = StrideType::OuterStrideAtCompileTime == 0,
00097 HasNoStride = HasNoInnerStride && HasNoOuterStride,
00098 IsAligned = int(int(MapOptions)&Aligned)==Aligned,
00099 IsDynamicSize = PlainObjectType::SizeAtCompileTime==Dynamic,
00100 KeepsPacketAccess = bool(HasNoInnerStride)
00101 && ( bool(IsDynamicSize)
00102 || HasNoOuterStride
00103 || ( OuterStrideAtCompileTime!=Dynamic
00104 && ((static_cast<int>(sizeof(Scalar))*OuterStrideAtCompileTime)%16)==0 ) ),
00105 Flags0 = TraitsBase::Flags,
00106 Flags1 = IsAligned ? (int(Flags0) | AlignedBit) : (int(Flags0) & ~AlignedBit),
00107 Flags2 = (bool(HasNoStride) || bool(PlainObjectType::IsVectorAtCompileTime))
00108 ? int(Flags1) : int(Flags1 & ~LinearAccessBit),
00109 Flags3 = is_lvalue<PlainObjectType>::value ? int(Flags2) : (int(Flags2) & ~LvalueBit),
00110 Flags = KeepsPacketAccess ? int(Flags3) : (int(Flags3) & ~PacketAccessBit)
00111 };
00112 private:
00113 enum { Options };
00114 };
00115 }
00116
00117 template<typename PlainObjectType, int MapOptions, typename StrideType> class Map
00118 : public MapBase<Map<PlainObjectType, MapOptions, StrideType> >
00119 {
00120 public:
00121
00122 typedef MapBase<Map> Base;
00123
00124 EIGEN_DENSE_PUBLIC_INTERFACE(Map)
00125
00126 typedef typename Base::PointerType PointerType;
00127
00128
00129 inline Index innerStride() const
00130 {
00131 return StrideType::InnerStrideAtCompileTime != 0 ? m_stride.inner() : 1;
00132 }
00133
00134 inline Index outerStride() const
00135 {
00136 return StrideType::OuterStrideAtCompileTime != 0 ? m_stride.outer()
00137 : IsVectorAtCompileTime ? this->size()
00138 : int(Flags)&RowMajorBit ? this->cols()
00139 : this->rows();
00140 }
00141
00142
00143
00144
00145
00146
00147 inline Map(PointerType data, const StrideType& stride = StrideType())
00148 : Base(data), m_stride(stride)
00149 {
00150 PlainObjectType::Base::_check_template_params();
00151 }
00152
00153
00154
00155
00156
00157
00158
00159 inline Map(PointerType data, Index size, const StrideType& stride = StrideType())
00160 : Base(data, size), m_stride(stride)
00161 {
00162 PlainObjectType::Base::_check_template_params();
00163 }
00164
00165
00166
00167
00168
00169
00170
00171
00172 inline Map(PointerType data, Index rows, Index cols, const StrideType& stride = StrideType())
00173 : Base(data, rows, cols), m_stride(stride)
00174 {
00175 PlainObjectType::Base::_check_template_params();
00176 }
00177
00178
00179 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map)
00180
00181 protected:
00182 StrideType m_stride;
00183 };
00184
00185 template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
00186 inline Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>
00187 ::Array(const Scalar *data)
00188 {
00189 _set_noalias(Eigen::Map<const Array>(data));
00190 }
00191
00192 template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
00193 inline Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>
00194 ::Matrix(const Scalar *data)
00195 {
00196 _set_noalias(Eigen::Map<const Matrix>(data));
00197 }
00198
00199 #endif // EIGEN_MAP_H