2 #include "Teuchos_LAPACK.hpp"
15 std::vector<Real>
dl_;
21 std::vector<Real>
du_;
41 lapack_.GTTRF(n_,&dl_[0],&d_[0],&du_[0],&du2_[0],&ipiv_[0],&info_);
45 void solve(ROL::Ptr<
const std::vector<Real> > fp, ROL::Ptr<std::vector<Real> > up) {
46 for(
int i=0;i<n_;++i) {
49 lapack_.GTTRS(
'n',n_,1,&dl_[0],&d_[0],&du_[0],&du2_[0],&ipiv_[0],&(*up)[0],n_,&info_);
53 void solve(ROL::Ptr<std::vector<Real> > up) {
54 lapack_.GTTRS(
'n',n_,1,&dl_[0],&d_[0],&du_[0],&du2_[0],&ipiv_[0],&(*up)[0],n_,&info_);
58 void apply(ROL::Ptr<
const std::vector<Real> > up, ROL::Ptr<std::vector<Real> > fp) {
59 (*fp)[0] = (2.0*(*up)[0]-(*up)[1])/dx2_;
61 for(
int i=1;i<n_-1;++i) {
62 (*fp)[i] = (2.0*(*up)[i]-(*up)[i-1]-(*up)[i+1])/dx2_;
64 (*fp)[n_-1] = (2.0*(*up)[n_-1]-(*up)[n_-2])/dx2_;
68 void apply(ROL::Ptr<std::vector<Real> > fp) {
70 ROL::Ptr<std::vector<Real> > up = ROL::makePtr<std::vector<Real>>(n_, 0.0);
71 for(
int i=0;i<n_;++i) {
75 (*fp)[0] = (2.0*(*up)[0]-(*up)[1])/dx2_;
76 for(
int i=1;i<n_-1;++i) {
77 (*fp)[i] = (2.0*(*up)[i]-(*up)[i-1]-(*up)[i+1])/dx2_;
79 (*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''.