diff --git a/Eigen/Core b/Eigen/Core index 0689921a9..e046c2dff 100644 --- a/Eigen/Core +++ b/Eigen/Core @@ -1,6 +1,6 @@ -#include #include #include +#include namespace Eigen { diff --git a/Eigen/src/Core/IO.h b/Eigen/src/Core/IO.h index 0aa8f22f7..feb2a24a0 100644 --- a/Eigen/src/Core/IO.h +++ b/Eigen/src/Core/IO.h @@ -26,6 +26,10 @@ #ifndef EIGEN_IO_H #define EIGEN_IO_H +/** \relates MatrixBase + * + * Outputs the matrix, laid out as an array as usual, to the given stream. + */ template std::ostream & operator << ( std::ostream & s, diff --git a/Eigen/src/Core/Map.h b/Eigen/src/Core/Map.h index 4558d329d..2e3a4838f 100644 --- a/Eigen/src/Core/Map.h +++ b/Eigen/src/Core/Map.h @@ -26,6 +26,19 @@ #ifndef EIGEN_MAP_H #define EIGEN_MAP_H +/** \class Map + * + * \brief A matrix or vector expression mapping an existing array of data. + * + * This class represents a matrix or vector expression mapping an existing array of data. + * 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() and most of the time this is the only + * way it is used. + * + * \sa Matrix::map() + */ template class Map : public MatrixBase > { @@ -75,6 +88,7 @@ template class Map int m_rows, m_cols; }; +/** This is the const version of map(Scalar*,int,int). */ template const Map > Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(const Scalar* data, int rows, int cols) @@ -82,6 +96,7 @@ Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(const Scalar* data, int rows, return Map(data, rows, cols); } +/** This is the const version of map(Scalar*,int). */ template const Map > Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(const Scalar* data, int size) @@ -93,6 +108,7 @@ Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(const Scalar* data, int size) return Map(data, 1, size); } +/** This is the const version of map(Scalar*). */ template const Map > Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(const Scalar* data) @@ -100,6 +116,15 @@ Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(const Scalar* data) return Map(data, _Rows, _Cols); } +/** \returns a expression of a matrix or vector mapping the given data. + * + * \param data The array of data to map + * \param rows The number of rows of the expression to construct + * \param cols The number of columns of the expression to construct + * + * Example: \include MatrixBase_map_int_int.cpp + * Output: \verbinclude MatrixBase_map_int_int.out + */ template Map > Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(Scalar* data, int rows, int cols) @@ -107,6 +132,16 @@ Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(Scalar* data, int rows, int co return Map(data, rows, cols); } +/** \returns a expression of a vector mapping the given data. + * + * \param data The array of data to map + * \param rows The size (number of coefficients) of the expression to construct + * + * \only_for_vectors + * + * Example: \include MatrixBase_map_int.cpp + * Output: \verbinclude MatrixBase_map_int.out + */ template Map > Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(Scalar* data, int size) @@ -118,6 +153,13 @@ Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(Scalar* data, int size) return Map(data, 1, size); } +/** \returns a expression of a fixed-size matrix or vector mapping the given data. + * + * \param data The array of data to map + * + * Example: \include MatrixBase_map.cpp + * Output: \verbinclude MatrixBase_map.out + */ template Map > Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(Scalar* data) diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h index 812691156..149d2cdca 100644 --- a/Eigen/src/Core/Matrix.h +++ b/Eigen/src/Core/Matrix.h @@ -26,6 +26,7 @@ #ifndef EIGEN_MATRIX_H #define EIGEN_MATRIX_H +/** \class Matrix */ template class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols, _StorageOrder> >, diff --git a/Eigen/src/Core/Ones.h b/Eigen/src/Core/Ones.h index 4aedb7f0f..cf421f686 100644 --- a/Eigen/src/Core/Ones.h +++ b/Eigen/src/Core/Ones.h @@ -26,6 +26,12 @@ #ifndef EIGEN_ONES_H #define EIGEN_ONES_H +/** \class Ones + * + * \brief Expression of a matrix where all coefficients equal one. + * + * \sa MatrixBase::ones(), MatrixBase::ones(int), MatrixBase::ones(int,int) + */ template class Ones : NoOperatorEquals, public MatrixBase > { @@ -59,12 +65,42 @@ template class Ones : NoOperatorEquals, int m_rows, m_cols; }; +/** \returns an expression of a matrix where all coefficients equal one. + * + * The parameters \a rows and \a cols are the number of rows and of columns of + * the returned matrix. Must be compatible with this MatrixBase type. + * + * This variant is meant to be used for dynamic-size matrix types. For fixed-size types, + * it is redundant to pass \a rows and \a cols as arguments, so ones() should be used + * instead. + * + * Example: \include MatrixBase_ones_int_int.cpp + * Output: \verbinclude MatrixBase_ones_int_int.out + * + * \sa ones(), ones(int) + */ template const Ones MatrixBase::ones(int rows, int cols) { return Ones(rows, cols); } +/** \returns an expression of a vector where all coefficients equal one. + * + * The parameter \a size is the size of the returned vector. + * Must be compatible with this MatrixBase type. + * + * \only_for_vectors + * + * This variant is meant to be used for dynamic-size vector types. For fixed-size types, + * it is redundant to pass \a size as argument, so ones() should be used + * instead. + * + * Example: \include MatrixBase_ones_int.cpp + * Output: \verbinclude MatrixBase_ones_int.out + * + * \sa ones(), ones(int,int) + */ template const Ones MatrixBase::ones(int size) { @@ -73,6 +109,16 @@ const Ones MatrixBase::ones(int size) else return Ones(size, 1); } +/** \returns an expression of a fixed-size matrix or vector where all coefficients equal one. + * + * This variant is only for fixed-size MatrixBase types. For dynamic-size types, you + * need to use the variants taking size arguments. + * + * Example: \include MatrixBase_ones.cpp + * Output: \verbinclude MatrixBase_ones.out + * + * \sa ones(int), ones(int,int) + */ template const Ones MatrixBase::ones() { diff --git a/Eigen/src/Core/Random.h b/Eigen/src/Core/Random.h index 6e672709c..ef07bfa43 100644 --- a/Eigen/src/Core/Random.h +++ b/Eigen/src/Core/Random.h @@ -26,6 +26,12 @@ #ifndef EIGEN_RANDOM_H #define EIGEN_RANDOM_H +/** \class Random + * + * \brief Expression of a random matrix or vector. + * + * \sa MatrixBase::random(), MatrixBase::random(int), MatrixBase::random(int,int) + */ template class Random : NoOperatorEquals, public MatrixBase > { @@ -59,12 +65,42 @@ template class Random : NoOperatorEquals, int m_rows, m_cols; }; +/** \returns a random matrix (not an expression, the matrix is immediately evaluated). + * + * The parameters \a rows and \a cols are the number of rows and of columns of + * the returned matrix. Must be compatible with this MatrixBase type. + * + * This variant is meant to be used for dynamic-size matrix types. For fixed-size types, + * it is redundant to pass \a rows and \a cols as arguments, so random() should be used + * instead. + * + * Example: \include MatrixBase_random_int_int.cpp + * Output: \verbinclude MatrixBase_random_int_int.out + * + * \sa random(), random(int) + */ template const Eval > MatrixBase::random(int rows, int cols) { return Random(rows, cols).eval(); } +/** \returns a random vector (not an expression, the vector is immediately evaluated). + * + * The parameter \a size is the size of the returned vector. + * Must be compatible with this MatrixBase type. + * + * \only_for_vectors + * + * This variant is meant to be used for dynamic-size vector types. For fixed-size types, + * it is redundant to pass \a size as argument, so random() should be used + * instead. + * + * Example: \include MatrixBase_random_int.cpp + * Output: \verbinclude MatrixBase_random_int.out + * + * \sa random(), random(int,int) + */ template const Eval > MatrixBase::random(int size) { @@ -73,6 +109,17 @@ const Eval > MatrixBase::random(int size) else return Random(size, 1).eval(); } +/** \returns a fixed-size random matrix or vector + * (not an expression, the matrix is immediately evaluated). + * + * This variant is only for fixed-size MatrixBase types. For dynamic-size types, you + * need to use the variants taking size arguments. + * + * Example: \include MatrixBase_random.cpp + * Output: \verbinclude MatrixBase_random.out + * + * \sa random(int), random(int,int) + */ template const Eval > MatrixBase::random() { diff --git a/Eigen/src/Core/Zero.h b/Eigen/src/Core/Zero.h index aad2f382d..533e1e0f1 100644 --- a/Eigen/src/Core/Zero.h +++ b/Eigen/src/Core/Zero.h @@ -26,6 +26,12 @@ #ifndef EIGEN_ZERO_H #define EIGEN_ZERO_H +/** \class Zero + * + * \brief Expression of a zero matrix or vector. + * + * \sa MatrixBase::zero(), MatrixBase::zero(int), MatrixBase::zero(int,int) + */ template class Zero : NoOperatorEquals, public MatrixBase > { @@ -59,12 +65,42 @@ template class Zero : NoOperatorEquals, int m_rows, m_cols; }; +/** \returns an expression of a zero matrix. + * + * The parameters \a rows and \a cols are the number of rows and of columns of + * the returned matrix. Must be compatible with this MatrixBase type. + * + * This variant is meant to be used for dynamic-size matrix types. For fixed-size types, + * it is redundant to pass \a rows and \a cols as arguments, so zero() should be used + * instead. + * + * Example: \include MatrixBase_zero_int_int.cpp + * Output: \verbinclude MatrixBase_zero_int_int.out + * + * \sa zero(), zero(int) + */ template const Zero MatrixBase::zero(int rows, int cols) { return Zero(rows, cols); } +/** \returns an expression of a zero vector. + * + * The parameter \a size is the size of the returned vector. + * Must be compatible with this MatrixBase type. + * + * \only_for_vectors + * + * This variant is meant to be used for dynamic-size vector types. For fixed-size types, + * it is redundant to pass \a size as argument, so zero() should be used + * instead. + * + * Example: \include MatrixBase_zero_int.cpp + * Output: \verbinclude MatrixBase_zero_int.out + * + * \sa zero(), zero(int,int) + */ template const Zero MatrixBase::zero(int size) { @@ -73,6 +109,16 @@ const Zero MatrixBase::zero(int size) else return Zero(size, 1); } +/** \returns an expression of a fixed-size zero matrix or vector. + * + * This variant is only for fixed-size MatrixBase types. For dynamic-size types, you + * need to use the variants taking size arguments. + * + * Example: \include MatrixBase_zero.cpp + * Output: \verbinclude MatrixBase_zero.out + * + * \sa zero(int), zero(int,int) + */ template const Zero MatrixBase::zero() { diff --git a/doc/snippets/MatrixBase_map.cpp b/doc/snippets/MatrixBase_map.cpp new file mode 100644 index 000000000..1655c542e --- /dev/null +++ b/doc/snippets/MatrixBase_map.cpp @@ -0,0 +1,5 @@ +int data[4] = {1,3,0,2}; +cout << Matrix2i::map(data) << endl; +Matrix2i::map(data) *= 2; +cout << "The data is now:" << endl; +for(int i = 0; i < 4; i++) cout << data[i] << endl; \ No newline at end of file diff --git a/doc/snippets/MatrixBase_map_int.cpp b/doc/snippets/MatrixBase_map_int.cpp new file mode 100644 index 000000000..066e54773 --- /dev/null +++ b/doc/snippets/MatrixBase_map_int.cpp @@ -0,0 +1,5 @@ +int data[4] = {1,3,0,2}; +cout << VectorXi::map(data, 4) << endl; +VectorXi::map(data, 4) *= 2; +cout << "The data is now:" << endl; +for(int i = 0; i < 4; i++) cout << data[i] << endl; diff --git a/doc/snippets/MatrixBase_map_int_int.cpp b/doc/snippets/MatrixBase_map_int_int.cpp new file mode 100644 index 000000000..516b9e7f9 --- /dev/null +++ b/doc/snippets/MatrixBase_map_int_int.cpp @@ -0,0 +1,5 @@ +int data[4] = {1,3,0,2}; +cout << MatrixXi::map(data, 2, 2) << endl; +MatrixXi::map(data, 2, 2) *= 2; +cout << "The data is now:" << endl; +for(int i = 0; i < 4; i++) cout << data[i] << endl; diff --git a/doc/snippets/MatrixBase_ones.cpp b/doc/snippets/MatrixBase_ones.cpp new file mode 100644 index 000000000..2434f518a --- /dev/null +++ b/doc/snippets/MatrixBase_ones.cpp @@ -0,0 +1,2 @@ +cout << Matrix2d::ones() << endl; +cout << 6 * RowVector4i::ones() << endl; diff --git a/doc/snippets/MatrixBase_ones_int.cpp b/doc/snippets/MatrixBase_ones_int.cpp new file mode 100644 index 000000000..0610bc2f2 --- /dev/null +++ b/doc/snippets/MatrixBase_ones_int.cpp @@ -0,0 +1,2 @@ +cout << 6 * RowVectorXi::ones(4) << endl; +cout << VectorXf::ones(2) << endl; diff --git a/doc/snippets/MatrixBase_ones_int_int.cpp b/doc/snippets/MatrixBase_ones_int_int.cpp new file mode 100644 index 000000000..faecee1af --- /dev/null +++ b/doc/snippets/MatrixBase_ones_int_int.cpp @@ -0,0 +1 @@ +cout << MatrixXi::ones(2,3) << endl; diff --git a/doc/snippets/MatrixBase_random.cpp b/doc/snippets/MatrixBase_random.cpp new file mode 100644 index 000000000..09b5fb2db --- /dev/null +++ b/doc/snippets/MatrixBase_random.cpp @@ -0,0 +1 @@ +cout << 100 * Matrix2i::random() << endl; diff --git a/doc/snippets/MatrixBase_random_int.cpp b/doc/snippets/MatrixBase_random_int.cpp new file mode 100644 index 000000000..a1f609ce0 --- /dev/null +++ b/doc/snippets/MatrixBase_random_int.cpp @@ -0,0 +1 @@ +cout << VectorXi::random(2) << endl; diff --git a/doc/snippets/MatrixBase_random_int_int.cpp b/doc/snippets/MatrixBase_random_int_int.cpp new file mode 100644 index 000000000..235dd4721 --- /dev/null +++ b/doc/snippets/MatrixBase_random_int_int.cpp @@ -0,0 +1 @@ +cout << MatrixXi::random(2,3) << endl; diff --git a/doc/snippets/MatrixBase_transpose.cpp b/doc/snippets/MatrixBase_transpose.cpp index 0a0586d53..342d14a81 100644 --- a/doc/snippets/MatrixBase_transpose.cpp +++ b/doc/snippets/MatrixBase_transpose.cpp @@ -1,4 +1,4 @@ -Matrix2f m = Matrix2f::random(); +Matrix2i m = Matrix2i::random(); cout << "Here is the matrix m:" << endl << m << endl; cout << "Here is the transpose of m:" << endl << m.transpose() << endl; cout << "Here is the coefficient (1,0) in the transpose of m:" << endl diff --git a/doc/snippets/MatrixBase_zero.cpp b/doc/snippets/MatrixBase_zero.cpp new file mode 100644 index 000000000..8b4af04a9 --- /dev/null +++ b/doc/snippets/MatrixBase_zero.cpp @@ -0,0 +1,2 @@ +cout << Matrix2d::zero() << endl; +cout << RowVector4i::zero() << endl; diff --git a/doc/snippets/MatrixBase_zero_int.cpp b/doc/snippets/MatrixBase_zero_int.cpp new file mode 100644 index 000000000..4ef99edeb --- /dev/null +++ b/doc/snippets/MatrixBase_zero_int.cpp @@ -0,0 +1,2 @@ +cout << RowVectorXi::zero(4) << endl; +cout << VectorXf::zero(2) << endl; diff --git a/doc/snippets/MatrixBase_zero_int_int.cpp b/doc/snippets/MatrixBase_zero_int_int.cpp new file mode 100644 index 000000000..b108c763b --- /dev/null +++ b/doc/snippets/MatrixBase_zero_int_int.cpp @@ -0,0 +1 @@ +cout << MatrixXi::zero(2,3) << endl;