Go to the documentation of this file.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 namespace internal {
00029
00030 template<typename Scalar> struct scalar_random_op {
00031 EIGEN_EMPTY_STRUCT_CTOR(scalar_random_op)
00032 template<typename Index>
00033 inline const Scalar operator() (Index, Index = 0) const { return random<Scalar>(); }
00034 };
00035
00036 template<typename Scalar>
00037 struct functor_traits<scalar_random_op<Scalar> >
00038 { enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false, IsRepeatable = false }; };
00039
00040 }
00041
00060 template<typename Derived>
00061 inline const CwiseNullaryOp<internal::scalar_random_op<typename internal::traits<Derived>::Scalar>, Derived>
00062 DenseBase<Derived>::Random(Index rows, Index cols)
00063 {
00064 return NullaryExpr(rows, cols, internal::scalar_random_op<Scalar>());
00065 }
00066
00087 template<typename Derived>
00088 inline const CwiseNullaryOp<internal::scalar_random_op<typename internal::traits<Derived>::Scalar>, Derived>
00089 DenseBase<Derived>::Random(Index size)
00090 {
00091 return NullaryExpr(size, internal::scalar_random_op<Scalar>());
00092 }
00093
00108 template<typename Derived>
00109 inline const CwiseNullaryOp<internal::scalar_random_op<typename internal::traits<Derived>::Scalar>, Derived>
00110 DenseBase<Derived>::Random()
00111 {
00112 return NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, internal::scalar_random_op<Scalar>());
00113 }
00114
00122 template<typename Derived>
00123 inline Derived& DenseBase<Derived>::setRandom()
00124 {
00125 return *this = Random(rows(), cols());
00126 }
00127
00137 template<typename Derived>
00138 EIGEN_STRONG_INLINE Derived&
00139 PlainObjectBase<Derived>::setRandom(Index size)
00140 {
00141 resize(size);
00142 return setRandom();
00143 }
00144
00155 template<typename Derived>
00156 EIGEN_STRONG_INLINE Derived&
00157 PlainObjectBase<Derived>::setRandom(Index rows, Index cols)
00158 {
00159 resize(rows, cols);
00160 return setRandom();
00161 }
00162
00163 #endif // EIGEN_RANDOM_H