Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef EIGEN_RANDOM_H
00011 #define EIGEN_RANDOM_H
00012
00013 namespace Eigen {
00014
00015 namespace internal {
00016
00017 template<typename Scalar> struct scalar_random_op {
00018 EIGEN_EMPTY_STRUCT_CTOR(scalar_random_op)
00019 template<typename Index>
00020 inline const Scalar operator() (Index, Index = 0) const { return random<Scalar>(); }
00021 };
00022
00023 template<typename Scalar>
00024 struct functor_traits<scalar_random_op<Scalar> >
00025 { enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false, IsRepeatable = false }; };
00026
00027 }
00028
00047 template<typename Derived>
00048 inline const CwiseNullaryOp<internal::scalar_random_op<typename internal::traits<Derived>::Scalar>, Derived>
00049 DenseBase<Derived>::Random(Index rows, Index cols)
00050 {
00051 return NullaryExpr(rows, cols, internal::scalar_random_op<Scalar>());
00052 }
00053
00074 template<typename Derived>
00075 inline const CwiseNullaryOp<internal::scalar_random_op<typename internal::traits<Derived>::Scalar>, Derived>
00076 DenseBase<Derived>::Random(Index size)
00077 {
00078 return NullaryExpr(size, internal::scalar_random_op<Scalar>());
00079 }
00080
00095 template<typename Derived>
00096 inline const CwiseNullaryOp<internal::scalar_random_op<typename internal::traits<Derived>::Scalar>, Derived>
00097 DenseBase<Derived>::Random()
00098 {
00099 return NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, internal::scalar_random_op<Scalar>());
00100 }
00101
00109 template<typename Derived>
00110 inline Derived& DenseBase<Derived>::setRandom()
00111 {
00112 return *this = Random(rows(), cols());
00113 }
00114
00124 template<typename Derived>
00125 EIGEN_STRONG_INLINE Derived&
00126 PlainObjectBase<Derived>::setRandom(Index size)
00127 {
00128 resize(size);
00129 return setRandom();
00130 }
00131
00142 template<typename Derived>
00143 EIGEN_STRONG_INLINE Derived&
00144 PlainObjectBase<Derived>::setRandom(Index rows, Index cols)
00145 {
00146 resize(rows, cols);
00147 return setRandom();
00148 }
00149
00150 }
00151
00152 #endif // EIGEN_RANDOM_H