53 #ifndef ROL_LEASTSQUARES_HPP
54 #define ROL_LEASTSQUARES_HPP
71 ROL::Ptr<const std::vector<Real> > ex
75 Real h = 1.0/((Real)n+1.0);
78 for (
uint i=0; i<n; i++) {
80 res = 2.0*h*(5.0/6.0) + 1.0/h*((*ex)[i+1]-2.0*(*ex)[i]);
82 else if ( i == n-1 ) {
83 res = 2.0*h*(5.0/6.0) + 1.0/h*((*ex)[i-1]-2.0*(*ex)[i]);
86 res = 2.0*h + 1.0/h*((*ex)[i-1]-2.0*(*ex)[i]+(*ex)[i+1]);
94 ROL::Ptr<std::vector<Real> > eg
96 ROL::Ptr<const std::vector<Real> > ex
100 Real h = 1.0/((Real)n+1.0);
101 std::vector<Real> res(n,0.0);
102 for (
uint i=0; i<n; i++) {
104 res[i] = 2.0*h*(5.0/6.0) + 1.0/h*((*ex)[i+1]-2.0*(*ex)[i]);
106 else if ( i == n-1 ) {
107 res[i] = 2.0*h*(5.0/6.0) + 1.0/h*((*ex)[i-1]-2.0*(*ex)[i]);
110 res[i] = 2.0*h + 1.0/h*((*ex)[i-1]-2.0*(*ex)[i]+(*ex)[i+1]);
114 for (
uint i=0; i<n; i++) {
116 (*eg)[i] = 1.0/h*(res[i+1]-2.0*res[i]);
118 else if ( i == n-1 ) {
119 (*eg)[i] = 1.0/h*(res[i-1]-2.0*res[i]);
122 (*eg)[i] = 1.0/h*(res[i-1]-2.0*res[i]+res[i+1]);
128 ROL::Ptr<std::vector<Real> > ehv
130 ROL::Ptr<const std::vector<Real> > ev
132 ROL::Ptr<const std::vector<Real> > ex
136 Real h = 1.0/((Real)n+1.0);
137 std::vector<Real> res(n,0.0);
138 for (
uint i=0; i<n; i++) {
140 res[i] = 1.0/h*((*ev)[i+1]-2.0*(*ev)[i]);
142 else if ( i == n-1 ) {
143 res[i] = 1.0/h*((*ev)[i-1]-2.0*(*ev)[i]);
146 res[i] = 1.0/h*((*ev)[i-1]-2.0*(*ev)[i]+(*ev)[i+1]);
150 for (
uint i=0; i<n; i++) {
152 (*ehv)[i] = 1.0/h*(res[i+1]-2.0*res[i]);
154 else if ( i == n-1 ) {
155 (*ehv)[i] = 1.0/h*(res[i-1]-2.0*res[i]);
158 (*ehv)[i] = 1.0/h*(res[i-1]-2.0*res[i]+res[i+1]);
172 return ROL::makePtr<Objective_LeastSquares<Real>>();
179 ROL::Ptr<std::vector<Real> > x0p = ROL::makePtr<std::vector<Real>>(n,0.0);
180 for (
int i = 0; i < n; i++ ) {
183 return ROL::makePtr<StdVector<Real>>(x0p);
190 ROL::Ptr<std::vector<Real> > xp = ROL::makePtr<std::vector<Real>>(n,0.0);
191 Real h = 1.0/((Real)n+1.0), pt = 0.0;
192 for(
int i = 0; i < n; i++ ) {
194 (*xp)[i] = pt*(1.0-pt);
196 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