more documentation, 12 more code snippets

This commit is contained in:
Benoit Jacob
2008-01-03 19:36:32 +00:00
parent 42f6590bb2
commit 23ffede3d0
20 changed files with 216 additions and 2 deletions

View File

@@ -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()
{