Random.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_RANDOM_H
11 #define EIGEN_RANDOM_H
12 
13 // IWYU pragma: private
14 #include "./InternalHeaderCheck.h"
15 
16 namespace Eigen {
17 
18 namespace internal {
19 
20 template <typename Scalar>
22  inline const Scalar operator()() const { return random<Scalar>(); }
23 };
24 
25 template <typename Scalar>
27  enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false, IsRepeatable = false };
28 };
29 
30 } // end namespace internal
31 
58 template <typename Derived>
60  return NullaryExpr(rows, cols, internal::scalar_random_op<Scalar>());
61 }
62 
87 template <typename Derived>
89  return NullaryExpr(size, internal::scalar_random_op<Scalar>());
90 }
91 
111 template <typename Derived>
113  return NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, internal::scalar_random_op<Scalar>());
114 }
115 
128 template <typename Derived>
130  return *this = Random(rows(), cols());
131 }
132 
146 template <typename Derived>
148  resize(newSize);
149  return setRandom();
150 }
151 
167 template <typename Derived>
169  resize(rows, cols);
170  return setRandom();
171 }
172 
184 template <typename Derived>
186  return setRandom(rows(), cols);
187 }
188 
200 template <typename Derived>
202  return setRandom(rows, cols());
203 }
204 
205 } // end namespace Eigen
206 
207 #endif // EIGEN_RANDOM_H
A setRandom()
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:892
#define EIGEN_STRONG_INLINE
Definition: Macros.h:834
v resize(3)
int rows
Definition: Tutorial_commainit_02.cpp:1
int cols
Definition: Tutorial_commainit_02.cpp:1
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
SCALAR Scalar
Definition: bench_gemm.cpp:45
Generic expression of a matrix where all coefficients are defined by a functor.
Definition: CwiseNullaryOp.h:64
EIGEN_DEVICE_FUNC Derived & setRandom()
Definition: Random.h:129
static const RandomReturnType Random()
Definition: Random.h:112
Derived & setRandom(Index size)
Definition: Random.h:147
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
NoChange_t
Definition: Constants.h:359
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
Definition: Eigen_Colamd.h:49
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:217
Definition: XprHelper.h:205
@ PacketAccess
Definition: XprHelper.h:206
@ Cost
Definition: XprHelper.h:206
@ IsRepeatable
Definition: XprHelper.h:206
Definition: Random.h:21
const Scalar operator()() const
Definition: Random.h:22