Please, help us to better know about our user community by answering the following short survey: https://forms.gle/wpyrxWi18ox9Z5ae9
Eigen  3.4.0
 
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 <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
13namespace Eigen {
14
15namespace internal {
16
17template<typename Scalar> struct scalar_random_op {
18 EIGEN_EMPTY_STRUCT_CTOR(scalar_random_op)
19 inline const Scalar operator() () const { return random<Scalar>(); }
20};
21
22template<typename Scalar>
23struct functor_traits<scalar_random_op<Scalar> >
24{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false, IsRepeatable = false }; };
25
26} // end namespace internal
27
54template<typename Derived>
55inline const typename DenseBase<Derived>::RandomReturnType
57{
58 return NullaryExpr(rows, cols, internal::scalar_random_op<Scalar>());
59}
60
85template<typename Derived>
86inline const typename DenseBase<Derived>::RandomReturnType
88{
89 return NullaryExpr(size, internal::scalar_random_op<Scalar>());
90}
91
111template<typename Derived>
112inline const typename DenseBase<Derived>::RandomReturnType
114{
115 return NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, internal::scalar_random_op<Scalar>());
116}
117
130template<typename Derived>
131EIGEN_DEVICE_FUNC inline Derived& DenseBase<Derived>::setRandom()
132{
133 return *this = Random(rows(), cols());
134}
135
149template<typename Derived>
150EIGEN_STRONG_INLINE Derived&
152{
153 resize(newSize);
154 return setRandom();
155}
156
172template<typename Derived>
173EIGEN_STRONG_INLINE Derived&
175{
176 resize(rows, cols);
177 return setRandom();
178}
179
191template<typename Derived>
192EIGEN_STRONG_INLINE Derived&
194{
195 return setRandom(rows(), cols);
196}
197
209template<typename Derived>
210EIGEN_STRONG_INLINE Derived&
212{
213 return setRandom(rows, cols());
214}
215
216} // end namespace Eigen
217
218#endif // EIGEN_RANDOM_H
Generic expression of a matrix where all coefficients are defined by a functor.
Definition: CwiseNullaryOp.h:61
Base class for all dense matrices, vectors, and arrays.
Definition: DenseBase.h:47
Dense storage base class for matrices and arrays.
Definition: PlainObjectBase.h:100
Namespace containing all symbols from the Eigen library.
Definition: Core:141
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74