File indexing completed on 2025-04-19 09:06:03
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef EIGEN_ARRAY_H
0011 #define EIGEN_ARRAY_H
0012
0013 namespace RivetEigen {
0014
0015 namespace internal {
0016 template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
0017 struct traits<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > : traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
0018 {
0019 typedef ArrayXpr XprKind;
0020 typedef ArrayBase<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > XprBase;
0021 };
0022 }
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
0045 class Array
0046 : public PlainObjectBase<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
0047 {
0048 public:
0049
0050 typedef PlainObjectBase<Array> Base;
0051 EIGEN_DENSE_PUBLIC_INTERFACE(Array)
0052
0053 enum { Options = _Options };
0054 typedef typename Base::PlainObject PlainObject;
0055
0056 protected:
0057 template <typename Derived, typename OtherDerived, bool IsVector>
0058 friend struct internal::conservative_resize_like_impl;
0059
0060 using Base::m_storage;
0061
0062 public:
0063
0064 using Base::base;
0065 using Base::coeff;
0066 using Base::coeffRef;
0067
0068
0069
0070
0071
0072
0073
0074 template<typename OtherDerived>
0075 EIGEN_DEVICE_FUNC
0076 EIGEN_STRONG_INLINE Array& operator=(const EigenBase<OtherDerived> &other)
0077 {
0078 return Base::operator=(other);
0079 }
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089 EIGEN_DEVICE_FUNC
0090 EIGEN_STRONG_INLINE Array& operator=(const Scalar &value)
0091 {
0092 Base::setConstant(value);
0093 return *this;
0094 }
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105 template<typename OtherDerived>
0106 EIGEN_DEVICE_FUNC
0107 EIGEN_STRONG_INLINE Array& operator=(const DenseBase<OtherDerived>& other)
0108 {
0109 return Base::_set(other);
0110 }
0111
0112
0113
0114
0115 EIGEN_DEVICE_FUNC
0116 EIGEN_STRONG_INLINE Array& operator=(const Array& other)
0117 {
0118 return Base::_set(other);
0119 }
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131 EIGEN_DEVICE_FUNC
0132 EIGEN_STRONG_INLINE Array() : Base()
0133 {
0134 Base::_check_template_params();
0135 EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
0136 }
0137
0138 #ifndef EIGEN_PARSED_BY_DOXYGEN
0139
0140
0141 EIGEN_DEVICE_FUNC
0142 Array(internal::constructor_without_unaligned_array_assert)
0143 : Base(internal::constructor_without_unaligned_array_assert())
0144 {
0145 Base::_check_template_params();
0146 EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
0147 }
0148 #endif
0149
0150 #if EIGEN_HAS_RVALUE_REFERENCES
0151 EIGEN_DEVICE_FUNC
0152 Array(Array&& other) EIGEN_NOEXCEPT_IF(std::is_nothrow_move_constructible<Scalar>::value)
0153 : Base(std::move(other))
0154 {
0155 Base::_check_template_params();
0156 }
0157 EIGEN_DEVICE_FUNC
0158 Array& operator=(Array&& other) EIGEN_NOEXCEPT_IF(std::is_nothrow_move_assignable<Scalar>::value)
0159 {
0160 Base::operator=(std::move(other));
0161 return *this;
0162 }
0163 #endif
0164
0165 #if EIGEN_HAS_CXX11
0166
0167
0168
0169
0170
0171
0172
0173
0174 template <typename... ArgTypes>
0175 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0176 Array(const Scalar& a0, const Scalar& a1, const Scalar& a2, const Scalar& a3, const ArgTypes&... args)
0177 : Base(a0, a1, a2, a3, args...) {}
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200 EIGEN_DEVICE_FUNC
0201 EIGEN_STRONG_INLINE Array(const std::initializer_list<std::initializer_list<Scalar>>& list) : Base(list) {}
0202 #endif
0203
0204 #ifndef EIGEN_PARSED_BY_DOXYGEN
0205 template<typename T>
0206 EIGEN_DEVICE_FUNC
0207 EIGEN_STRONG_INLINE explicit Array(const T& x)
0208 {
0209 Base::_check_template_params();
0210 Base::template _init1<T>(x);
0211 }
0212
0213 template<typename T0, typename T1>
0214 EIGEN_DEVICE_FUNC
0215 EIGEN_STRONG_INLINE Array(const T0& val0, const T1& val1)
0216 {
0217 Base::_check_template_params();
0218 this->template _init2<T0,T1>(val0, val1);
0219 }
0220
0221 #else
0222
0223 EIGEN_DEVICE_FUNC explicit Array(const Scalar *data);
0224
0225
0226
0227
0228
0229
0230 EIGEN_DEVICE_FUNC
0231 EIGEN_STRONG_INLINE explicit Array(Index dim);
0232
0233
0234 Array(const Scalar& value);
0235
0236
0237
0238
0239
0240 Array(Index rows, Index cols);
0241
0242
0243 Array(const Scalar& val0, const Scalar& val1);
0244 #endif
0245
0246
0247
0248
0249 EIGEN_DEVICE_FUNC
0250 EIGEN_STRONG_INLINE Array(const Scalar& val0, const Scalar& val1, const Scalar& val2)
0251 {
0252 Base::_check_template_params();
0253 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Array, 3)
0254 m_storage.data()[0] = val0;
0255 m_storage.data()[1] = val1;
0256 m_storage.data()[2] = val2;
0257 }
0258
0259
0260
0261 EIGEN_DEVICE_FUNC
0262 EIGEN_STRONG_INLINE Array(const Scalar& val0, const Scalar& val1, const Scalar& val2, const Scalar& val3)
0263 {
0264 Base::_check_template_params();
0265 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Array, 4)
0266 m_storage.data()[0] = val0;
0267 m_storage.data()[1] = val1;
0268 m_storage.data()[2] = val2;
0269 m_storage.data()[3] = val3;
0270 }
0271
0272
0273 EIGEN_DEVICE_FUNC
0274 EIGEN_STRONG_INLINE Array(const Array& other)
0275 : Base(other)
0276 { }
0277
0278 private:
0279 struct PrivateType {};
0280 public:
0281
0282
0283 template<typename OtherDerived>
0284 EIGEN_DEVICE_FUNC
0285 EIGEN_STRONG_INLINE Array(const EigenBase<OtherDerived> &other,
0286 typename internal::enable_if<internal::is_convertible<typename OtherDerived::Scalar,Scalar>::value,
0287 PrivateType>::type = PrivateType())
0288 : Base(other.derived())
0289 { }
0290
0291 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
0292 inline Index innerStride() const EIGEN_NOEXCEPT{ return 1; }
0293 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
0294 inline Index outerStride() const EIGEN_NOEXCEPT { return this->innerSize(); }
0295
0296 #ifdef EIGEN_ARRAY_PLUGIN
0297 #include EIGEN_ARRAY_PLUGIN
0298 #endif
0299
0300 private:
0301
0302 template<typename MatrixType, typename OtherDerived, bool SwapPointers>
0303 friend struct internal::matrix_swap_impl;
0304 };
0305
0306
0307
0308
0309
0310
0311
0312
0313
0314
0315
0316
0317
0318
0319
0320
0321
0322
0323
0324
0325
0326
0327
0328
0329
0330
0331 #define EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix) \
0332 \
0333 typedef Array<Type, Size, Size> Array##SizeSuffix##SizeSuffix##TypeSuffix; \
0334 \
0335 typedef Array<Type, Size, 1> Array##SizeSuffix##TypeSuffix;
0336
0337 #define EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Type, TypeSuffix, Size) \
0338 \
0339 typedef Array<Type, Size, Dynamic> Array##Size##X##TypeSuffix; \
0340 \
0341 typedef Array<Type, Dynamic, Size> Array##X##Size##TypeSuffix;
0342
0343 #define EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(Type, TypeSuffix) \
0344 EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, 2, 2) \
0345 EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, 3, 3) \
0346 EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, 4, 4) \
0347 EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, Dynamic, X) \
0348 EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Type, TypeSuffix, 2) \
0349 EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Type, TypeSuffix, 3) \
0350 EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Type, TypeSuffix, 4)
0351
0352 EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(int, i)
0353 EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(float, f)
0354 EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(double, d)
0355 EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(std::complex<float>, cf)
0356 EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(std::complex<double>, cd)
0357
0358 #undef EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES
0359 #undef EIGEN_MAKE_ARRAY_TYPEDEFS
0360 #undef EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS
0361
0362 #if EIGEN_HAS_CXX11
0363
0364 #define EIGEN_MAKE_ARRAY_TYPEDEFS(Size, SizeSuffix) \
0365 \
0366 \
0367 template <typename Type> \
0368 using Array##SizeSuffix##SizeSuffix = Array<Type, Size, Size>; \
0369 \
0370 \
0371 template <typename Type> \
0372 using Array##SizeSuffix = Array<Type, Size, 1>;
0373
0374 #define EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Size) \
0375 \
0376 \
0377 template <typename Type> \
0378 using Array##Size##X = Array<Type, Size, Dynamic>; \
0379 \
0380 \
0381 template <typename Type> \
0382 using Array##X##Size = Array<Type, Dynamic, Size>;
0383
0384 EIGEN_MAKE_ARRAY_TYPEDEFS(2, 2)
0385 EIGEN_MAKE_ARRAY_TYPEDEFS(3, 3)
0386 EIGEN_MAKE_ARRAY_TYPEDEFS(4, 4)
0387 EIGEN_MAKE_ARRAY_TYPEDEFS(Dynamic, X)
0388 EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(2)
0389 EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(3)
0390 EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(4)
0391
0392 #undef EIGEN_MAKE_ARRAY_TYPEDEFS
0393 #undef EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS
0394
0395 #endif
0396
0397 #define EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, SizeSuffix) \
0398 using RivetEigen::Matrix##SizeSuffix##TypeSuffix; \
0399 using RivetEigen::Vector##SizeSuffix##TypeSuffix; \
0400 using RivetEigen::RowVector##SizeSuffix##TypeSuffix;
0401
0402 #define EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(TypeSuffix) \
0403 EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 2) \
0404 EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 3) \
0405 EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 4) \
0406 EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, X) \
0407
0408 #define EIGEN_USING_ARRAY_TYPEDEFS \
0409 EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(i) \
0410 EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(f) \
0411 EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(d) \
0412 EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(cf) \
0413 EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(cd)
0414
0415 }
0416
0417 #endif