ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
vector
ROL_RandomVector.hpp
Go to the documentation of this file.
1
// @HEADER
2
// *****************************************************************************
3
// Rapid Optimization Library (ROL) Package
4
//
5
// Copyright 2014 NTESS and the ROL contributors.
6
// SPDX-License-Identifier: BSD-3-Clause
7
// *****************************************************************************
8
// @HEADER
9
10
#ifndef ROL_RANDOMVECTOR_H
11
#define ROL_RANDOMVECTOR_H
12
13
#include "
ROL_Vector.hpp
"
14
#include "
ROL_BoundConstraint.hpp
"
15
#include "ROL_Elementwise_Function.hpp"
16
17
18
namespace
ROL
{
19
28
29
template
<
class
Real>
30
void
RandomizeVector
(
Vector<Real>
&x,
const
Real &lower=0.0,
const
Real &upper=1.0 ) {
31
32
Elementwise::UniformlyRandom<Real> ur(lower,upper);
33
x.
applyUnary
(ur);
34
}
35
43
44
template
<
class
Real>
45
void
RandomizeFeasibleVector
(
Vector<Real>
&x,
BoundConstraint<Real>
&bnd ) {
46
const
ROL::Ptr<const Vector<Real> > u = bnd.
getUpperBound
();
47
const
ROL::Ptr<const Vector<Real> > l = bnd.
getLowerBound
();
48
49
Elementwise::UniformlyRandomMultiply<Real> urm;
50
51
x.
set
(*u);
52
x.
axpy
(-1.0,*l);
53
x.
applyUnary
(urm);
54
x.
plus
(*l);
55
}
56
57
58
}
// namespace ROL
59
60
#endif
// ROL_RANDOMVECTOR_H
ROL_BoundConstraint.hpp
ROL_Vector.hpp
ROL::BoundConstraint
Provides the interface to apply upper and lower bound constraints.
Definition
ROL_BoundConstraint.hpp:39
ROL::BoundConstraint::getLowerBound
virtual const Ptr< const Vector< Real > > getLowerBound(void) const
Return the ref count pointer to the lower bound vector.
Definition
ROL_BoundConstraint_Def.hpp:82
ROL::BoundConstraint::getUpperBound
virtual const Ptr< const Vector< Real > > getUpperBound(void) const
Return the ref count pointer to the upper bound vector.
Definition
ROL_BoundConstraint_Def.hpp:90
ROL::Vector
Defines the linear algebra or vector space interface.
Definition
ROL_Vector.hpp:51
ROL::Vector::set
virtual void set(const Vector &x)
Set where .
Definition
ROL_Vector.hpp:176
ROL::Vector::applyUnary
virtual void applyUnary(const Elementwise::UnaryFunction< Real > &f)
Definition
ROL_Vector.hpp:209
ROL::Vector::plus
virtual void plus(const Vector &x)=0
Compute , where .
ROL::Vector::axpy
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
Definition
ROL_Vector.hpp:120
ROL::RandomizeVector
void RandomizeVector(Vector< Real > &x, const Real &lower=0.0, const Real &upper=1.0)
Fill a ROL::Vector with uniformly-distributed random numbers in the interval [lower,...
Definition
ROL_RandomVector.hpp:30
ROL::RandomizeFeasibleVector
void RandomizeFeasibleVector(Vector< Real > &x, BoundConstraint< Real > &bnd)
Fill a ROL::Vector with uniformly-distributed random numbers which satisfy the supplied bound constra...
Definition
ROL_RandomVector.hpp:45
ROL
Definition
ROL_ElementwiseVector.hpp:27
Generated by
1.17.0