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 #ifndef EIGEN_ARRAY_H
00026 #define EIGEN_ARRAY_H
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 namespace internal {
00043 template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
00044 struct traits<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > : traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
00045 {
00046 typedef ArrayXpr XprKind;
00047 typedef ArrayBase<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > XprBase;
00048 };
00049 }
00050
00051 template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
00052 class Array
00053 : public PlainObjectBase<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
00054 {
00055 public:
00056
00057 typedef PlainObjectBase<Array> Base;
00058 EIGEN_DENSE_PUBLIC_INTERFACE(Array)
00059
00060 enum { Options = _Options };
00061 typedef typename Base::PlainObject PlainObject;
00062
00063 protected:
00064 template <typename Derived, typename OtherDerived, bool IsVector>
00065 friend struct internal::conservative_resize_like_impl;
00066
00067 using Base::m_storage;
00068 public:
00069 enum { NeedsToAlign = (!(Options&DontAlign))
00070 && SizeAtCompileTime!=Dynamic && ((static_cast<int>(sizeof(Scalar))*SizeAtCompileTime)%16)==0 };
00071 EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign)
00072
00073 using Base::base;
00074 using Base::coeff;
00075 using Base::coeffRef;
00076
00077
00078
00079
00080
00081
00082
00083 template<typename OtherDerived>
00084 EIGEN_STRONG_INLINE Array& operator=(const EigenBase<OtherDerived> &other)
00085 {
00086 return Base::operator=(other);
00087 }
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098 template<typename OtherDerived>
00099 EIGEN_STRONG_INLINE Array& operator=(const ArrayBase<OtherDerived>& other)
00100 {
00101 return Base::_set(other);
00102 }
00103
00104
00105
00106
00107 EIGEN_STRONG_INLINE Array& operator=(const Array& other)
00108 {
00109 return Base::_set(other);
00110 }
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122 EIGEN_STRONG_INLINE explicit Array() : Base()
00123 {
00124 Base::_check_template_params();
00125 EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED
00126 }
00127
00128 #ifndef EIGEN_PARSED_BY_DOXYGEN
00129
00130
00131 Array(internal::constructor_without_unaligned_array_assert)
00132 : Base(internal::constructor_without_unaligned_array_assert())
00133 {
00134 Base::_check_template_params();
00135 EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED
00136 }
00137 #endif
00138
00139
00140
00141
00142
00143
00144
00145 EIGEN_STRONG_INLINE explicit Array(Index dim)
00146 : Base(dim, RowsAtCompileTime == 1 ? 1 : dim, ColsAtCompileTime == 1 ? 1 : dim)
00147 {
00148 Base::_check_template_params();
00149 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Array)
00150 eigen_assert(dim > 0);
00151 eigen_assert(SizeAtCompileTime == Dynamic || SizeAtCompileTime == dim);
00152 EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED
00153 }
00154
00155 #ifndef EIGEN_PARSED_BY_DOXYGEN
00156 template<typename T0, typename T1>
00157 EIGEN_STRONG_INLINE Array(const T0& x, const T1& y)
00158 {
00159 Base::_check_template_params();
00160 this->template _init2<T0,T1>(x, y);
00161 }
00162 #else
00163
00164
00165
00166
00167
00168 Array(Index rows, Index cols);
00169
00170 Array(const Scalar& x, const Scalar& y);
00171 #endif
00172
00173
00174 EIGEN_STRONG_INLINE Array(const Scalar& x, const Scalar& y, const Scalar& z)
00175 {
00176 Base::_check_template_params();
00177 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Array, 3)
00178 m_storage.data()[0] = x;
00179 m_storage.data()[1] = y;
00180 m_storage.data()[2] = z;
00181 }
00182
00183 EIGEN_STRONG_INLINE Array(const Scalar& x, const Scalar& y, const Scalar& z, const Scalar& w)
00184 {
00185 Base::_check_template_params();
00186 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Array, 4)
00187 m_storage.data()[0] = x;
00188 m_storage.data()[1] = y;
00189 m_storage.data()[2] = z;
00190 m_storage.data()[3] = w;
00191 }
00192
00193 explicit Array(const Scalar *data);
00194
00195
00196 template<typename OtherDerived>
00197 EIGEN_STRONG_INLINE Array(const ArrayBase<OtherDerived>& other)
00198 : Base(other.rows() * other.cols(), other.rows(), other.cols())
00199 {
00200 Base::_check_template_params();
00201 Base::_set_noalias(other);
00202 }
00203
00204 EIGEN_STRONG_INLINE Array(const Array& other)
00205 : Base(other.rows() * other.cols(), other.rows(), other.cols())
00206 {
00207 Base::_check_template_params();
00208 Base::_set_noalias(other);
00209 }
00210
00211 template<typename OtherDerived>
00212 EIGEN_STRONG_INLINE Array(const ReturnByValue<OtherDerived>& other)
00213 {
00214 Base::_check_template_params();
00215 Base::resize(other.rows(), other.cols());
00216 other.evalTo(*this);
00217 }
00218
00219
00220 template<typename OtherDerived>
00221 EIGEN_STRONG_INLINE Array(const EigenBase<OtherDerived> &other)
00222 : Base(other.derived().rows() * other.derived().cols(), other.derived().rows(), other.derived().cols())
00223 {
00224 Base::_check_template_params();
00225 Base::resize(other.rows(), other.cols());
00226 *this = other;
00227 }
00228
00229
00230
00231
00232 template<typename OtherDerived>
00233 void swap(ArrayBase<OtherDerived> const & other)
00234 { this->_swap(other.derived()); }
00235
00236 inline Index innerStride() const { return 1; }
00237 inline Index outerStride() const { return this->innerSize(); }
00238
00239 #ifdef EIGEN_ARRAY_PLUGIN
00240 #include EIGEN_ARRAY_PLUGIN
00241 #endif
00242
00243 private:
00244
00245 template<typename MatrixType, typename OtherDerived, bool SwapPointers>
00246 friend struct internal::matrix_swap_impl;
00247 };
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268 #define EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix) \
00269 \
00270 typedef Array<Type, Size, Size> Array##SizeSuffix##SizeSuffix##TypeSuffix; \
00271 \
00272 typedef Array<Type, Size, 1> Array##SizeSuffix##TypeSuffix;
00273
00274 #define EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Type, TypeSuffix, Size) \
00275 \
00276 typedef Array<Type, Size, Dynamic> Array##Size##X##TypeSuffix; \
00277 \
00278 typedef Array<Type, Dynamic, Size> Array##X##Size##TypeSuffix;
00279
00280 #define EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(Type, TypeSuffix) \
00281 EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, 2, 2) \
00282 EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, 3, 3) \
00283 EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, 4, 4) \
00284 EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, Dynamic, X) \
00285 EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Type, TypeSuffix, 2) \
00286 EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Type, TypeSuffix, 3) \
00287 EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Type, TypeSuffix, 4)
00288
00289 EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(int, i)
00290 EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(float, f)
00291 EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(double, d)
00292 EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(std::complex<float>, cf)
00293 EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(std::complex<double>, cd)
00294
00295 #undef EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES
00296 #undef EIGEN_MAKE_ARRAY_TYPEDEFS
00297
00298 #undef EIGEN_MAKE_ARRAY_TYPEDEFS_LARGE
00299
00300 #define EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, SizeSuffix) \
00301 using Eigen::Matrix##SizeSuffix##TypeSuffix; \
00302 using Eigen::Vector##SizeSuffix##TypeSuffix; \
00303 using Eigen::RowVector##SizeSuffix##TypeSuffix;
00304
00305 #define EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(TypeSuffix) \
00306 EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 2) \
00307 EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 3) \
00308 EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 4) \
00309 EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, X) \
00310
00311 #define EIGEN_USING_ARRAY_TYPEDEFS \
00312 EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(i) \
00313 EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(f) \
00314 EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(d) \
00315 EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(cf) \
00316 EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(cd)
00317
00318
00319 #endif // EIGEN_ARRAY_H