Random.h
Go to the documentation of this file.
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 // Eigen is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 3 of the License, or (at your option) any later version.
00010 //
00011 // Alternatively, you can redistribute it and/or
00012 // modify it under the terms of the GNU General Public License as
00013 // published by the Free Software Foundation; either version 2 of
00014 // the License, or (at your option) any later version.
00015 //
00016 // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
00017 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00018 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
00019 // GNU General Public License for more details.
00020 //
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License and a copy of the GNU General Public License along with
00023 // Eigen. If not, see <http://www.gnu.org/licenses/>.
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 } // end namespace internal
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


re_vision
Author(s): Dorian Galvez-Lopez
autogenerated on Sun Jan 5 2014 11:32:17