Merged eigen/eigen into default

This commit is contained in:
Martinho Fernandes 2014-01-10 11:22:24 +01:00
commit 4c08385b74
11 changed files with 267 additions and 173 deletions

View File

@ -204,7 +204,7 @@ if(NOT MSVC)
option(EIGEN_TEST_NEON "Enable/Disable Neon in tests/examples" OFF) option(EIGEN_TEST_NEON "Enable/Disable Neon in tests/examples" OFF)
if(EIGEN_TEST_NEON) if(EIGEN_TEST_NEON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=neon -mcpu=cortex-a"8) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=neon -mcpu=cortex-a8")
message(STATUS "Enabling NEON in tests/examples") message(STATUS "Enabling NEON in tests/examples")
endif() endif()

View File

@ -138,6 +138,9 @@ DenseBase<Derived>::NullaryExpr(Index rows, Index cols, const CustomNullaryOp& f
* *
* The template parameter \a CustomNullaryOp is the type of the functor. * The template parameter \a CustomNullaryOp is the type of the functor.
* *
* Here is an example with C++11 random generators: \include random_cpp11.cpp
* Output: \verbinclude random_cpp11.out
*
* \sa class CwiseNullaryOp * \sa class CwiseNullaryOp
*/ */
template<typename Derived> template<typename Derived>

View File

@ -34,6 +34,8 @@ struct functor_traits<scalar_random_op<Scalar> >
* The parameters \a rows and \a cols are the number of rows and of columns of * 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. * the returned matrix. Must be compatible with this MatrixBase type.
* *
* \not_reentrant
*
* This variant is meant to be used for dynamic-size matrix types. For fixed-size types, * 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 * it is redundant to pass \a rows and \a cols as arguments, so Random() should be used
* instead. * instead.
@ -46,7 +48,9 @@ struct functor_traits<scalar_random_op<Scalar> >
* a temporary matrix whenever it is nested in a larger expression. This prevents unexpected * a temporary matrix whenever it is nested in a larger expression. This prevents unexpected
* behavior with expressions involving random matrices. * behavior with expressions involving random matrices.
* *
* \sa MatrixBase::setRandom(), MatrixBase::Random(Index), MatrixBase::Random() * See DenseBase::NullaryExpr(Index, const CustomNullaryOp&) for an example using C++11 random generators.
*
* \sa DenseBase::setRandom(), DenseBase::Random(Index), DenseBase::Random()
*/ */
template<typename Derived> template<typename Derived>
inline const CwiseNullaryOp<internal::scalar_random_op<typename internal::traits<Derived>::Scalar>, Derived> inline const CwiseNullaryOp<internal::scalar_random_op<typename internal::traits<Derived>::Scalar>, Derived>
@ -64,6 +68,7 @@ DenseBase<Derived>::Random(Index rows, Index cols)
* Must be compatible with this MatrixBase type. * Must be compatible with this MatrixBase type.
* *
* \only_for_vectors * \only_for_vectors
* \not_reentrant
* *
* This variant is meant to be used for dynamic-size vector types. For fixed-size types, * 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 * it is redundant to pass \a size as argument, so Random() should be used
@ -76,7 +81,7 @@ DenseBase<Derived>::Random(Index rows, Index cols)
* a temporary vector whenever it is nested in a larger expression. This prevents unexpected * a temporary vector whenever it is nested in a larger expression. This prevents unexpected
* behavior with expressions involving random matrices. * behavior with expressions involving random matrices.
* *
* \sa MatrixBase::setRandom(), MatrixBase::Random(Index,Index), MatrixBase::Random() * \sa DenseBase::setRandom(), DenseBase::Random(Index,Index), DenseBase::Random()
*/ */
template<typename Derived> template<typename Derived>
inline const CwiseNullaryOp<internal::scalar_random_op<typename internal::traits<Derived>::Scalar>, Derived> inline const CwiseNullaryOp<internal::scalar_random_op<typename internal::traits<Derived>::Scalar>, Derived>
@ -100,7 +105,9 @@ DenseBase<Derived>::Random(Index size)
* a temporary matrix whenever it is nested in a larger expression. This prevents unexpected * a temporary matrix whenever it is nested in a larger expression. This prevents unexpected
* behavior with expressions involving random matrices. * behavior with expressions involving random matrices.
* *
* \sa MatrixBase::setRandom(), MatrixBase::Random(Index,Index), MatrixBase::Random(Index) * \not_reentrant
*
* \sa DenseBase::setRandom(), DenseBase::Random(Index,Index), DenseBase::Random(Index)
*/ */
template<typename Derived> template<typename Derived>
inline const CwiseNullaryOp<internal::scalar_random_op<typename internal::traits<Derived>::Scalar>, Derived> inline const CwiseNullaryOp<internal::scalar_random_op<typename internal::traits<Derived>::Scalar>, Derived>
@ -114,6 +121,8 @@ DenseBase<Derived>::Random()
* Numbers are uniformly spread through their whole definition range for integer types, * Numbers are uniformly spread through their whole definition range for integer types,
* and in the [-1:1] range for floating point scalar types. * and in the [-1:1] range for floating point scalar types.
* *
* \not_reentrant
*
* Example: \include MatrixBase_setRandom.cpp * Example: \include MatrixBase_setRandom.cpp
* Output: \verbinclude MatrixBase_setRandom.out * Output: \verbinclude MatrixBase_setRandom.out
* *
@ -131,11 +140,12 @@ inline Derived& DenseBase<Derived>::setRandom()
* and in the [-1:1] range for floating point scalar types. * and in the [-1:1] range for floating point scalar types.
* *
* \only_for_vectors * \only_for_vectors
* \not_reentrant
* *
* Example: \include Matrix_setRandom_int.cpp * Example: \include Matrix_setRandom_int.cpp
* Output: \verbinclude Matrix_setRandom_int.out * Output: \verbinclude Matrix_setRandom_int.out
* *
* \sa MatrixBase::setRandom(), setRandom(Index,Index), class CwiseNullaryOp, MatrixBase::Random() * \sa DenseBase::setRandom(), setRandom(Index,Index), class CwiseNullaryOp, DenseBase::Random()
*/ */
template<typename Derived> template<typename Derived>
EIGEN_STRONG_INLINE Derived& EIGEN_STRONG_INLINE Derived&
@ -150,13 +160,15 @@ PlainObjectBase<Derived>::setRandom(Index newSize)
* Numbers are uniformly spread through their whole definition range for integer types, * Numbers are uniformly spread through their whole definition range for integer types,
* and in the [-1:1] range for floating point scalar types. * and in the [-1:1] range for floating point scalar types.
* *
* \not_reentrant
*
* \param nbRows the new number of rows * \param nbRows the new number of rows
* \param nbCols the new number of columns * \param nbCols the new number of columns
* *
* Example: \include Matrix_setRandom_int_int.cpp * Example: \include Matrix_setRandom_int_int.cpp
* Output: \verbinclude Matrix_setRandom_int_int.out * Output: \verbinclude Matrix_setRandom_int_int.out
* *
* \sa MatrixBase::setRandom(), setRandom(Index), class CwiseNullaryOp, MatrixBase::Random() * \sa DenseBase::setRandom(), setRandom(Index), class CwiseNullaryOp, DenseBase::Random()
*/ */
template<typename Derived> template<typename Derived>
EIGEN_STRONG_INLINE Derived& EIGEN_STRONG_INLINE Derived&

View File

@ -194,11 +194,11 @@ public:
* \brief The quaternion class used to represent 3D orientations and rotations * \brief The quaternion class used to represent 3D orientations and rotations
* *
* \tparam _Scalar the scalar type, i.e., the type of the coefficients * \tparam _Scalar the scalar type, i.e., the type of the coefficients
* \tparam _Options controls the memory alignement of the coeffecients. Can be \# AutoAlign or \# DontAlign. Default is AutoAlign. * \tparam _Options controls the memory alignment of the coefficients. Can be \# AutoAlign or \# DontAlign. Default is AutoAlign.
* *
* This class represents a quaternion \f$ w+xi+yj+zk \f$ that is a convenient representation of * This class represents a quaternion \f$ w+xi+yj+zk \f$ that is a convenient representation of
* orientations and rotations of objects in three dimensions. Compared to other representations * orientations and rotations of objects in three dimensions. Compared to other representations
* like Euler angles or 3x3 matrices, quatertions offer the following advantages: * like Euler angles or 3x3 matrices, quaternions offer the following advantages:
* \li \b compact storage (4 scalars) * \li \b compact storage (4 scalars)
* \li \b efficient to compose (28 flops), * \li \b efficient to compose (28 flops),
* \li \b stable spherical interpolation * \li \b stable spherical interpolation
@ -385,7 +385,7 @@ class Map<Quaternion<_Scalar>, _Options >
/** Constructs a Mapped Quaternion object from the pointer \a coeffs /** Constructs a Mapped Quaternion object from the pointer \a coeffs
* *
* The pointer \a coeffs must reference the four coeffecients of Quaternion in the following order: * The pointer \a coeffs must reference the four coefficients of Quaternion in the following order:
* \code *coeffs == {x, y, z, w} \endcode * \code *coeffs == {x, y, z, w} \endcode
* *
* If the template parameter _Options is set to #Aligned, then the pointer coeffs must be aligned. */ * If the template parameter _Options is set to #Aligned, then the pointer coeffs must be aligned. */
@ -399,16 +399,16 @@ class Map<Quaternion<_Scalar>, _Options >
}; };
/** \ingroup Geometry_Module /** \ingroup Geometry_Module
* Map an unaligned array of single precision scalar as a quaternion */ * Map an unaligned array of single precision scalars as a quaternion */
typedef Map<Quaternion<float>, 0> QuaternionMapf; typedef Map<Quaternion<float>, 0> QuaternionMapf;
/** \ingroup Geometry_Module /** \ingroup Geometry_Module
* Map an unaligned array of double precision scalar as a quaternion */ * Map an unaligned array of double precision scalars as a quaternion */
typedef Map<Quaternion<double>, 0> QuaternionMapd; typedef Map<Quaternion<double>, 0> QuaternionMapd;
/** \ingroup Geometry_Module /** \ingroup Geometry_Module
* Map a 16-bits aligned array of double precision scalars as a quaternion */ * Map a 16-byte aligned array of single precision scalars as a quaternion */
typedef Map<Quaternion<float>, Aligned> QuaternionMapAlignedf; typedef Map<Quaternion<float>, Aligned> QuaternionMapAlignedf;
/** \ingroup Geometry_Module /** \ingroup Geometry_Module
* Map a 16-bits aligned array of double precision scalars as a quaternion */ * Map a 16-byte aligned array of double precision scalars as a quaternion */
typedef Map<Quaternion<double>, Aligned> QuaternionMapAlignedd; typedef Map<Quaternion<double>, Aligned> QuaternionMapAlignedd;
/*************************************************************************** /***************************************************************************
@ -579,7 +579,7 @@ inline Derived& QuaternionBase<Derived>::setFromTwoVectors(const MatrixBase<Deri
Scalar c = v1.dot(v0); Scalar c = v1.dot(v0);
// if dot == -1, vectors are nearly opposites // if dot == -1, vectors are nearly opposites
// => accuraletly compute the rotation axis by computing the // => accurately compute the rotation axis by computing the
// intersection of the two planes. This is done by solving: // intersection of the two planes. This is done by solving:
// x^T v0 = 0 // x^T v0 = 0
// x^T v1 = 0 // x^T v1 = 0

View File

@ -251,8 +251,13 @@ void householder_qr_inplace_unblocked(MatrixQR& mat, HCoeffs& hCoeffs, typename
} }
/** \internal */ /** \internal */
template<typename MatrixQR, typename HCoeffs> template<typename MatrixQR, typename HCoeffs,
void householder_qr_inplace_blocked(MatrixQR& mat, HCoeffs& hCoeffs, typename MatrixQRScalar = typename MatrixQR::Scalar,
bool InnerStrideIsOne = (MatrixQR::InnerStrideAtCompileTime == 1 && HCoeffs::InnerStrideAtCompileTime == 1)>
struct householder_qr_inplace_blocked
{
// This is specialized for MKL-supported Scalar types in HouseholderQR_MKL.h
static void run(MatrixQR& mat, HCoeffs& hCoeffs,
typename MatrixQR::Index maxBlockSize=32, typename MatrixQR::Index maxBlockSize=32,
typename MatrixQR::Scalar* tempData = 0) typename MatrixQR::Scalar* tempData = 0)
{ {
@ -301,6 +306,7 @@ void householder_qr_inplace_blocked(MatrixQR& mat, HCoeffs& hCoeffs,
} }
} }
} }
};
template<typename _MatrixType, typename Rhs> template<typename _MatrixType, typename Rhs>
struct solve_retval<HouseholderQR<_MatrixType>, Rhs> struct solve_retval<HouseholderQR<_MatrixType>, Rhs>
@ -352,7 +358,7 @@ HouseholderQR<MatrixType>& HouseholderQR<MatrixType>::compute(const MatrixType&
m_temp.resize(cols); m_temp.resize(cols);
internal::householder_qr_inplace_blocked(m_qr, m_hCoeffs, 48, m_temp.data()); internal::householder_qr_inplace_blocked<MatrixType, HCoeffsType>::run(m_qr, m_hCoeffs, 48, m_temp.data());
m_isInitialized = true; m_isInitialized = true;
return *this; return *this;

View File

@ -34,7 +34,7 @@
#ifndef EIGEN_QR_MKL_H #ifndef EIGEN_QR_MKL_H
#define EIGEN_QR_MKL_H #define EIGEN_QR_MKL_H
#include "Eigen/src/Core/util/MKL_support.h" #include "../Core/util/MKL_support.h"
namespace Eigen { namespace Eigen {
@ -44,18 +44,20 @@ namespace internal {
#define EIGEN_MKL_QR_NOPIV(EIGTYPE, MKLTYPE, MKLPREFIX) \ #define EIGEN_MKL_QR_NOPIV(EIGTYPE, MKLTYPE, MKLPREFIX) \
template<typename MatrixQR, typename HCoeffs> \ template<typename MatrixQR, typename HCoeffs> \
void householder_qr_inplace_blocked(MatrixQR& mat, HCoeffs& hCoeffs, \ struct householder_qr_inplace_blocked<MatrixQR, HCoeffs, EIGTYPE, true> \
typename MatrixQR::Index maxBlockSize=32, \
EIGTYPE* tempData = 0) \
{ \ { \
lapack_int m = mat.rows(); \ static void run(MatrixQR& mat, HCoeffs& hCoeffs, \
lapack_int n = mat.cols(); \ typename MatrixQR::Index = 32, \
lapack_int lda = mat.outerStride(); \ typename MatrixQR::Scalar* = 0) \
{ \
lapack_int m = (lapack_int) mat.rows(); \
lapack_int n = (lapack_int) mat.cols(); \
lapack_int lda = (lapack_int) mat.outerStride(); \
lapack_int matrix_order = (MatrixQR::IsRowMajor) ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR; \ lapack_int matrix_order = (MatrixQR::IsRowMajor) ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR; \
LAPACKE_##MKLPREFIX##geqrf( matrix_order, m, n, (MKLTYPE*)mat.data(), lda, (MKLTYPE*)hCoeffs.data()); \ LAPACKE_##MKLPREFIX##geqrf( matrix_order, m, n, (MKLTYPE*)mat.data(), lda, (MKLTYPE*)hCoeffs.data()); \
hCoeffs.adjointInPlace(); \ hCoeffs.adjointInPlace(); \
\ } \
} };
EIGEN_MKL_QR_NOPIV(double, double, d) EIGEN_MKL_QR_NOPIV(double, double, d)
EIGEN_MKL_QR_NOPIV(float, float, s) EIGEN_MKL_QR_NOPIV(float, float, s)

View File

@ -119,13 +119,13 @@ inline const Block<const Derived, CRows, CCols> topRightCorner() const
/** \returns an expression of a top-right corner of *this. /** \returns an expression of a top-right corner of *this.
* *
* \tparam CRows number of rows in corner as specified at compile time * \tparam CRows number of rows in corner as specified at compile-time
* \tparam CCols number of columns in corner as specified at compile time * \tparam CCols number of columns in corner as specified at compile-time
* \param cRows number of rows in corner as specified at run time * \param cRows number of rows in corner as specified at run-time
* \param cCols number of columns in corner as specified at run time * \param cCols number of columns in corner as specified at run-time
* *
* This function is mainly useful for corners where the number of rows is specified at compile time * This function is mainly useful for corners where the number of rows is specified at compile-time
* and the number of columns is specified at run time, or vice versa. The compile-time and run-time * and the number of columns is specified at run-time, or vice versa. The compile-time and run-time
* information should not contradict. In other words, \a cRows should equal \a CRows unless * information should not contradict. In other words, \a cRows should equal \a CRows unless
* \a CRows is \a Dynamic, and the same for the number of columns. * \a CRows is \a Dynamic, and the same for the number of columns.
* *
@ -198,13 +198,13 @@ inline const Block<const Derived, CRows, CCols> topLeftCorner() const
/** \returns an expression of a top-left corner of *this. /** \returns an expression of a top-left corner of *this.
* *
* \tparam CRows number of rows in corner as specified at compile time * \tparam CRows number of rows in corner as specified at compile-time
* \tparam CCols number of columns in corner as specified at compile time * \tparam CCols number of columns in corner as specified at compile-time
* \param cRows number of rows in corner as specified at run time * \param cRows number of rows in corner as specified at run-time
* \param cCols number of columns in corner as specified at run time * \param cCols number of columns in corner as specified at run-time
* *
* This function is mainly useful for corners where the number of rows is specified at compile time * This function is mainly useful for corners where the number of rows is specified at compile-time
* and the number of columns is specified at run time, or vice versa. The compile-time and run-time * and the number of columns is specified at run-time, or vice versa. The compile-time and run-time
* information should not contradict. In other words, \a cRows should equal \a CRows unless * information should not contradict. In other words, \a cRows should equal \a CRows unless
* \a CRows is \a Dynamic, and the same for the number of columns. * \a CRows is \a Dynamic, and the same for the number of columns.
* *
@ -277,13 +277,13 @@ inline const Block<const Derived, CRows, CCols> bottomRightCorner() const
/** \returns an expression of a bottom-right corner of *this. /** \returns an expression of a bottom-right corner of *this.
* *
* \tparam CRows number of rows in corner as specified at compile time * \tparam CRows number of rows in corner as specified at compile-time
* \tparam CCols number of columns in corner as specified at compile time * \tparam CCols number of columns in corner as specified at compile-time
* \param cRows number of rows in corner as specified at run time * \param cRows number of rows in corner as specified at run-time
* \param cCols number of columns in corner as specified at run time * \param cCols number of columns in corner as specified at run-time
* *
* This function is mainly useful for corners where the number of rows is specified at compile time * This function is mainly useful for corners where the number of rows is specified at compile-time
* and the number of columns is specified at run time, or vice versa. The compile-time and run-time * and the number of columns is specified at run-time, or vice versa. The compile-time and run-time
* information should not contradict. In other words, \a cRows should equal \a CRows unless * information should not contradict. In other words, \a cRows should equal \a CRows unless
* \a CRows is \a Dynamic, and the same for the number of columns. * \a CRows is \a Dynamic, and the same for the number of columns.
* *
@ -356,13 +356,13 @@ inline const Block<const Derived, CRows, CCols> bottomLeftCorner() const
/** \returns an expression of a bottom-left corner of *this. /** \returns an expression of a bottom-left corner of *this.
* *
* \tparam CRows number of rows in corner as specified at compile time * \tparam CRows number of rows in corner as specified at compile-time
* \tparam CCols number of columns in corner as specified at compile time * \tparam CCols number of columns in corner as specified at compile-time
* \param cRows number of rows in corner as specified at run time * \param cRows number of rows in corner as specified at run-time
* \param cCols number of columns in corner as specified at run time * \param cCols number of columns in corner as specified at run-time
* *
* This function is mainly useful for corners where the number of rows is specified at compile time * This function is mainly useful for corners where the number of rows is specified at compile-time
* and the number of columns is specified at run time, or vice versa. The compile-time and run-time * and the number of columns is specified at run-time, or vice versa. The compile-time and run-time
* information should not contradict. In other words, \a cRows should equal \a CRows unless * information should not contradict. In other words, \a cRows should equal \a CRows unless
* \a CRows is \a Dynamic, and the same for the number of columns. * \a CRows is \a Dynamic, and the same for the number of columns.
* *
@ -410,7 +410,11 @@ inline ConstRowsBlockXpr topRows(Index n) const
/** \returns a block consisting of the top rows of *this. /** \returns a block consisting of the top rows of *this.
* *
* \tparam N the number of rows in the block * \tparam N the number of rows in the block as specified at compile-time
* \param n the number of rows in the block as specified at run-time
*
* The compile-time and run-time information should not contradict. In other words,
* \a n should equal \a N unless \a N is \a Dynamic.
* *
* Example: \include MatrixBase_template_int_topRows.cpp * Example: \include MatrixBase_template_int_topRows.cpp
* Output: \verbinclude MatrixBase_template_int_topRows.out * Output: \verbinclude MatrixBase_template_int_topRows.out
@ -419,17 +423,17 @@ inline ConstRowsBlockXpr topRows(Index n) const
*/ */
template<int N> template<int N>
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline typename NRowsBlockXpr<N>::Type topRows() inline typename NRowsBlockXpr<N>::Type topRows(Index n = N)
{ {
return typename NRowsBlockXpr<N>::Type(derived(), 0, 0, N, cols()); return typename NRowsBlockXpr<N>::Type(derived(), 0, 0, n, cols());
} }
/** This is the const version of topRows<int>().*/ /** This is the const version of topRows<int>().*/
template<int N> template<int N>
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline typename ConstNRowsBlockXpr<N>::Type topRows() const inline typename ConstNRowsBlockXpr<N>::Type topRows(Index n = N) const
{ {
return typename ConstNRowsBlockXpr<N>::Type(derived(), 0, 0, N, cols()); return typename ConstNRowsBlockXpr<N>::Type(derived(), 0, 0, n, cols());
} }
@ -458,7 +462,11 @@ inline ConstRowsBlockXpr bottomRows(Index n) const
/** \returns a block consisting of the bottom rows of *this. /** \returns a block consisting of the bottom rows of *this.
* *
* \tparam N the number of rows in the block * \tparam N the number of rows in the block as specified at compile-time
* \param n the number of rows in the block as specified at run-time
*
* The compile-time and run-time information should not contradict. In other words,
* \a n should equal \a N unless \a N is \a Dynamic.
* *
* Example: \include MatrixBase_template_int_bottomRows.cpp * Example: \include MatrixBase_template_int_bottomRows.cpp
* Output: \verbinclude MatrixBase_template_int_bottomRows.out * Output: \verbinclude MatrixBase_template_int_bottomRows.out
@ -467,17 +475,17 @@ inline ConstRowsBlockXpr bottomRows(Index n) const
*/ */
template<int N> template<int N>
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline typename NRowsBlockXpr<N>::Type bottomRows() inline typename NRowsBlockXpr<N>::Type bottomRows(Index n = N)
{ {
return typename NRowsBlockXpr<N>::Type(derived(), rows() - N, 0, N, cols()); return typename NRowsBlockXpr<N>::Type(derived(), rows() - n, 0, n, cols());
} }
/** This is the const version of bottomRows<int>().*/ /** This is the const version of bottomRows<int>().*/
template<int N> template<int N>
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline typename ConstNRowsBlockXpr<N>::Type bottomRows() const inline typename ConstNRowsBlockXpr<N>::Type bottomRows(Index n = N) const
{ {
return typename ConstNRowsBlockXpr<N>::Type(derived(), rows() - N, 0, N, cols()); return typename ConstNRowsBlockXpr<N>::Type(derived(), rows() - n, 0, n, cols());
} }
@ -485,7 +493,7 @@ inline typename ConstNRowsBlockXpr<N>::Type bottomRows() const
/** \returns a block consisting of a range of rows of *this. /** \returns a block consisting of a range of rows of *this.
* *
* \param startRow the index of the first row in the block * \param startRow the index of the first row in the block
* \param numRows the number of rows in the block * \param n the number of rows in the block
* *
* Example: \include DenseBase_middleRows_int.cpp * Example: \include DenseBase_middleRows_int.cpp
* Output: \verbinclude DenseBase_middleRows_int.out * Output: \verbinclude DenseBase_middleRows_int.out
@ -493,22 +501,26 @@ inline typename ConstNRowsBlockXpr<N>::Type bottomRows() const
* \sa class Block, block(Index,Index,Index,Index) * \sa class Block, block(Index,Index,Index,Index)
*/ */
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline RowsBlockXpr middleRows(Index startRow, Index numRows) inline RowsBlockXpr middleRows(Index startRow, Index n)
{ {
return RowsBlockXpr(derived(), startRow, 0, numRows, cols()); return RowsBlockXpr(derived(), startRow, 0, n, cols());
} }
/** This is the const version of middleRows(Index,Index).*/ /** This is the const version of middleRows(Index,Index).*/
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline ConstRowsBlockXpr middleRows(Index startRow, Index numRows) const inline ConstRowsBlockXpr middleRows(Index startRow, Index n) const
{ {
return ConstRowsBlockXpr(derived(), startRow, 0, numRows, cols()); return ConstRowsBlockXpr(derived(), startRow, 0, n, cols());
} }
/** \returns a block consisting of a range of rows of *this. /** \returns a block consisting of a range of rows of *this.
* *
* \tparam N the number of rows in the block * \tparam N the number of rows in the block as specified at compile-time
* \param startRow the index of the first row in the block * \param startRow the index of the first row in the block
* \param n the number of rows in the block as specified at run-time
*
* The compile-time and run-time information should not contradict. In other words,
* \a n should equal \a N unless \a N is \a Dynamic.
* *
* Example: \include DenseBase_template_int_middleRows.cpp * Example: \include DenseBase_template_int_middleRows.cpp
* Output: \verbinclude DenseBase_template_int_middleRows.out * Output: \verbinclude DenseBase_template_int_middleRows.out
@ -517,17 +529,17 @@ inline ConstRowsBlockXpr middleRows(Index startRow, Index numRows) const
*/ */
template<int N> template<int N>
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline typename NRowsBlockXpr<N>::Type middleRows(Index startRow) inline typename NRowsBlockXpr<N>::Type middleRows(Index startRow, Index n = N)
{ {
return typename NRowsBlockXpr<N>::Type(derived(), startRow, 0, N, cols()); return typename NRowsBlockXpr<N>::Type(derived(), startRow, 0, n, cols());
} }
/** This is the const version of middleRows<int>().*/ /** This is the const version of middleRows<int>().*/
template<int N> template<int N>
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline typename ConstNRowsBlockXpr<N>::Type middleRows(Index startRow) const inline typename ConstNRowsBlockXpr<N>::Type middleRows(Index startRow, Index n = N) const
{ {
return typename ConstNRowsBlockXpr<N>::Type(derived(), startRow, 0, N, cols()); return typename ConstNRowsBlockXpr<N>::Type(derived(), startRow, 0, n, cols());
} }
@ -556,7 +568,11 @@ inline ConstColsBlockXpr leftCols(Index n) const
/** \returns a block consisting of the left columns of *this. /** \returns a block consisting of the left columns of *this.
* *
* \tparam N the number of columns in the block * \tparam N the number of columns in the block as specified at compile-time
* \param n the number of columns in the block as specified at run-time
*
* The compile-time and run-time information should not contradict. In other words,
* \a n should equal \a N unless \a N is \a Dynamic.
* *
* Example: \include MatrixBase_template_int_leftCols.cpp * Example: \include MatrixBase_template_int_leftCols.cpp
* Output: \verbinclude MatrixBase_template_int_leftCols.out * Output: \verbinclude MatrixBase_template_int_leftCols.out
@ -565,17 +581,17 @@ inline ConstColsBlockXpr leftCols(Index n) const
*/ */
template<int N> template<int N>
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline typename NColsBlockXpr<N>::Type leftCols() inline typename NColsBlockXpr<N>::Type leftCols(Index n = N)
{ {
return typename NColsBlockXpr<N>::Type(derived(), 0, 0, rows(), N); return typename NColsBlockXpr<N>::Type(derived(), 0, 0, rows(), n);
} }
/** This is the const version of leftCols<int>().*/ /** This is the const version of leftCols<int>().*/
template<int N> template<int N>
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline typename ConstNColsBlockXpr<N>::Type leftCols() const inline typename ConstNColsBlockXpr<N>::Type leftCols(Index n = N) const
{ {
return typename ConstNColsBlockXpr<N>::Type(derived(), 0, 0, rows(), N); return typename ConstNColsBlockXpr<N>::Type(derived(), 0, 0, rows(), n);
} }
@ -604,7 +620,11 @@ inline ConstColsBlockXpr rightCols(Index n) const
/** \returns a block consisting of the right columns of *this. /** \returns a block consisting of the right columns of *this.
* *
* \tparam N the number of columns in the block * \tparam N the number of columns in the block as specified at compile-time
* \param n the number of columns in the block as specified at run-time
*
* The compile-time and run-time information should not contradict. In other words,
* \a n should equal \a N unless \a N is \a Dynamic.
* *
* Example: \include MatrixBase_template_int_rightCols.cpp * Example: \include MatrixBase_template_int_rightCols.cpp
* Output: \verbinclude MatrixBase_template_int_rightCols.out * Output: \verbinclude MatrixBase_template_int_rightCols.out
@ -613,17 +633,17 @@ inline ConstColsBlockXpr rightCols(Index n) const
*/ */
template<int N> template<int N>
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline typename NColsBlockXpr<N>::Type rightCols() inline typename NColsBlockXpr<N>::Type rightCols(Index n = N)
{ {
return typename NColsBlockXpr<N>::Type(derived(), 0, cols() - N, rows(), N); return typename NColsBlockXpr<N>::Type(derived(), 0, cols() - n, rows(), n);
} }
/** This is the const version of rightCols<int>().*/ /** This is the const version of rightCols<int>().*/
template<int N> template<int N>
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline typename ConstNColsBlockXpr<N>::Type rightCols() const inline typename ConstNColsBlockXpr<N>::Type rightCols(Index n = N) const
{ {
return typename ConstNColsBlockXpr<N>::Type(derived(), 0, cols() - N, rows(), N); return typename ConstNColsBlockXpr<N>::Type(derived(), 0, cols() - n, rows(), n);
} }
@ -653,8 +673,12 @@ inline ConstColsBlockXpr middleCols(Index startCol, Index numCols) const
/** \returns a block consisting of a range of columns of *this. /** \returns a block consisting of a range of columns of *this.
* *
* \tparam N the number of columns in the block * \tparam N the number of columns in the block as specified at compile-time
* \param startCol the index of the first column in the block * \param startCol the index of the first column in the block
* \param n the number of columns in the block as specified at run-time
*
* The compile-time and run-time information should not contradict. In other words,
* \a n should equal \a N unless \a N is \a Dynamic.
* *
* Example: \include DenseBase_template_int_middleCols.cpp * Example: \include DenseBase_template_int_middleCols.cpp
* Output: \verbinclude DenseBase_template_int_middleCols.out * Output: \verbinclude DenseBase_template_int_middleCols.out
@ -663,17 +687,17 @@ inline ConstColsBlockXpr middleCols(Index startCol, Index numCols) const
*/ */
template<int N> template<int N>
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline typename NColsBlockXpr<N>::Type middleCols(Index startCol) inline typename NColsBlockXpr<N>::Type middleCols(Index startCol, Index n = N)
{ {
return typename NColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), N); return typename NColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), n);
} }
/** This is the const version of middleCols<int>().*/ /** This is the const version of middleCols<int>().*/
template<int N> template<int N>
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline typename ConstNColsBlockXpr<N>::Type middleCols(Index startCol) const inline typename ConstNColsBlockXpr<N>::Type middleCols(Index startCol, Index n = N) const
{ {
return typename ConstNColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), N); return typename ConstNColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), n);
} }
@ -711,15 +735,15 @@ inline const Block<const Derived, BlockRows, BlockCols> block(Index startRow, In
/** \returns an expression of a block in *this. /** \returns an expression of a block in *this.
* *
* \tparam BlockRows number of rows in block as specified at compile time * \tparam BlockRows number of rows in block as specified at compile-time
* \tparam BlockCols number of columns in block as specified at compile time * \tparam BlockCols number of columns in block as specified at compile-time
* \param startRow the first row in the block * \param startRow the first row in the block
* \param startCol the first column in the block * \param startCol the first column in the block
* \param blockRows number of rows in block as specified at run time * \param blockRows number of rows in block as specified at run-time
* \param blockCols number of columns in block as specified at run time * \param blockCols number of columns in block as specified at run-time
* *
* This function is mainly useful for blocks where the number of rows is specified at compile time * This function is mainly useful for blocks where the number of rows is specified at compile-time
* and the number of columns is specified at run time, or vice versa. The compile-time and run-time * and the number of columns is specified at run-time, or vice versa. The compile-time and run-time
* information should not contradict. In other words, \a blockRows should equal \a BlockRows unless * information should not contradict. In other words, \a blockRows should equal \a BlockRows unless
* \a BlockRows is \a Dynamic, and the same for the number of columns. * \a BlockRows is \a Dynamic, and the same for the number of columns.
* *
@ -786,7 +810,7 @@ inline ConstRowXpr row(Index i) const
* \only_for_vectors * \only_for_vectors
* *
* \param start the first coefficient in the segment * \param start the first coefficient in the segment
* \param vecSize the number of coefficients in the segment * \param n the number of coefficients in the segment
* *
* Example: \include MatrixBase_segment_int_int.cpp * Example: \include MatrixBase_segment_int_int.cpp
* Output: \verbinclude MatrixBase_segment_int_int.out * Output: \verbinclude MatrixBase_segment_int_int.out
@ -798,26 +822,26 @@ inline ConstRowXpr row(Index i) const
* \sa class Block, segment(Index) * \sa class Block, segment(Index)
*/ */
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline SegmentReturnType segment(Index start, Index vecSize) inline SegmentReturnType segment(Index start, Index n)
{ {
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return SegmentReturnType(derived(), start, vecSize); return SegmentReturnType(derived(), start, n);
} }
/** This is the const version of segment(Index,Index).*/ /** This is the const version of segment(Index,Index).*/
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline ConstSegmentReturnType segment(Index start, Index vecSize) const inline ConstSegmentReturnType segment(Index start, Index n) const
{ {
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return ConstSegmentReturnType(derived(), start, vecSize); return ConstSegmentReturnType(derived(), start, n);
} }
/** \returns a dynamic-size expression of the first coefficients of *this. /** \returns a dynamic-size expression of the first coefficients of *this.
* *
* \only_for_vectors * \only_for_vectors
* *
* \param vecSize the number of coefficients in the block * \param n the number of coefficients in the segment
* *
* Example: \include MatrixBase_start_int.cpp * Example: \include MatrixBase_start_int.cpp
* Output: \verbinclude MatrixBase_start_int.out * Output: \verbinclude MatrixBase_start_int.out
@ -829,26 +853,25 @@ inline ConstSegmentReturnType segment(Index start, Index vecSize) const
* \sa class Block, block(Index,Index) * \sa class Block, block(Index,Index)
*/ */
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline SegmentReturnType head(Index vecSize) inline SegmentReturnType head(Index n)
{ {
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return SegmentReturnType(derived(), 0, vecSize); return SegmentReturnType(derived(), 0, n);
} }
/** This is the const version of head(Index).*/ /** This is the const version of head(Index).*/
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline ConstSegmentReturnType inline ConstSegmentReturnType head(Index n) const
head(Index vecSize) const
{ {
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return ConstSegmentReturnType(derived(), 0, vecSize); return ConstSegmentReturnType(derived(), 0, n);
} }
/** \returns a dynamic-size expression of the last coefficients of *this. /** \returns a dynamic-size expression of the last coefficients of *this.
* *
* \only_for_vectors * \only_for_vectors
* *
* \param vecSize the number of coefficients in the block * \param n the number of coefficients in the segment
* *
* Example: \include MatrixBase_end_int.cpp * Example: \include MatrixBase_end_int.cpp
* Output: \verbinclude MatrixBase_end_int.out * Output: \verbinclude MatrixBase_end_int.out
@ -860,102 +883,113 @@ inline ConstSegmentReturnType
* \sa class Block, block(Index,Index) * \sa class Block, block(Index,Index)
*/ */
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline SegmentReturnType tail(Index vecSize) inline SegmentReturnType tail(Index n)
{ {
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return SegmentReturnType(derived(), this->size() - vecSize, vecSize); return SegmentReturnType(derived(), this->size() - n, n);
} }
/** This is the const version of tail(Index).*/ /** This is the const version of tail(Index).*/
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline ConstSegmentReturnType tail(Index vecSize) const inline ConstSegmentReturnType tail(Index n) const
{ {
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return ConstSegmentReturnType(derived(), this->size() - vecSize, vecSize); return ConstSegmentReturnType(derived(), this->size() - n, n);
} }
/** \returns a fixed-size expression of a segment (i.e. a vector block) in \c *this /** \returns a fixed-size expression of a segment (i.e. a vector block) in \c *this
* *
* \only_for_vectors * \only_for_vectors
* *
* The template parameter \a Size is the number of coefficients in the block * \tparam N the number of coefficients in the segment as specified at compile-time
* \param start the index of the first element in the segment
* \param n the number of coefficients in the segment as specified at compile-time
* *
* \param start the index of the first element of the sub-vector * The compile-time and run-time information should not contradict. In other words,
* \a n should equal \a N unless \a N is \a Dynamic.
* *
* Example: \include MatrixBase_template_int_segment.cpp * Example: \include MatrixBase_template_int_segment.cpp
* Output: \verbinclude MatrixBase_template_int_segment.out * Output: \verbinclude MatrixBase_template_int_segment.out
* *
* \sa class Block * \sa class Block
*/ */
template<int Size> template<int N>
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline typename FixedSegmentReturnType<Size>::Type segment(Index start) inline typename FixedSegmentReturnType<N>::Type segment(Index start, Index n = N)
{ {
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return typename FixedSegmentReturnType<Size>::Type(derived(), start); return typename FixedSegmentReturnType<N>::Type(derived(), start, n);
} }
/** This is the const version of segment<int>(Index).*/ /** This is the const version of segment<int>(Index).*/
template<int Size> template<int N>
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline typename ConstFixedSegmentReturnType<Size>::Type segment(Index start) const inline typename ConstFixedSegmentReturnType<N>::Type segment(Index start, Index n = N) const
{ {
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return typename ConstFixedSegmentReturnType<Size>::Type(derived(), start); return typename ConstFixedSegmentReturnType<N>::Type(derived(), start, n);
} }
/** \returns a fixed-size expression of the first coefficients of *this. /** \returns a fixed-size expression of the first coefficients of *this.
* *
* \only_for_vectors * \only_for_vectors
* *
* The template parameter \a Size is the number of coefficients in the block * \tparam N the number of coefficients in the segment as specified at compile-time
* \param n the number of coefficients in the segment as specified at run-time
*
* The compile-time and run-time information should not contradict. In other words,
* \a n should equal \a N unless \a N is \a Dynamic.
* *
* Example: \include MatrixBase_template_int_start.cpp * Example: \include MatrixBase_template_int_start.cpp
* Output: \verbinclude MatrixBase_template_int_start.out * Output: \verbinclude MatrixBase_template_int_start.out
* *
* \sa class Block * \sa class Block
*/ */
template<int Size> template<int N>
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline typename FixedSegmentReturnType<Size>::Type head() inline typename FixedSegmentReturnType<N>::Type head(Index n = N)
{ {
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return typename FixedSegmentReturnType<Size>::Type(derived(), 0); return typename FixedSegmentReturnType<N>::Type(derived(), 0, n);
} }
/** This is the const version of head<int>().*/ /** This is the const version of head<int>().*/
template<int Size> template<int N>
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline typename ConstFixedSegmentReturnType<Size>::Type head() const inline typename ConstFixedSegmentReturnType<N>::Type head(Index n = N) const
{ {
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return typename ConstFixedSegmentReturnType<Size>::Type(derived(), 0); return typename ConstFixedSegmentReturnType<N>::Type(derived(), 0, n);
} }
/** \returns a fixed-size expression of the last coefficients of *this. /** \returns a fixed-size expression of the last coefficients of *this.
* *
* \only_for_vectors * \only_for_vectors
* *
* The template parameter \a Size is the number of coefficients in the block * \tparam N the number of coefficients in the segment as specified at compile-time
* \param n the number of coefficients in the segment as specified at run-time
*
* The compile-time and run-time information should not contradict. In other words,
* \a n should equal \a N unless \a N is \a Dynamic.
* *
* Example: \include MatrixBase_template_int_end.cpp * Example: \include MatrixBase_template_int_end.cpp
* Output: \verbinclude MatrixBase_template_int_end.out * Output: \verbinclude MatrixBase_template_int_end.out
* *
* \sa class Block * \sa class Block
*/ */
template<int Size> template<int N>
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline typename FixedSegmentReturnType<Size>::Type tail() inline typename FixedSegmentReturnType<N>::Type tail(Index n = N)
{ {
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return typename FixedSegmentReturnType<Size>::Type(derived(), size() - Size); return typename FixedSegmentReturnType<N>::Type(derived(), size() - n);
} }
/** This is the const version of tail<int>.*/ /** This is the const version of tail<int>.*/
template<int Size> template<int N>
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
inline typename ConstFixedSegmentReturnType<Size>::Type tail() const inline typename ConstFixedSegmentReturnType<N>::Type tail(Index n = N) const
{ {
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return typename ConstFixedSegmentReturnType<Size>::Type(derived(), size() - Size); return typename ConstFixedSegmentReturnType<N>::Type(derived(), size() - n);
} }

View File

@ -206,6 +206,7 @@ TAB_SIZE = 8
# You can put \n's in the value part of an alias to insert newlines. # You can put \n's in the value part of an alias to insert newlines.
ALIASES = "only_for_vectors=This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column." \ ALIASES = "only_for_vectors=This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column." \
"not_reentrant=\warning This function is not re-entrant." \
"array_module=This is defined in the %Array module. \code #include <Eigen/Array> \endcode" \ "array_module=This is defined in the %Array module. \code #include <Eigen/Array> \endcode" \
"cholesky_module=This is defined in the %Cholesky module. \code #include <Eigen/Cholesky> \endcode" \ "cholesky_module=This is defined in the %Cholesky module. \code #include <Eigen/Cholesky> \endcode" \
"eigenvalues_module=This is defined in the %Eigenvalues module. \code #include <Eigen/Eigenvalues> \endcode" \ "eigenvalues_module=This is defined in the %Eigenvalues module. \code #include <Eigen/Eigenvalues> \endcode" \
@ -224,6 +225,7 @@ ALIASES = "only_for_vectors=This is only for vectors (either row-
"note_try_to_help_rvo=This function returns the result by value. In order to make that efficient, it is implemented as just a return statement using a special constructor, hopefully allowing the compiler to perform a RVO (return value optimization)." \ "note_try_to_help_rvo=This function returns the result by value. In order to make that efficient, it is implemented as just a return statement using a special constructor, hopefully allowing the compiler to perform a RVO (return value optimization)." \
"nonstableyet=\warning This is not considered to be part of the stable public API yet. Changes may happen in future releases. See \ref Experimental \"Experimental parts of Eigen\" "nonstableyet=\warning This is not considered to be part of the stable public API yet. Changes may happen in future releases. See \ref Experimental \"Experimental parts of Eigen\"
ALIASES += "eigenAutoToc= " ALIASES += "eigenAutoToc= "
ALIASES += "eigenManualPage=\defgroup" ALIASES += "eigenManualPage=\defgroup"

View File

@ -39,6 +39,8 @@ int main(int argc, char** argv)
} }
\endcode \endcode
\warning note that all functions generating random matrices are \b not re-entrant nor thread-safe. Those include DenseBase::Random(), and DenseBase::setRandom() despite a call to Eigen::initParallel(). This is because these functions are based on std::rand which is not re-entrant. For thread-safe random generator, we recommend the use of boost::random of c++11 random feature.
In the case your application is parallelized with OpenMP, you might want to disable Eigen's own parallization as detailed in the previous section. In the case your application is parallelized with OpenMP, you might want to disable Eigen's own parallization as detailed in the previous section.
*/ */

View File

@ -19,3 +19,22 @@ if(QT4_FOUND)
add_dependencies(all_examples Tutorial_sparse_example) add_dependencies(all_examples Tutorial_sparse_example)
endif(QT4_FOUND) endif(QT4_FOUND)
check_cxx_compiler_flag("-std=c++11" EIGEN_COMPILER_SUPPORT_CPP11)
if(EIGEN_COMPILER_SUPPORT_CPP11)
add_executable(random_cpp11 random_cpp11.cpp)
target_link_libraries(random_cpp11 ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO})
add_dependencies(all_examples random_cpp11)
ei_add_target_property(random_cpp11 COMPILE_FLAGS "-std=c++11")
get_target_property(random_cpp11_exec
random_cpp11 LOCATION)
add_custom_command(
TARGET random_cpp11
POST_BUILD
COMMAND ${random_cpp11_exec}
ARGS >${CMAKE_CURRENT_BINARY_DIR}/random_cpp11.out
)
endif()

View File

@ -0,0 +1,14 @@
#include <Eigen/Core>
#include <iostream>
#include <random>
using namespace Eigen;
int main() {
std::default_random_engine generator;
std::poisson_distribution<int> distribution(4.1);
auto poisson = [&] (int) {return distribution(generator);};
RowVectorXi v = RowVectorXi::NullaryExpr(10, poisson );
std::cout << v << "\n";
}