Eigen  3.4.90 (git rev 5a9f66fb35d03a4da9ef8976e67a61b30aa16dcf)
 
Loading...
Searching...
No Matches
Random.h
1// This file is part of Eigen, a lightweight C++ template library
2// for linear algebra.
3//
4// Copyright (C) 2008 Gael Guennebaud <[email protected]>
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
16namespace Eigen {
17
18namespace internal {
19
20template <typename Scalar>
21struct scalar_random_op {
22 inline const Scalar operator()() const { return random<Scalar>(); }
23};
24
25template <typename Scalar>
26struct functor_traits<scalar_random_op<Scalar> > {
27 enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false, IsRepeatable = false };
28};
29
30} // end namespace internal
31
58template <typename Derived>
60 return NullaryExpr(rows, cols, internal::scalar_random_op<Scalar>());
61}
62
87template <typename Derived>
89 return NullaryExpr(size, internal::scalar_random_op<Scalar>());
90}
91
111template <typename Derived>
113 return NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, internal::scalar_random_op<Scalar>());
114}
115
128template <typename Derived>
129EIGEN_DEVICE_FUNC inline Derived& DenseBase<Derived>::setRandom() {
130 return *this = Random(rows(), cols());
131}
132
146template <typename Derived>
147EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setRandom(Index newSize) {
148 resize(newSize);
149 return setRandom();
150}
151
167template <typename Derived>
168EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setRandom(Index rows, Index cols) {
169 resize(rows, cols);
170 return setRandom();
171}
172
184template <typename Derived>
185EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setRandom(NoChange_t, Index cols) {
186 return setRandom(rows(), cols);
187}
188
200template <typename Derived>
201EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setRandom(Index rows, NoChange_t) {
202 return setRandom(rows, cols());
203}
204
205} // end namespace Eigen
206
207#endif // EIGEN_RANDOM_H
Generic expression of a matrix where all coefficients are defined by a functor.
Definition CwiseNullaryOp.h:64
Base class for all dense matrices, vectors, and arrays.
Definition DenseBase.h:44
Dense storage base class for matrices and arrays.
Definition PlainObjectBase.h:121
Namespace containing all symbols from the Eigen library.
Definition Core:137
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:83