aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/Matrix.h
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2008-06-27 01:22:35 +0000
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2008-06-27 01:22:35 +0000
commite27b2b95cf566201810aa9f831c52bed3314d927 (patch)
treed41831d1e9353d3867bc9afa91a0598ddd2c2e4d /Eigen/src/Core/Matrix.h
parente5d301dc961ddfaba6e38c497904b2aee378a7cc (diff)
* rework Map, allow vectorization
* rework PacketMath and DummyPacketMath, make these actual template specializations instead of just overriding by non-template inline functions * introduce ei_ploadt and ei_pstoret, make use of them in Map and Matrix * remove Matrix::map() methods, use Map constructors instead.
Diffstat (limited to 'Eigen/src/Core/Matrix.h')
-rw-r--r--Eigen/src/Core/Matrix.h50
1 files changed, 13 insertions, 37 deletions
diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h
index f00a27b33..bf4b8d739 100644
--- a/Eigen/src/Core/Matrix.h
+++ b/Eigen/src/Core/Matrix.h
@@ -102,12 +102,13 @@ class Matrix : public MatrixBase<Matrix<_Scalar, _Rows, _Cols, _MaxRows, _MaxCol
{
public:
EIGEN_GENERIC_PUBLIC_INTERFACE(Matrix)
+ friend class Eigen::Map<Matrix, Unaligned>;
+ friend class Eigen::Map<Matrix, Aligned>;
protected:
ei_matrix_storage<Scalar, MaxSizeAtCompileTime, RowsAtCompileTime, ColsAtCompileTime> m_storage;
public:
- friend class Map<Matrix>;
inline int rows() const { return m_storage.rows(); }
inline int cols() const { return m_storage.cols(); }
@@ -149,50 +150,31 @@ class Matrix : public MatrixBase<Matrix<_Scalar, _Rows, _Cols, _MaxRows, _MaxCol
template<int LoadMode>
inline PacketScalar packet(int row, int col) const
{
- if(Flags & RowMajorBit)
- if (LoadMode==Aligned)
- return ei_pload(m_storage.data() + col + row * m_storage.cols());
- else
- return ei_ploadu(m_storage.data() + col + row * m_storage.cols());
- else
- if (LoadMode==Aligned)
- return ei_pload(m_storage.data() + row + col * m_storage.rows());
- else
- return ei_ploadu(m_storage.data() + row + col * m_storage.rows());
+ return ei_ploadt<Scalar, LoadMode>
+ (m_storage.data() + (Flags & RowMajorBit
+ ? col + row * m_storage.cols()
+ : row + col * m_storage.rows()));
}
template<int LoadMode>
inline PacketScalar packet(int index) const
{
- if (LoadMode==Aligned)
- return ei_pload(m_storage.data() + index);
- else
- return ei_ploadu(m_storage.data() + index);
+ return ei_ploadt<Scalar, LoadMode>(m_storage.data() + index);
}
template<int StoreMode>
inline void writePacket(int row, int col, const PacketScalar& x)
{
- ei_internal_assert(Flags & PacketAccessBit);
- if(Flags & RowMajorBit)
- if (StoreMode==Aligned)
- ei_pstore(m_storage.data() + col + row * m_storage.cols(), x);
- else
- ei_pstoreu(m_storage.data() + col + row * m_storage.cols(), x);
- else
- if (StoreMode==Aligned)
- ei_pstore(m_storage.data() + row + col * m_storage.rows(), x);
- else
- ei_pstoreu(m_storage.data() + row + col * m_storage.rows(), x);
+ ei_pstoret<Scalar, PacketScalar, StoreMode>
+ (m_storage.data() + (Flags & RowMajorBit
+ ? col + row * m_storage.cols()
+ : row + col * m_storage.rows()), x);
}
template<int StoreMode>
inline void writePacket(int index, const PacketScalar& x)
{
- if (StoreMode==Aligned)
- ei_pstore(m_storage.data() + index, x);
- else
- ei_pstoreu(m_storage.data() + index, x);
+ ei_pstoret<Scalar, PacketScalar, StoreMode>(m_storage.data() + index, x);
}
public:
@@ -253,19 +235,13 @@ class Matrix : public MatrixBase<Matrix<_Scalar, _Rows, _Cols, _MaxRows, _MaxCol
EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Matrix, *=)
EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Matrix, /=)
- static const Map<Matrix> map(const Scalar* array, int rows, int cols);
- static const Map<Matrix> map(const Scalar* array, int size);
- static const Map<Matrix> map(const Scalar* array);
- static Map<Matrix> map(Scalar* array, int rows, int cols);
- static Map<Matrix> map(Scalar* array, int size);
- static Map<Matrix> map(Scalar* array);
-
/** Default constructor, does nothing. Only for fixed-size matrices.
* For dynamic-size matrices and vectors, this constructor is forbidden (guarded by
* an assertion) because it would leave the matrix without an allocated data buffer.
*/
inline explicit Matrix()
{
+ ei_assert(RowsAtCompileTime != Dynamic && ColsAtCompileTime != Dynamic);
ei_assert(RowsAtCompileTime > 0 && ColsAtCompileTime > 0);
}