19 #ifndef ROL_LEASTSQUARES_HPP
20 #define ROL_LEASTSQUARES_HPP
37 ROL::Ptr<const std::vector<Real> > ex
41 Real h = 1.0/((Real)n+1.0);
44 for (
uint i=0; i<n; i++) {
46 res = 2.0*h*(5.0/6.0) + 1.0/h*((*ex)[i+1]-2.0*(*ex)[i]);
48 else if ( i == n-1 ) {
49 res = 2.0*h*(5.0/6.0) + 1.0/h*((*ex)[i-1]-2.0*(*ex)[i]);
52 res = 2.0*h + 1.0/h*((*ex)[i-1]-2.0*(*ex)[i]+(*ex)[i+1]);
60 ROL::Ptr<std::vector<Real> > eg
62 ROL::Ptr<const std::vector<Real> > ex
66 Real h = 1.0/((Real)n+1.0);
67 std::vector<Real> res(n,0.0);
68 for (
uint i=0; i<n; i++) {
70 res[i] = 2.0*h*(5.0/6.0) + 1.0/h*((*ex)[i+1]-2.0*(*ex)[i]);
72 else if ( i == n-1 ) {
73 res[i] = 2.0*h*(5.0/6.0) + 1.0/h*((*ex)[i-1]-2.0*(*ex)[i]);
76 res[i] = 2.0*h + 1.0/h*((*ex)[i-1]-2.0*(*ex)[i]+(*ex)[i+1]);
80 for (
uint i=0; i<n; i++) {
82 (*eg)[i] = 1.0/h*(res[i+1]-2.0*res[i]);
84 else if ( i == n-1 ) {
85 (*eg)[i] = 1.0/h*(res[i-1]-2.0*res[i]);
88 (*eg)[i] = 1.0/h*(res[i-1]-2.0*res[i]+res[i+1]);
94 ROL::Ptr<std::vector<Real> > ehv
96 ROL::Ptr<const std::vector<Real> > ev
98 ROL::Ptr<const std::vector<Real> > ex
102 Real h = 1.0/((Real)n+1.0);
103 std::vector<Real> res(n,0.0);
104 for (
uint i=0; i<n; i++) {
106 res[i] = 1.0/h*((*ev)[i+1]-2.0*(*ev)[i]);
108 else if ( i == n-1 ) {
109 res[i] = 1.0/h*((*ev)[i-1]-2.0*(*ev)[i]);
112 res[i] = 1.0/h*((*ev)[i-1]-2.0*(*ev)[i]+(*ev)[i+1]);
116 for (
uint i=0; i<n; i++) {
118 (*ehv)[i] = 1.0/h*(res[i+1]-2.0*res[i]);
120 else if ( i == n-1 ) {
121 (*ehv)[i] = 1.0/h*(res[i-1]-2.0*res[i]);
124 (*ehv)[i] = 1.0/h*(res[i-1]-2.0*res[i]+res[i+1]);
138 return ROL::makePtr<Objective_LeastSquares<Real>>();
145 ROL::Ptr<std::vector<Real> > x0p = ROL::makePtr<std::vector<Real>>(n,0.0);
146 for (
int i = 0; i < n; i++ ) {
149 return ROL::makePtr<StdVector<Real>>(x0p);
156 ROL::Ptr<std::vector<Real> > xp = ROL::makePtr<std::vector<Real>>(n,0.0);
157 Real h = 1.0/((Real)n+1.0), pt = 0.0;
158 for(
int i = 0; i < n; i++ ) {
160 (*xp)[i] = pt*(1.0-pt);
162 return ROL::makePtr<StdVector<Real>>(xp);
Provides the interface to evaluate objective functions.
typename PV< Real >::size_type size_type
std::vector< Real >::size_type uint
virtual void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply Hessian approximation to vector.
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
Ptr< Objective< Real > > getObjective(void) const
Defines the linear algebra or vector space interface.
Real value(const Vector< Real > &x, Real &tol)
Compute value.
Ptr< Vector< Real > > getInitialGuess(void) const
Contains definitions of test objective functions.
Ptr< Vector< Real > > getSolution(const int i=0) const