aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2008-11-03 21:49:03 +0000
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2008-11-03 21:49:03 +0000
commita0ec0fca5ae4469e516b15910c80af5a46073cbe (patch)
tree2414073168ec42cb23c32b983af2e29912f3f651 /Eigen
parent3d90c139706daccce577f5f2960ceb98a42871a3 (diff)
Add Matrix::Map() and Matrix::AlignedMap() static methods
Diffstat (limited to 'Eigen')
-rw-r--r--Eigen/src/Core/Map.h8
-rw-r--r--Eigen/src/Core/Matrix.h41
2 files changed, 43 insertions, 6 deletions
diff --git a/Eigen/src/Core/Map.h b/Eigen/src/Core/Map.h
index 7dfaac273..99061f77f 100644
--- a/Eigen/src/Core/Map.h
+++ b/Eigen/src/Core/Map.h
@@ -40,9 +40,9 @@
* It can be used to let Eigen interface without any overhead with non-Eigen data structures,
* such as plain C arrays or structures from other libraries.
*
- * This class is the return type of Matrix::map() but can also be used directly.
+ * This class is the return type of Matrix::Map() but can also be used directly.
*
- * \sa Matrix::map()
+ * \sa Matrix::Map()
*/
template<typename MatrixType, int _PacketAccess>
struct ei_traits<Map<MatrixType, _PacketAccess> > : public ei_traits<MatrixType>
@@ -106,13 +106,13 @@ template<typename MatrixType, int PacketAccess> class Map
* for the dimensions.
*
* \sa Matrix(const Scalar *, int), Matrix(const Scalar *, int, int),
- * Matrix::map(const Scalar *)
+ * Matrix::Map(const Scalar *)
*/
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder, int _MaxRows, int _MaxCols>
inline Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>
::Matrix(const Scalar *data)
{
- *this = Map<Matrix>(data);
+ *this = Eigen::Map<Matrix>(data);
}
#endif // EIGEN_MAP_H
diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h
index 5b95a0a5e..bf579dc9e 100644
--- a/Eigen/src/Core/Matrix.h
+++ b/Eigen/src/Core/Matrix.h
@@ -108,7 +108,9 @@ class Matrix
public:
EIGEN_GENERIC_PUBLIC_INTERFACE(Matrix)
friend class Eigen::Map<Matrix, Unaligned>;
+ typedef class Eigen::Map<Matrix, Unaligned> UnalignedMapType;
friend class Eigen::Map<Matrix, Aligned>;
+ typedef class Eigen::Map<Matrix, Aligned> AlignedMapType;
protected:
ei_matrix_storage<Scalar, MaxSizeAtCompileTime, RowsAtCompileTime, ColsAtCompileTime> m_storage;
@@ -406,7 +408,7 @@ class Matrix
/** Override MatrixBase::eval() since matrices don't need to be evaluated, it is enough to just read them.
* This prevents a useless copy when doing e.g. "m1 = m2.eval()"
*/
- const Matrix& eval() const
+ inline const Matrix& eval() const
{
return *this;
}
@@ -414,7 +416,7 @@ class Matrix
/** Override MatrixBase::swap() since for dynamic-sized matrices of same type it is enough to swap the
* data pointers.
*/
- void swap(Matrix& other)
+ inline void swap(Matrix& other)
{
if (Base::SizeAtCompileTime==Dynamic)
m_storage.swap(other.m_storage);
@@ -422,6 +424,41 @@ class Matrix
this->Base::swap(other);
}
+ /**
+ * These are convenience functions returning Map objects. The Map() static functions return unaligned Map objects,
+ * while the AlignedMap() functions return aligned Map objects and thus should be called only with 16-byte-aligned
+ * \a data pointers.
+ *
+ * \see class Map
+ */
+ //@}
+ inline static const UnalignedMapType Map(const Scalar* data)
+ { return UnalignedMapType(data); }
+ inline static UnalignedMapType Map(Scalar* data)
+ { return UnalignedMapType(data); }
+ inline static const UnalignedMapType Map(const Scalar* data, int size)
+ { return UnalignedMapType(data, size); }
+ inline static UnalignedMapType Map(Scalar* data, int size)
+ { return UnalignedMapType(data, size); }
+ inline static const UnalignedMapType Map(const Scalar* data, int rows, int cols)
+ { return UnalignedMapType(data, rows, cols); }
+ inline static UnalignedMapType Map(Scalar* data, int rows, int cols)
+ { return UnalignedMapType(data, rows, cols); }
+
+ inline static const AlignedMapType MapAligned(const Scalar* data)
+ { return AlignedMapType(data); }
+ inline static AlignedMapType MapAligned(Scalar* data)
+ { return AlignedMapType(data); }
+ inline static const AlignedMapType MapAligned(const Scalar* data, int size)
+ { return AlignedMapType(data, size); }
+ inline static AlignedMapType MapAligned(Scalar* data, int size)
+ { return AlignedMapType(data, size); }
+ inline static const AlignedMapType MapAligned(const Scalar* data, int rows, int cols)
+ { return AlignedMapType(data, rows, cols); }
+ inline static AlignedMapType MapAligned(Scalar* data, int rows, int cols)
+ { return AlignedMapType(data, rows, cols); }
+ //@}
+
/////////// Geometry module ///////////
template<typename OtherDerived>