本文整理汇总了C++中teuchos::LAPACK::PTTRS方法的典型用法代码示例。如果您正苦于以下问题:C++ LAPACK::PTTRS方法的具体用法?C++ LAPACK::PTTRS怎么用?C++ LAPACK::PTTRS使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类teuchos::LAPACK
的用法示例。
在下文中一共展示了LAPACK::PTTRS方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: solve_adjoint_sensitivity
void solve_adjoint_sensitivity(std::vector<std::vector<Real> > &P, const std::vector<std::vector<Real> > &U) {
// Get Diagonal and Off-Diagonal Entries of PDE Jacobian
std::vector<Real> d(nx_,4.0*dx_/6.0 + dt_*2.0/dx_);
d[0] = dx_/3.0 + dt_/dx_;
d[nx_-1] = dx_/3.0 + dt_/dx_;
std::vector<Real> o(nx_-1,dx_/6.0 - dt_/dx_);
// Perform LDL factorization
Teuchos::LAPACK<int,Real> lp;
int info;
int ldb = nx_;
int nhrs = 1;
lp.PTTRF(nx_,&d[0],&o[0],&info);
// Initialize State Storage
P.clear();
P.resize(nt_);
// Time Step Using Implicit Euler
std::vector<Real> b(nx_,0.0);
for ( uint t = nt_; t > 0; t-- ) {
// Get Right Hand Side
if ( t == nt_ ) {
apply_mass(b,U[t-1]);
}
else {
apply_mass(b,P[t]);
}
// Solve Tridiagonal System Using LAPACK's SPD Tridiagonal Solver
lp.PTTRS(nx_,nhrs,&d[0],&o[0],&b[0],ldb,&info);
// Update State Storage
(P[t-1]).assign(b.begin(),b.end());
}
}
示例2: solve_state
void solve_state(std::vector<std::vector<Real> > &U, const std::vector<Real> &z) {
// Get Diagonal and Off-Diagonal Entries of PDE Jacobian
std::vector<Real> d(nx_,4.0*dx_/6.0 + dt_*2.0/dx_);
d[0] = dx_/3.0 + dt_/dx_;
d[nx_-1] = dx_/3.0 + dt_/dx_;
std::vector<Real> o(nx_-1,dx_/6.0 - dt_/dx_);
// Perform LDL factorization
Teuchos::LAPACK<int,Real> lp;
int info;
int ldb = nx_;
int nhrs = 1;
lp.PTTRF(nx_,&d[0],&o[0],&info);
// Initialize State Storage
U.clear();
U.resize(nt_+1);
(U[0]).assign(u0_.begin(),u0_.end());
// Time Step Using Implicit Euler
std::vector<Real> b(nx_,0.0);
for ( uint t = 0; t < nt_; t++ ) {
// Get Right Hand Side
apply_mass(b,U[t]);
b[nx_-1] += dt_*z[t];
// Solve Tridiagonal System Using LAPACK's SPD Tridiagonal Solver
lp.PTTRS(nx_,nhrs,&d[0],&o[0],&b[0],ldb,&info);
// Update State Storage
(U[t+1]).assign(b.begin(),b.end());
}
}