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
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
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113 namespace internal {
00114 template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
00115 struct traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
00116 {
00117 typedef _Scalar Scalar;
00118 typedef Dense StorageKind;
00119 typedef DenseIndex Index;
00120 typedef MatrixXpr XprKind;
00121 enum {
00122 RowsAtCompileTime = _Rows,
00123 ColsAtCompileTime = _Cols,
00124 MaxRowsAtCompileTime = _MaxRows,
00125 MaxColsAtCompileTime = _MaxCols,
00126 Flags = compute_matrix_flags<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::ret,
00127 CoeffReadCost = NumTraits<Scalar>::ReadCost,
00128 Options = _Options,
00129 InnerStrideAtCompileTime = 1,
00130 OuterStrideAtCompileTime = (Options&RowMajor) ? ColsAtCompileTime : RowsAtCompileTime
00131 };
00132 };
00133 }
00134
00135 template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
00136 class Matrix
00137 : public PlainObjectBase<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
00138 {
00139 public:
00140
00141
00142
00143
00144 typedef PlainObjectBase<Matrix> Base;
00145
00146 enum { Options = _Options };
00147
00148 EIGEN_DENSE_PUBLIC_INTERFACE(Matrix)
00149
00150 typedef typename Base::PlainObject PlainObject;
00151
00152 enum { NeedsToAlign = (!(Options&DontAlign))
00153 && SizeAtCompileTime!=Dynamic && ((static_cast<int>(sizeof(Scalar))*SizeAtCompileTime)%16)==0 };
00154 EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign)
00155
00156 using Base::base;
00157 using Base::coeffRef;
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167 EIGEN_STRONG_INLINE Matrix& operator=(const Matrix& other)
00168 {
00169 return Base::_set(other);
00170 }
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182 template<typename OtherDerived>
00183 EIGEN_STRONG_INLINE Matrix& operator=(const MatrixBase<OtherDerived>& other)
00184 {
00185 return Base::_set(other);
00186 }
00187
00188
00189
00190
00191
00192
00193
00194 template<typename OtherDerived>
00195 EIGEN_STRONG_INLINE Matrix& operator=(const EigenBase<OtherDerived> &other)
00196 {
00197 return Base::operator=(other);
00198 }
00199
00200 template<typename OtherDerived>
00201 EIGEN_STRONG_INLINE Matrix& operator=(const ReturnByValue<OtherDerived>& func)
00202 {
00203 return Base::operator=(func);
00204 }
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216 EIGEN_STRONG_INLINE explicit Matrix() : Base()
00217 {
00218 Base::_check_template_params();
00219 EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED
00220 }
00221
00222
00223 Matrix(internal::constructor_without_unaligned_array_assert)
00224 : Base(internal::constructor_without_unaligned_array_assert())
00225 { Base::_check_template_params(); EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED }
00226
00227
00228
00229
00230
00231
00232
00233 EIGEN_STRONG_INLINE explicit Matrix(Index dim)
00234 : Base(dim, RowsAtCompileTime == 1 ? 1 : dim, ColsAtCompileTime == 1 ? 1 : dim)
00235 {
00236 Base::_check_template_params();
00237 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Matrix)
00238 eigen_assert(dim > 0);
00239 eigen_assert(SizeAtCompileTime == Dynamic || SizeAtCompileTime == dim);
00240 EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED
00241 }
00242
00243 #ifndef EIGEN_PARSED_BY_DOXYGEN
00244 template<typename T0, typename T1>
00245 EIGEN_STRONG_INLINE Matrix(const T0& x, const T1& y)
00246 {
00247 Base::_check_template_params();
00248 Base::template _init2<T0,T1>(x, y);
00249 }
00250 #else
00251
00252
00253
00254
00255
00256 Matrix(Index rows, Index cols);
00257
00258 Matrix(const Scalar& x, const Scalar& y);
00259 #endif
00260
00261
00262 EIGEN_STRONG_INLINE Matrix(const Scalar& x, const Scalar& y, const Scalar& z)
00263 {
00264 Base::_check_template_params();
00265 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Matrix, 3)
00266 m_storage.data()[0] = x;
00267 m_storage.data()[1] = y;
00268 m_storage.data()[2] = z;
00269 }
00270
00271 EIGEN_STRONG_INLINE Matrix(const Scalar& x, const Scalar& y, const Scalar& z, const Scalar& w)
00272 {
00273 Base::_check_template_params();
00274 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Matrix, 4)
00275 m_storage.data()[0] = x;
00276 m_storage.data()[1] = y;
00277 m_storage.data()[2] = z;
00278 m_storage.data()[3] = w;
00279 }
00280
00281 explicit Matrix(const Scalar *data);
00282
00283
00284 template<typename OtherDerived>
00285 EIGEN_STRONG_INLINE Matrix(const MatrixBase<OtherDerived>& other)
00286 : Base(other.rows() * other.cols(), other.rows(), other.cols())
00287 {
00288 Base::_check_template_params();
00289 Base::_set_noalias(other);
00290 }
00291
00292 EIGEN_STRONG_INLINE Matrix(const Matrix& other)
00293 : Base(other.rows() * other.cols(), other.rows(), other.cols())
00294 {
00295 Base::_check_template_params();
00296 Base::_set_noalias(other);
00297 }
00298
00299 template<typename OtherDerived>
00300 EIGEN_STRONG_INLINE Matrix(const ReturnByValue<OtherDerived>& other)
00301 {
00302 Base::_check_template_params();
00303 Base::resize(other.rows(), other.cols());
00304 other.evalTo(*this);
00305 }
00306
00307
00308
00309
00310 template<typename OtherDerived>
00311 EIGEN_STRONG_INLINE Matrix(const EigenBase<OtherDerived> &other)
00312 : Base(other.derived().rows() * other.derived().cols(), other.derived().rows(), other.derived().cols())
00313 {
00314 Base::_check_template_params();
00315 Base::resize(other.rows(), other.cols());
00316
00317
00318 *this = other;
00319 }
00320
00321
00322
00323
00324
00325 template<typename OtherDerived>
00326 void swap(MatrixBase<OtherDerived> const & other)
00327 { this->_swap(other.derived()); }
00328
00329 inline Index innerStride() const { return 1; }
00330 inline Index outerStride() const { return this->innerSize(); }
00331
00332
00333
00334 template<typename OtherDerived>
00335 explicit Matrix(const RotationBase<OtherDerived,ColsAtCompileTime>& r);
00336 template<typename OtherDerived>
00337 Matrix& operator=(const RotationBase<OtherDerived,ColsAtCompileTime>& r);
00338
00339
00340 #ifdef EIGEN_MATRIX_PLUGIN
00341 #include EIGEN_MATRIX_PLUGIN
00342 #endif
00343
00344 protected:
00345 template <typename Derived, typename OtherDerived, bool IsVector>
00346 friend struct internal::conservative_resize_like_impl;
00347
00348 using Base::m_storage;
00349 };
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371 #define EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix) \
00372 \
00373 typedef Matrix<Type, Size, Size> Matrix##SizeSuffix##TypeSuffix; \
00374 \
00375 typedef Matrix<Type, Size, 1> Vector##SizeSuffix##TypeSuffix; \
00376 \
00377 typedef Matrix<Type, 1, Size> RowVector##SizeSuffix##TypeSuffix;
00378
00379 #define EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, Size) \
00380 \
00381 typedef Matrix<Type, Size, Dynamic> Matrix##Size##X##TypeSuffix; \
00382 \
00383 typedef Matrix<Type, Dynamic, Size> Matrix##X##Size##TypeSuffix;
00384
00385 #define EIGEN_MAKE_TYPEDEFS_ALL_SIZES(Type, TypeSuffix) \
00386 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 2, 2) \
00387 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 3, 3) \
00388 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 4, 4) \
00389 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Dynamic, X) \
00390 EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 2) \
00391 EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 3) \
00392 EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 4)
00393
00394 EIGEN_MAKE_TYPEDEFS_ALL_SIZES(int, i)
00395 EIGEN_MAKE_TYPEDEFS_ALL_SIZES(float, f)
00396 EIGEN_MAKE_TYPEDEFS_ALL_SIZES(double, d)
00397 EIGEN_MAKE_TYPEDEFS_ALL_SIZES(std::complex<float>, cf)
00398 EIGEN_MAKE_TYPEDEFS_ALL_SIZES(std::complex<double>, cd)
00399
00400 #undef EIGEN_MAKE_TYPEDEFS_ALL_SIZES
00401 #undef EIGEN_MAKE_TYPEDEFS
00402
00403 #undef EIGEN_MAKE_TYPEDEFS_LARGE
00404
00405 #define EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, SizeSuffix) \
00406 using Eigen::Matrix##SizeSuffix##TypeSuffix; \
00407 using Eigen::Vector##SizeSuffix##TypeSuffix; \
00408 using Eigen::RowVector##SizeSuffix##TypeSuffix;
00409
00410 #define EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(TypeSuffix) \
00411 EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 2) \
00412 EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 3) \
00413 EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 4) \
00414 EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, X) \
00415
00416 #define EIGEN_USING_MATRIX_TYPEDEFS \
00417 EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(i) \
00418 EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(f) \
00419 EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(d) \
00420 EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(cf) \
00421 EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(cd)
00422
00423 #endif // EIGEN_MATRIX_H