$treeview $search $mathjax
Eigen
3.2.5
$projectbrief
|
$projectbrief
|
$searchbox |
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 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 } // end namespace internal 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 newSize) 00127 { 00128 resize(newSize); 00129 return setRandom(); 00130 } 00131 00142 template<typename Derived> 00143 EIGEN_STRONG_INLINE Derived& 00144 PlainObjectBase<Derived>::setRandom(Index nbRows, Index nbCols) 00145 { 00146 resize(nbRows, nbCols); 00147 return setRandom(); 00148 } 00149 00150 } // end namespace Eigen 00151 00152 #endif // EIGEN_RANDOM_H