44 #ifndef ROL_MEANVARIANCEFROMTARGET_HPP
45 #define ROL_MEANVARIANCEFROMTARGET_HPP
66 order_.push_back((order < 2.0) ? 2.0 : order);
68 coeff_.push_back((coeff < 0.0) ? 1.0 : coeff);
75 if ( order.size() != target.size() ) {
76 target.resize(order.size(),0.0);
78 if ( order.size() != coeff.size() ) {
79 coeff.resize(order.size(),1.0);
81 for (
unsigned i = 0; i < order.size(); i++ ) {
83 order_.push_back((order[i] < 2.0) ? 2.0 : order[i]);
84 coeff_.push_back((coeff[i] < 0.0) ? 1.0 : coeff[i]);
102 x0 = Teuchos::rcp(&
const_cast<Vector<Real> &
>(x),
false);
103 v0 = Teuchos::rcp(&
const_cast<Vector<Real> &
>(v),
false);
106 void update(
const Real val,
const Real weight) {
107 Real diff = 0.0, pf0 = 0.0;
109 for (
unsigned p = 0; p < this->
order_.size(); p++ ) {
117 Real diff = 0.0, pf0 = 0.0, pf1 = 0.0, c = 1.0;
118 for (
unsigned p = 0; p < this->
order_.size(); p++ ) {
129 Real diff = 0.0, pf0 = 0.0, pf1 = 0.0, pf2 = 0.0, p1 = 0.0, p2 = 0.0, ch = 1.0, cg = 0.0;
130 for (
unsigned p = 0; p < this->
order_.size(); p++ ) {
136 p1 = std::pow(pf0,this->
order_[p]-1.0);
137 p2 = std::pow(pf0,this->
order_[p]-2.0);
138 cg += this->
order_[p]*this->
coeff_[p]*gv*( (this->
order_[p]-1.0)*p2*pf1*pf1 + p1*pf2 );
148 sampler.
sumAll(&val,&ev,1);
void update(const Real val, const Vector< Real > &g, const Real gv, const Vector< Real > &hv, const Real weight)
void update(const Real val, const Vector< Real > &g, const Real weight)
virtual Teuchos::RCP< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
Defines the linear algebra or vector space interface.
void sumAll(Real *input, Real *output, int dim) const
MeanVarianceFromTarget(Real target, Real order, Real coeff, Teuchos::RCP< PositiveFunction< Real > > &pf)
std::vector< Real > target_
void getGradient(Vector< Real > &g, SampleGenerator< Real > &sampler)
MeanVarianceFromTarget(std::vector< Real > &target, std::vector< Real > &order, std::vector< Real > &coeff, Teuchos::RCP< PositiveFunction< Real > > &pf)
Teuchos::RCP< PositiveFunction< Real > > positiveFunction_
std::vector< Real > order_
void reset(Teuchos::RCP< Vector< Real > > &x0, const Vector< Real > &x)
void getHessVec(Vector< Real > &hv, SampleGenerator< Real > &sampler)
Real getValue(SampleGenerator< Real > &sampler)
std::vector< Real > coeff_
void update(const Real val, const Real weight)
void reset(Teuchos::RCP< Vector< Real > > &x0, const Vector< Real > &x, Teuchos::RCP< Vector< Real > > &v0, const Vector< Real > &v)