mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-09 18:29:03 +08:00
Improve the "map" API and corresponding Matrix constructors
This commit is contained in:
parent
a32690a222
commit
3380429e3a
@ -66,7 +66,23 @@ template<typename MatrixType> class Map
|
||||
template<typename Scalar, typename Derived>
|
||||
Map<Derived> MatrixBase<Scalar, Derived>::map(const Scalar* data, int rows, int cols)
|
||||
{
|
||||
return Map<Derived>(const_cast<Scalar*>(data),rows, cols);
|
||||
return Map<Derived>(const_cast<Scalar*>(data), rows, cols);
|
||||
}
|
||||
|
||||
template<typename Scalar, typename Derived>
|
||||
Map<Derived> MatrixBase<Scalar, Derived>::map(const Scalar* data, int size)
|
||||
{
|
||||
assert(IsVector);
|
||||
if(ColsAtCompileTime == 1)
|
||||
return Map<Derived>(const_cast<Scalar*>(data), size, 1);
|
||||
else
|
||||
return Map<Derived>(const_cast<Scalar*>(data), 1, size);
|
||||
}
|
||||
|
||||
template<typename Scalar, typename Derived>
|
||||
Map<Derived> MatrixBase<Scalar, Derived>::map(const Scalar* data)
|
||||
{
|
||||
return Map<Derived>(const_cast<Scalar*>(data), RowsAtCompileTime, ColsAtCompileTime);
|
||||
}
|
||||
|
||||
template<typename _Scalar, int _Rows, int _Cols>
|
||||
@ -74,7 +90,23 @@ Matrix<_Scalar, _Rows, _Cols>
|
||||
::Matrix(const Scalar *data, int rows, int cols)
|
||||
: Storage(rows, cols)
|
||||
{
|
||||
*this = Map<Matrix>(const_cast<Scalar*>(data), rows, cols);
|
||||
*this = map(data, rows, cols);
|
||||
}
|
||||
|
||||
template<typename _Scalar, int _Rows, int _Cols>
|
||||
Matrix<_Scalar, _Rows, _Cols>
|
||||
::Matrix(const Scalar *data, int size)
|
||||
: Storage(size)
|
||||
{
|
||||
*this = map(data, size);
|
||||
}
|
||||
|
||||
template<typename _Scalar, int _Rows, int _Cols>
|
||||
Matrix<_Scalar, _Rows, _Cols>
|
||||
::Matrix(const Scalar *data)
|
||||
: Storage()
|
||||
{
|
||||
*this = map(data);
|
||||
}
|
||||
|
||||
#endif // EIGEN_FROMARRAY_H
|
||||
|
@ -144,8 +144,9 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols> >,
|
||||
(Storage::m_data)[2] = z;
|
||||
(Storage::m_data)[3] = w;
|
||||
}
|
||||
explicit Matrix(const Scalar *data, int rows = RowsAtCompileTime,
|
||||
int cols = ColsAtCompileTime);
|
||||
Matrix(const Scalar *data, int rows, int cols);
|
||||
Matrix(const Scalar *data, int size);
|
||||
explicit Matrix(const Scalar *data);
|
||||
|
||||
template<typename OtherDerived>
|
||||
Matrix(const MatrixBase<Scalar, OtherDerived>& other)
|
||||
|
@ -95,8 +95,9 @@ template<typename Scalar, typename Derived> class MatrixBase
|
||||
diagonal(const OtherDerived& coeffs);
|
||||
DiagonalCoeffs<Derived> diagonal() const;
|
||||
|
||||
static Map<Derived>
|
||||
map(const Scalar* array, int rows = RowsAtCompileTime, int cols = ColsAtCompileTime);
|
||||
static Map<Derived> map(const Scalar* array, int rows, int cols);
|
||||
static Map<Derived> map(const Scalar* array, int size);
|
||||
static Map<Derived> map(const Scalar* array);
|
||||
|
||||
template<typename OtherDerived>
|
||||
bool isApprox(
|
||||
|
Loading…
x
Reference in New Issue
Block a user