aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/Random.h
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2008-03-10 17:23:11 +0000
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2008-03-10 17:23:11 +0000
commit01572b9f54e769a7d1bb3d5073c264a5fbc7ce42 (patch)
treeea9b9ef0469040e8b8ae0805f77d726c319dfeac /Eigen/src/Core/Random.h
parent9d9d81ad71a52c33ba4db9f8a6059d435d279316 (diff)
big change: MatrixBase only takes one template parameter "Derived", the
template parameter "Scalar" is removed. This is achieved by introducting a template <typename Derived> struct Scalar to achieve a forward-declaration of the Scalar typedefs.
Diffstat (limited to 'Eigen/src/Core/Random.h')
-rw-r--r--Eigen/src/Core/Random.h28
1 files changed, 16 insertions, 12 deletions
diff --git a/Eigen/src/Core/Random.h b/Eigen/src/Core/Random.h
index 394e6c3b0..364b8f4ed 100644
--- a/Eigen/src/Core/Random.h
+++ b/Eigen/src/Core/Random.h
@@ -32,14 +32,18 @@
* \sa MatrixBase::random(), MatrixBase::random(int), MatrixBase::random(int,int),
* MatrixBase::setRandom()
*/
+template<typename MatrixType>
+struct Scalar<Random<MatrixType> >
+{ typedef typename Scalar<MatrixType>::Type Type; };
+
template<typename MatrixType> class Random : NoOperatorEquals,
- public MatrixBase<typename MatrixType::Scalar, Random<MatrixType> >
+ public MatrixBase<Random<MatrixType> >
{
public:
typedef typename MatrixType::Scalar Scalar;
- friend class MatrixBase<Scalar, Random>;
- friend class MatrixBase<Scalar, Random>::Traits;
- typedef MatrixBase<Scalar, Random> Base;
+ friend class MatrixBase<Random>;
+ friend class MatrixBase<Random>::Traits;
+ typedef MatrixBase<Random> Base;
private:
enum {
@@ -86,9 +90,9 @@ template<typename MatrixType> class Random : NoOperatorEquals,
*
* \sa ei_random(), ei_random(int)
*/
-template<typename Scalar, typename Derived>
+template<typename Derived>
const Eval<Random<Derived> >
-MatrixBase<Scalar, Derived>::random(int rows, int cols)
+MatrixBase<Derived>::random(int rows, int cols)
{
return Random<Derived>(rows, cols).eval();
}
@@ -109,9 +113,9 @@ MatrixBase<Scalar, Derived>::random(int rows, int cols)
*
* \sa ei_random(), ei_random(int,int)
*/
-template<typename Scalar, typename Derived>
+template<typename Derived>
const Eval<Random<Derived> >
-MatrixBase<Scalar, Derived>::random(int size)
+MatrixBase<Derived>::random(int size)
{
assert(Traits::IsVectorAtCompileTime);
if(Traits::RowsAtCompileTime == 1) return Random<Derived>(1, size).eval();
@@ -129,9 +133,9 @@ MatrixBase<Scalar, Derived>::random(int size)
*
* \sa ei_random(int), ei_random(int,int)
*/
-template<typename Scalar, typename Derived>
+template<typename Derived>
const Eval<Random<Derived> >
-MatrixBase<Scalar, Derived>::random()
+MatrixBase<Derived>::random()
{
return Random<Derived>(Traits::RowsAtCompileTime, Traits::ColsAtCompileTime).eval();
}
@@ -143,8 +147,8 @@ MatrixBase<Scalar, Derived>::random()
*
* \sa class Random, ei_random()
*/
-template<typename Scalar, typename Derived>
-Derived& MatrixBase<Scalar, Derived>::setRandom()
+template<typename Derived>
+Derived& MatrixBase<Derived>::setRandom()
{
return *this = Random<Derived>(rows(), cols());
}