Eigen  3.3.3
Random.h
00001 // This file is part of Eigen, a lightweight C++ template library
00002 // for linear algebra.
00003 //
00004 // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
00005 //
00006 // This Source Code Form is subject to the terms of the Mozilla
00007 // Public License v. 2.0. If a copy of the MPL was not distributed
00008 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
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   inline const Scalar operator() () const { return random<Scalar>(); }
00020 };
00021 
00022 template<typename Scalar>
00023 struct functor_traits<scalar_random_op<Scalar> >
00024 { enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false, IsRepeatable = false }; };
00025 
00026 } // end namespace internal
00027 
00054 template<typename Derived>
00055 inline const typename DenseBase<Derived>::RandomReturnType
00056 DenseBase<Derived>::Random(Index rows, Index cols)
00057 {
00058   return NullaryExpr(rows, cols, internal::scalar_random_op<Scalar>());
00059 }
00060 
00085 template<typename Derived>
00086 inline const typename DenseBase<Derived>::RandomReturnType
00087 DenseBase<Derived>::Random(Index size)
00088 {
00089   return NullaryExpr(size, internal::scalar_random_op<Scalar>());
00090 }
00091 
00111 template<typename Derived>
00112 inline const typename DenseBase<Derived>::RandomReturnType
00113 DenseBase<Derived>::Random()
00114 {
00115   return NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, internal::scalar_random_op<Scalar>());
00116 }
00117 
00130 template<typename Derived>
00131 inline Derived& DenseBase<Derived>::setRandom()
00132 {
00133   return *this = Random(rows(), cols());
00134 }
00135 
00149 template<typename Derived>
00150 EIGEN_STRONG_INLINE Derived&
00151 PlainObjectBase<Derived>::setRandom(Index newSize)
00152 {
00153   resize(newSize);
00154   return setRandom();
00155 }
00156 
00172 template<typename Derived>
00173 EIGEN_STRONG_INLINE Derived&
00174 PlainObjectBase<Derived>::setRandom(Index rows, Index cols)
00175 {
00176   resize(rows, cols);
00177   return setRandom();
00178 }
00179 
00180 } // end namespace Eigen
00181 
00182 #endif // EIGEN_RANDOM_H
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends