11 #include "Teuchos_LAPACK.hpp"
24 std::vector<Real>
dl_;
30 std::vector<Real>
du_;
50 lapack_.GTTRF(n_,&dl_[0],&d_[0],&du_[0],&du2_[0],&ipiv_[0],&info_);
54 void solve(ROL::Ptr<
const std::vector<Real> > fp, ROL::Ptr<std::vector<Real> > up) {
55 for(
int i=0;i<n_;++i) {
58 lapack_.GTTRS(
'n',n_,1,&dl_[0],&d_[0],&du_[0],&du2_[0],&ipiv_[0],&(*up)[0],n_,&info_);
62 void solve(ROL::Ptr<std::vector<Real> > up) {
63 lapack_.GTTRS(
'n',n_,1,&dl_[0],&d_[0],&du_[0],&du2_[0],&ipiv_[0],&(*up)[0],n_,&info_);
67 void apply(ROL::Ptr<
const std::vector<Real> > up, ROL::Ptr<std::vector<Real> > fp) {
68 (*fp)[0] = (2.0*(*up)[0]-(*up)[1])/dx2_;
70 for(
int i=1;i<n_-1;++i) {
71 (*fp)[i] = (2.0*(*up)[i]-(*up)[i-1]-(*up)[i+1])/dx2_;
73 (*fp)[n_-1] = (2.0*(*up)[n_-1]-(*up)[n_-2])/dx2_;
77 void apply(ROL::Ptr<std::vector<Real> > fp) {
79 ROL::Ptr<std::vector<Real> > up = ROL::makePtr<std::vector<Real>>(n_, 0.0);
80 for(
int i=0;i<n_;++i) {
84 (*fp)[0] = (2.0*(*up)[0]-(*up)[1])/dx2_;
85 for(
int i=1;i<n_-1;++i) {
86 (*fp)[i] = (2.0*(*up)[i]-(*up)[i-1]-(*up)[i+1])/dx2_;
88 (*fp)[n_-1] = (2.0*(*up)[n_-1]-(*up)[n_-2])/dx2_;
FiniteDifference(int n, double dx)
void solve(ROL::Ptr< std::vector< Real > > up)
Same as above but with overwrite in place.
void solve(ROL::Ptr< const std::vector< Real > > fp, ROL::Ptr< std::vector< Real > > up)
Given f, compute -u''=f.
Teuchos::LAPACK< int, Real > lapack_
void apply(ROL::Ptr< std::vector< Real > > fp)
Same as above but with overwrite in place.
void apply(ROL::Ptr< const std::vector< Real > > up, ROL::Ptr< std::vector< Real > > fp)
Given u, compute f = -u''.