Medial Code Documentation
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 template<typename Index>
20 inline const Scalar operator() (Index, Index = 0) const { return random<Scalar>(); }
21};
22
23template<typename Scalar>
25{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false, IsRepeatable = false }; };
26
27} // end namespace internal
28
55template<typename Derived>
56inline const typename DenseBase<Derived>::RandomReturnType
57DenseBase<Derived>::Random(Index rows, Index cols)
58{
59 return NullaryExpr(rows, cols, internal::scalar_random_op<Scalar>());
60}
61
86template<typename Derived>
87inline const typename DenseBase<Derived>::RandomReturnType
89{
90 return NullaryExpr(size, internal::scalar_random_op<Scalar>());
91}
92
112template<typename Derived>
113inline const typename DenseBase<Derived>::RandomReturnType
115{
116 return NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, internal::scalar_random_op<Scalar>());
117}
118
131template<typename Derived>
133{
134 return *this = Random(rows(), cols());
135}
136
150template<typename Derived>
151EIGEN_STRONG_INLINE Derived&
153{
154 resize(newSize);
155 return setRandom();
156}
157
173template<typename Derived>
174EIGEN_STRONG_INLINE Derived&
176{
177 resize(rows, cols);
178 return setRandom();
179}
180
181} // end namespace Eigen
182
183#endif // EIGEN_RANDOM_H
Base class for all dense matrices, vectors, and arrays.
Definition DenseBase.h:49
Dense storage base class for matrices and arrays.
Definition PlainObjectBase.h:93
Pseudo expression representing a solving operation.
Definition Solve.h:63
Holds information about the various numeric (i.e.
Definition NumTraits.h:108
Definition XprHelper.h:107
Definition Random.h:17