From 2ee68a074efc1163358fb3b51fb4b23e83a05f97 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Wed, 12 Mar 2008 17:17:36 +0000 Subject: generalized ei_traits<>. Finally the importing macro is named EIGEN_BASIC_PUBLIC_INTERFACE because it does not only import the ei_traits, it also makes the base class a friend, etc. --- Eigen/src/Core/Random.h | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'Eigen/src/Core/Random.h') diff --git a/Eigen/src/Core/Random.h b/Eigen/src/Core/Random.h index 364b8f4ed..1c2154b43 100644 --- a/Eigen/src/Core/Random.h +++ b/Eigen/src/Core/Random.h @@ -33,25 +33,23 @@ * MatrixBase::setRandom() */ template -struct Scalar > -{ typedef typename Scalar::Type Type; }; +struct ei_traits > +{ + typedef typename MatrixType::Scalar Scalar; + enum { + RowsAtCompileTime = MatrixType::RowsAtCompileTime, + ColsAtCompileTime = MatrixType::ColsAtCompileTime, + MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, + MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime + }; +}; template class Random : NoOperatorEquals, public MatrixBase > { public: - typedef typename MatrixType::Scalar Scalar; - friend class MatrixBase; - friend class MatrixBase::Traits; - typedef MatrixBase Base; - private: - enum { - RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime, - ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime, - MaxRowsAtCompileTime = MatrixType::Traits::MaxRowsAtCompileTime, - MaxColsAtCompileTime = MatrixType::Traits::MaxColsAtCompileTime - }; + EIGEN_BASIC_PUBLIC_INTERFACE(Random) const Random& _asArg() const { return *this; } int _rows() const { return m_rows.value(); } @@ -117,8 +115,8 @@ template const Eval > MatrixBase::random(int size) { - assert(Traits::IsVectorAtCompileTime); - if(Traits::RowsAtCompileTime == 1) return Random(1, size).eval(); + assert(IsVectorAtCompileTime); + if(RowsAtCompileTime == 1) return Random(1, size).eval(); else return Random(size, 1).eval(); } @@ -137,7 +135,7 @@ template const Eval > MatrixBase::random() { - return Random(Traits::RowsAtCompileTime, Traits::ColsAtCompileTime).eval(); + return Random(RowsAtCompileTime, ColsAtCompileTime).eval(); } /** Sets all coefficients in this expression to random values. -- cgit v1.2.3