00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef EIGEN_RANDOM_H
00026 #define EIGEN_RANDOM_H
00027
00028 template<typename Scalar> struct ei_scalar_random_op EIGEN_EMPTY_STRUCT {
00029 inline ei_scalar_random_op(void) {}
00030 inline const Scalar operator() (int, int) const { return ei_random<Scalar>(); }
00031 };
00032 template<typename Scalar>
00033 struct ei_functor_traits<ei_scalar_random_op<Scalar> >
00034 { enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false, IsRepeatable = false }; };
00035
00054 template<typename Derived>
00055 inline const CwiseNullaryOp<ei_scalar_random_op<typename ei_traits<Derived>::Scalar>, Derived>
00056 MatrixBase<Derived>::Random(int rows, int cols)
00057 {
00058 return NullaryExpr(rows, cols, ei_scalar_random_op<Scalar>());
00059 }
00060
00079 template<typename Derived>
00080 inline const CwiseNullaryOp<ei_scalar_random_op<typename ei_traits<Derived>::Scalar>, Derived>
00081 MatrixBase<Derived>::Random(int size)
00082 {
00083 return NullaryExpr(size, ei_scalar_random_op<Scalar>());
00084 }
00085
00099 template<typename Derived>
00100 inline const CwiseNullaryOp<ei_scalar_random_op<typename ei_traits<Derived>::Scalar>, Derived>
00101 MatrixBase<Derived>::Random()
00102 {
00103 return NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, ei_scalar_random_op<Scalar>());
00104 }
00105
00115 template<typename Derived>
00116 inline Derived& MatrixBase<Derived>::setRandom()
00117 {
00118 return *this = Random(rows(), cols());
00119 }
00120
00130 template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
00131 EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
00132 Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setRandom(int size)
00133 {
00134 resize(size);
00135 return setRandom();
00136 }
00137
00148 template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
00149 EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
00150 Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setRandom(int rows, int cols)
00151 {
00152 resize(rows, cols);
00153 return setRandom();
00154 }
00155
00156 #endif // EIGEN_RANDOM_H