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_MATRIX_H
00027 #define EIGEN_MATRIX_H
00028
00117 namespace internal {
00118 template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
00119 struct traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
00120 {
00121 typedef _Scalar Scalar;
00122 typedef Dense StorageKind;
00123 typedef DenseIndex Index;
00124 typedef MatrixXpr XprKind;
00125 enum {
00126 RowsAtCompileTime = _Rows,
00127 ColsAtCompileTime = _Cols,
00128 MaxRowsAtCompileTime = _MaxRows,
00129 MaxColsAtCompileTime = _MaxCols,
00130 Flags = compute_matrix_flags<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::ret,
00131 CoeffReadCost = NumTraits<Scalar>::ReadCost,
00132 Options = _Options,
00133 InnerStrideAtCompileTime = 1,
00134 OuterStrideAtCompileTime = (Options&RowMajor) ? ColsAtCompileTime : RowsAtCompileTime
00135 };
00136 };
00137 }
00138
00139 template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
00140 class Matrix
00141 : public PlainObjectBase<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
00142 {
00143 public:
00144
00148 typedef PlainObjectBase<Matrix> Base;
00149
00150 enum { Options = _Options };
00151
00152 EIGEN_DENSE_PUBLIC_INTERFACE(Matrix)
00153
00154 typedef typename Base::PlainObject PlainObject;
00155
00156 enum { NeedsToAlign = (!(Options&DontAlign))
00157 && SizeAtCompileTime!=Dynamic && ((static_cast<int>(sizeof(Scalar))*SizeAtCompileTime)%16)==0 };
00158 EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign)
00159
00160 using Base::base;
00161 using Base::coeffRef;
00162
00171 EIGEN_STRONG_INLINE Matrix& operator=(const Matrix& other)
00172 {
00173 return Base::_set(other);
00174 }
00175
00186 template<typename OtherDerived>
00187 EIGEN_STRONG_INLINE Matrix& operator=(const MatrixBase<OtherDerived>& other)
00188 {
00189 return Base::_set(other);
00190 }
00191
00192
00193
00198 template<typename OtherDerived>
00199 EIGEN_STRONG_INLINE Matrix& operator=(const EigenBase<OtherDerived> &other)
00200 {
00201 return Base::operator=(other);
00202 }
00203
00204 template<typename OtherDerived>
00205 EIGEN_STRONG_INLINE Matrix& operator=(const ReturnByValue<OtherDerived>& func)
00206 {
00207 return Base::operator=(func);
00208 }
00209
00220 EIGEN_STRONG_INLINE explicit Matrix() : Base()
00221 {
00222 Base::_check_template_params();
00223 EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED
00224 }
00225
00226
00227 Matrix(internal::constructor_without_unaligned_array_assert)
00228 : Base(internal::constructor_without_unaligned_array_assert())
00229 { Base::_check_template_params(); EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED }
00230
00237 EIGEN_STRONG_INLINE explicit Matrix(Index dim)
00238 : Base(dim, RowsAtCompileTime == 1 ? 1 : dim, ColsAtCompileTime == 1 ? 1 : dim)
00239 {
00240 Base::_check_template_params();
00241 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Matrix)
00242 eigen_assert(dim >= 0);
00243 eigen_assert(SizeAtCompileTime == Dynamic || SizeAtCompileTime == dim);
00244 EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED
00245 }
00246
00247 #ifndef EIGEN_PARSED_BY_DOXYGEN
00248 template<typename T0, typename T1>
00249 EIGEN_STRONG_INLINE Matrix(const T0& x, const T1& y)
00250 {
00251 Base::_check_template_params();
00252 Base::template _init2<T0,T1>(x, y);
00253 }
00254 #else
00255
00260 Matrix(Index rows, Index cols);
00262 Matrix(const Scalar& x, const Scalar& y);
00263 #endif
00264
00266 EIGEN_STRONG_INLINE Matrix(const Scalar& x, const Scalar& y, const Scalar& z)
00267 {
00268 Base::_check_template_params();
00269 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Matrix, 3)
00270 m_storage.data()[0] = x;
00271 m_storage.data()[1] = y;
00272 m_storage.data()[2] = z;
00273 }
00275 EIGEN_STRONG_INLINE Matrix(const Scalar& x, const Scalar& y, const Scalar& z, const Scalar& w)
00276 {
00277 Base::_check_template_params();
00278 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Matrix, 4)
00279 m_storage.data()[0] = x;
00280 m_storage.data()[1] = y;
00281 m_storage.data()[2] = z;
00282 m_storage.data()[3] = w;
00283 }
00284
00285 explicit Matrix(const Scalar *data);
00286
00288 template<typename OtherDerived>
00289 EIGEN_STRONG_INLINE Matrix(const MatrixBase<OtherDerived>& other)
00290 : Base(other.rows() * other.cols(), other.rows(), other.cols())
00291 {
00292
00293
00294 EIGEN_STATIC_ASSERT((internal::is_same<Scalar, typename OtherDerived::Scalar>::value),
00295 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
00296
00297 Base::_check_template_params();
00298 Base::_set_noalias(other);
00299 }
00301 EIGEN_STRONG_INLINE Matrix(const Matrix& other)
00302 : Base(other.rows() * other.cols(), other.rows(), other.cols())
00303 {
00304 Base::_check_template_params();
00305 Base::_set_noalias(other);
00306 }
00308 template<typename OtherDerived>
00309 EIGEN_STRONG_INLINE Matrix(const ReturnByValue<OtherDerived>& other)
00310 {
00311 Base::_check_template_params();
00312 Base::resize(other.rows(), other.cols());
00313 other.evalTo(*this);
00314 }
00315
00319 template<typename OtherDerived>
00320 EIGEN_STRONG_INLINE Matrix(const EigenBase<OtherDerived> &other)
00321 : Base(other.derived().rows() * other.derived().cols(), other.derived().rows(), other.derived().cols())
00322 {
00323 Base::_check_template_params();
00324 Base::resize(other.rows(), other.cols());
00325
00326
00327 *this = other;
00328 }
00329
00334 template<typename OtherDerived>
00335 void swap(MatrixBase<OtherDerived> const & other)
00336 { this->_swap(other.derived()); }
00337
00338 inline Index innerStride() const { return 1; }
00339 inline Index outerStride() const { return this->innerSize(); }
00340
00342
00343 template<typename OtherDerived>
00344 explicit Matrix(const RotationBase<OtherDerived,ColsAtCompileTime>& r);
00345 template<typename OtherDerived>
00346 Matrix& operator=(const RotationBase<OtherDerived,ColsAtCompileTime>& r);
00347
00348 #ifdef EIGEN2_SUPPORT
00349 template<typename OtherDerived>
00350 explicit Matrix(const eigen2_RotationBase<OtherDerived,ColsAtCompileTime>& r);
00351 template<typename OtherDerived>
00352 Matrix& operator=(const eigen2_RotationBase<OtherDerived,ColsAtCompileTime>& r);
00353 #endif
00354
00355
00356 #ifdef EIGEN_MATRIX_PLUGIN
00357 #include EIGEN_MATRIX_PLUGIN
00358 #endif
00359
00360 protected:
00361 template <typename Derived, typename OtherDerived, bool IsVector>
00362 friend struct internal::conservative_resize_like_impl;
00363
00364 using Base::m_storage;
00365 };
00366
00387 #define EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix) \
00388 \
00389 typedef Matrix<Type, Size, Size> Matrix##SizeSuffix##TypeSuffix; \
00390 \
00391 typedef Matrix<Type, Size, 1> Vector##SizeSuffix##TypeSuffix; \
00392 \
00393 typedef Matrix<Type, 1, Size> RowVector##SizeSuffix##TypeSuffix;
00394
00395 #define EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, Size) \
00396 \
00397 typedef Matrix<Type, Size, Dynamic> Matrix##Size##X##TypeSuffix; \
00398 \
00399 typedef Matrix<Type, Dynamic, Size> Matrix##X##Size##TypeSuffix;
00400
00401 #define EIGEN_MAKE_TYPEDEFS_ALL_SIZES(Type, TypeSuffix) \
00402 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 2, 2) \
00403 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 3, 3) \
00404 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 4, 4) \
00405 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Dynamic, X) \
00406 EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 2) \
00407 EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 3) \
00408 EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 4)
00409
00410 EIGEN_MAKE_TYPEDEFS_ALL_SIZES(int, i)
00411 EIGEN_MAKE_TYPEDEFS_ALL_SIZES(float, f)
00412 EIGEN_MAKE_TYPEDEFS_ALL_SIZES(double, d)
00413 EIGEN_MAKE_TYPEDEFS_ALL_SIZES(std::complex<float>, cf)
00414 EIGEN_MAKE_TYPEDEFS_ALL_SIZES(std::complex<double>, cd)
00415
00416 #undef EIGEN_MAKE_TYPEDEFS_ALL_SIZES
00417 #undef EIGEN_MAKE_TYPEDEFS
00418
00419 #undef EIGEN_MAKE_TYPEDEFS_LARGE
00420
00421 #define EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, SizeSuffix) \
00422 using Eigen::Matrix##SizeSuffix##TypeSuffix; \
00423 using Eigen::Vector##SizeSuffix##TypeSuffix; \
00424 using Eigen::RowVector##SizeSuffix##TypeSuffix;
00425
00426 #define EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(TypeSuffix) \
00427 EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 2) \
00428 EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 3) \
00429 EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 4) \
00430 EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, X) \
00431
00432 #define EIGEN_USING_MATRIX_TYPEDEFS \
00433 EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(i) \
00434 EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(f) \
00435 EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(d) \
00436 EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(cf) \
00437 EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(cd)
00438
00439 #endif // EIGEN_MATRIX_H