aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2008-01-03 19:36:32 +0000
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2008-01-03 19:36:32 +0000
commit23ffede3d0d280962bad418a41957cf82e3fadc9 (patch)
treea6dacc6b06f39b19d342664d2b73a6de3b0d424b /Eigen
parent42f6590bb26d77bfa67f57c64ff9cc6d38e23f58 (diff)
more documentation, 12 more code snippets
Diffstat (limited to 'Eigen')
-rw-r--r--Eigen/Core2
-rw-r--r--Eigen/src/Core/IO.h4
-rw-r--r--Eigen/src/Core/Map.h42
-rw-r--r--Eigen/src/Core/Matrix.h1
-rw-r--r--Eigen/src/Core/Ones.h46
-rw-r--r--Eigen/src/Core/Random.h47
-rw-r--r--Eigen/src/Core/Zero.h46
7 files changed, 187 insertions, 1 deletions
diff --git a/Eigen/Core b/Eigen/Core
index 0689921a9..e046c2dff 100644
--- a/Eigen/Core
+++ b/Eigen/Core
@@ -1,6 +1,6 @@
-#include <iostream>
#include <complex>
#include <cassert>
+#include <iostream>
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<typename Scalar, typename Derived>
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<typename MatrixType> class Map
: public MatrixBase<typename MatrixType::Scalar, Map<MatrixType> >
{
@@ -75,6 +88,7 @@ template<typename MatrixType> class Map
int m_rows, m_cols;
};
+/** This is the const version of map(Scalar*,int,int). */
template<typename _Scalar, int _Rows, int _Cols, MatrixStorageOrder _StorageOrder>
const Map<Matrix<_Scalar, _Rows, _Cols, _StorageOrder> >
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<Matrix>(data, rows, cols);
}
+/** This is the const version of map(Scalar*,int). */
template<typename _Scalar, int _Rows, int _Cols, MatrixStorageOrder _StorageOrder>
const Map<Matrix<_Scalar, _Rows, _Cols, _StorageOrder> >
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<Matrix>(data, 1, size);
}
+/** This is the const version of map(Scalar*). */
template<typename _Scalar, int _Rows, int _Cols, MatrixStorageOrder _StorageOrder>
const Map<Matrix<_Scalar, _Rows, _Cols, _StorageOrder> >
Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(const Scalar* data)
@@ -100,6 +116,15 @@ Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(const Scalar* data)
return Map<Matrix>(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<typename _Scalar, int _Rows, int _Cols, MatrixStorageOrder _StorageOrder>
Map<Matrix<_Scalar, _Rows, _Cols, _StorageOrder> >
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<Matrix>(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<typename _Scalar, int _Rows, int _Cols, MatrixStorageOrder _StorageOrder>
Map<Matrix<_Scalar, _Rows, _Cols, _StorageOrder> >
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<Matrix>(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<typename _Scalar, int _Rows, int _Cols, MatrixStorageOrder _StorageOrder>
Map<Matrix<_Scalar, _Rows, _Cols, _StorageOrder> >
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<typename _Scalar, int _Rows, int _Cols,
MatrixStorageOrder _StorageOrder = EIGEN_DEFAULT_MATRIX_STORAGE_ORDER>
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<typename MatrixType> class Ones : NoOperatorEquals,
public MatrixBase<typename MatrixType::Scalar, Ones<MatrixType> >
{
@@ -59,12 +65,42 @@ template<typename MatrixType> 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<typename Scalar, typename Derived>
const Ones<Derived> MatrixBase<Scalar, Derived>::ones(int rows, int cols)
{
return Ones<Derived>(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<typename Scalar, typename Derived>
const Ones<Derived> MatrixBase<Scalar, Derived>::ones(int size)
{
@@ -73,6 +109,16 @@ const Ones<Derived> MatrixBase<Scalar, Derived>::ones(int size)
else return Ones<Derived>(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<typename Scalar, typename Derived>
const Ones<Derived> MatrixBase<Scalar, Derived>::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<typename MatrixType> class Random : NoOperatorEquals,
public MatrixBase<typename MatrixType::Scalar, Random<MatrixType> >
{
@@ -59,12 +65,42 @@ template<typename MatrixType> 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<typename Scalar, typename Derived>
const Eval<Random<Derived> > MatrixBase<Scalar, Derived>::random(int rows, int cols)
{
return Random<Derived>(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<typename Scalar, typename Derived>
const Eval<Random<Derived> > MatrixBase<Scalar, Derived>::random(int size)
{
@@ -73,6 +109,17 @@ const Eval<Random<Derived> > MatrixBase<Scalar, Derived>::random(int size)
else return Random<Derived>(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<typename Scalar, typename Derived>
const Eval<Random<Derived> > MatrixBase<Scalar, Derived>::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<typename MatrixType> class Zero : NoOperatorEquals,
public MatrixBase<typename MatrixType::Scalar, Zero<MatrixType> >
{
@@ -59,12 +65,42 @@ template<typename MatrixType> 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<typename Scalar, typename Derived>
const Zero<Derived> MatrixBase<Scalar, Derived>::zero(int rows, int cols)
{
return Zero<Derived>(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<typename Scalar, typename Derived>
const Zero<Derived> MatrixBase<Scalar, Derived>::zero(int size)
{
@@ -73,6 +109,16 @@ const Zero<Derived> MatrixBase<Scalar, Derived>::zero(int size)
else return Zero<Derived>(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<typename Scalar, typename Derived>
const Zero<Derived> MatrixBase<Scalar, Derived>::zero()
{