![]() |
Eigen
3.3.3
|
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 00016 namespace internal { 00017 template<typename PlainObjectType, int MapOptions, typename StrideType> 00018 struct traits<Map<PlainObjectType, MapOptions, StrideType> > 00019 : public traits<PlainObjectType> 00020 { 00021 typedef traits<PlainObjectType> TraitsBase; 00022 enum { 00023 InnerStrideAtCompileTime = StrideType::InnerStrideAtCompileTime == 0 00024 ? int(PlainObjectType::InnerStrideAtCompileTime) 00025 : int(StrideType::InnerStrideAtCompileTime), 00026 OuterStrideAtCompileTime = StrideType::OuterStrideAtCompileTime == 0 00027 ? int(PlainObjectType::OuterStrideAtCompileTime) 00028 : int(StrideType::OuterStrideAtCompileTime), 00029 Alignment = int(MapOptions)&int(AlignedMask), 00030 Flags0 = TraitsBase::Flags & (~NestByRefBit), 00031 Flags = is_lvalue<PlainObjectType>::value ? int(Flags0) : (int(Flags0) & ~LvalueBit) 00032 }; 00033 private: 00034 enum { Options }; // Expressions don't have Options 00035 }; 00036 } 00037 00088 template<typename PlainObjectType, int MapOptions, typename StrideType> class Map 00089 : public MapBase<Map<PlainObjectType, MapOptions, StrideType> > 00090 { 00091 public: 00092 00093 typedef MapBase<Map> Base; 00094 EIGEN_DENSE_PUBLIC_INTERFACE(Map) 00095 00096 typedef typename Base::PointerType PointerType; 00097 typedef PointerType PointerArgType; 00098 EIGEN_DEVICE_FUNC 00099 inline PointerType cast_to_pointer_type(PointerArgType ptr) { return ptr; } 00100 00101 EIGEN_DEVICE_FUNC 00102 inline Index innerStride() const 00103 { 00104 return StrideType::InnerStrideAtCompileTime != 0 ? m_stride.inner() : 1; 00105 } 00106 00107 EIGEN_DEVICE_FUNC 00108 inline Index outerStride() const 00109 { 00110 return StrideType::OuterStrideAtCompileTime != 0 ? m_stride.outer() 00111 : IsVectorAtCompileTime ? this->size() 00112 : int(Flags)&RowMajorBit ? this->cols() 00113 : this->rows(); 00114 } 00115 00121 EIGEN_DEVICE_FUNC 00122 explicit inline Map(PointerArgType dataPtr, const StrideType& stride = StrideType()) 00123 : Base(cast_to_pointer_type(dataPtr)), m_stride(stride) 00124 { 00125 PlainObjectType::Base::_check_template_params(); 00126 } 00127 00134 EIGEN_DEVICE_FUNC 00135 inline Map(PointerArgType dataPtr, Index size, const StrideType& stride = StrideType()) 00136 : Base(cast_to_pointer_type(dataPtr), size), m_stride(stride) 00137 { 00138 PlainObjectType::Base::_check_template_params(); 00139 } 00140 00148 EIGEN_DEVICE_FUNC 00149 inline Map(PointerArgType dataPtr, Index rows, Index cols, const StrideType& stride = StrideType()) 00150 : Base(cast_to_pointer_type(dataPtr), rows, cols), m_stride(stride) 00151 { 00152 PlainObjectType::Base::_check_template_params(); 00153 } 00154 00155 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map) 00156 00157 protected: 00158 StrideType m_stride; 00159 }; 00160 00161 00162 } // end namespace Eigen 00163 00164 #endif // EIGEN_MAP_H