v1.0
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>
21
struct
scalar_random_op
{
22
inline
const
Scalar
operator()
()
const
{
return
random<Scalar>(); }
23
};
24
25
template
<
typename
Scalar>
26
struct
functor_traits
<
scalar_random_op
<
Scalar
> > {
27
enum
{
Cost
= 5 *
NumTraits<Scalar>::MulCost
,
PacketAccess
=
false
,
IsRepeatable
=
false
};
28
};
29
30
}
// end namespace internal
31
58
template
<
typename
Derived>
59
inline
const
typename
DenseBase<Derived>::RandomReturnType
DenseBase<Derived>::Random
(
Index
rows
,
Index
cols
) {
60
return
NullaryExpr(
rows
,
cols
,
internal::scalar_random_op<Scalar>
());
61
}
62
87
template
<
typename
Derived>
88
inline
const
typename
DenseBase<Derived>::RandomReturnType
DenseBase<Derived>::Random
(
Index
size
) {
89
return
NullaryExpr(
size
,
internal::scalar_random_op<Scalar>
());
90
}
91
111
template
<
typename
Derived>
112
inline
const
typename
DenseBase<Derived>::RandomReturnType
DenseBase<Derived>::Random
() {
113
return
NullaryExpr(RowsAtCompileTime, ColsAtCompileTime,
internal::scalar_random_op<Scalar>
());
114
}
115
128
template
<
typename
Derived>
129
EIGEN_DEVICE_FUNC
inline
Derived&
DenseBase<Derived>::setRandom
() {
130
return
*
this
= Random(
rows
(),
cols
());
131
}
132
146
template
<
typename
Derived>
147
EIGEN_STRONG_INLINE
Derived&
PlainObjectBase<Derived>::setRandom
(
Index
newSize) {
148
resize
(newSize);
149
return
setRandom
();
150
}
151
167
template
<
typename
Derived>
168
EIGEN_STRONG_INLINE
Derived&
PlainObjectBase<Derived>::setRandom
(
Index
rows
,
Index
cols
) {
169
resize
(
rows
,
cols
);
170
return
setRandom
();
171
}
172
184
template
<
typename
Derived>
185
EIGEN_STRONG_INLINE
Derived&
PlainObjectBase<Derived>::setRandom
(
NoChange_t
,
Index
cols
) {
186
return
setRandom
(
rows
(),
cols
);
187
}
188
200
template
<
typename
Derived>
201
EIGEN_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
setRandom
A setRandom()
EIGEN_DEVICE_FUNC
#define EIGEN_DEVICE_FUNC
Definition:
Macros.h:892
EIGEN_STRONG_INLINE
#define EIGEN_STRONG_INLINE
Definition:
Macros.h:834
resize
v resize(3)
rows
int rows
Definition:
Tutorial_commainit_02.cpp:1
cols
int cols
Definition:
Tutorial_commainit_02.cpp:1
size
Scalar Scalar int size
Definition:
benchVecAdd.cpp:17
Scalar
SCALAR Scalar
Definition:
bench_gemm.cpp:45
Eigen::CwiseNullaryOp
Generic expression of a matrix where all coefficients are defined by a functor.
Definition:
CwiseNullaryOp.h:64
Eigen::DenseBase::setRandom
EIGEN_DEVICE_FUNC Derived & setRandom()
Definition:
Random.h:129
Eigen::DenseBase::Random
static const RandomReturnType Random()
Definition:
Random.h:112
Eigen::PlainObjectBase::setRandom
Derived & setRandom(Index size)
Definition:
Random.h:147
Eigen
Namespace containing all symbols from the Eigen library.
Definition:
bench_norm.cpp:70
Eigen::NoChange_t
NoChange_t
Definition:
Constants.h:359
Eigen::Index
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition:
Meta.h:83
internal
Definition:
Eigen_Colamd.h:49
Eigen::NumTraits
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition:
NumTraits.h:217
Eigen::internal::functor_traits
Definition:
XprHelper.h:205
Eigen::internal::functor_traits::PacketAccess
@ PacketAccess
Definition:
XprHelper.h:206
Eigen::internal::functor_traits::Cost
@ Cost
Definition:
XprHelper.h:206
Eigen::internal::functor_traits::IsRepeatable
@ IsRepeatable
Definition:
XprHelper.h:206
Eigen::internal::scalar_random_op
Definition:
Random.h:21
Eigen::internal::scalar_random_op::operator()
const Scalar operator()() const
Definition:
Random.h:22
InternalHeaderCheck.h
Eigen
Eigen
src
Core
Random.h
Generated on Wed Aug 27 2025 17:02:21 for MercuryDPM by
1.9.1