1 #include"Teuchos_LAPACK.hpp"
4 #ifndef __LINEAR_ALGEBRA__
5 #define __LINEAR_ALGEBRA__
15 void trisolve(ROL::Ptr<Teuchos::LAPACK<int,Real> > lapack,
16 const std::vector<Real>& a,
17 const std::vector<Real>& b,
18 const std::vector<Real>& c,
19 const std::vector<Real>& r,
20 std::vector<Real>& x ) {
22 const char TRANS =
'N';
23 const int N = b.size();
27 std::vector<Real> dl(a);
28 std::vector<Real> d(b);
29 std::vector<Real> du(c);
30 std::vector<Real> du2(N-2,0.0);
31 std::vector<int> ipiv(N);
34 lapack->GTTRF(N,&dl[0],&d[0],&du[0],&du2[0],&ipiv[0],&info);
39 lapack->GTTRS(TRANS,N,NRHS,&dl[0],&d[0],&du[0],&du2[0],&ipiv[0],&x[0],N,&info);
50 void lusolve(ROL::Ptr<Teuchos::LAPACK<int,Real> > lapack,
51 const std::vector<Real> &A,
52 const std::vector<Real> &B,
53 std::vector<Real> &X) {
55 const char TRANS =
'N';
56 const int N2 = A.size();
57 const int N = sqrt(N2);
58 const int M = int(B.size()/N);
61 std::vector<int> ipiv(N);
62 std::vector<Real> PLU(A);
66 lapack->GETRF(N,N,&PLU[0],LDA,&ipiv[0],&info);
69 lapack->GETRS(TRANS,N,M,&PLU[0],LDA,&ipiv[0],&X[0],LDA,&info);
81 void cholsolve(ROL::Ptr<Teuchos::LAPACK<int,Real> > lapack,
82 const std::vector<Real> &A,
83 const std::vector<Real> &B,
84 std::vector<Real> &X) {
86 const char UPLO =
'U';
87 const int N2 = A.size();
88 const int N = sqrt(N2);
89 const int M = int(B.size()/N);
92 std::vector<Real> C(A);
96 lapack->POTRF(UPLO,N,&C[0],LDA,&info);
99 lapack->POTRS(UPLO,N,&C[0],LDA,&X[0],LDA,&info);
void trisolve(ROL::Ptr< Teuchos::LAPACK< int, Real > > lapack, const std::vector< Real > &a, const std::vector< Real > &b, const std::vector< Real > &c, const std::vector< Real > &r, std::vector< Real > &x)
Solve a tridiagonal system.
void cholsolve(ROL::Ptr< Teuchos::LAPACK< int, Real > > lapack, const std::vector< Real > &A, const std::vector< Real > &B, std::vector< Real > &X)
void lusolve(ROL::Ptr< Teuchos::LAPACK< int, Real > > lapack, const std::vector< Real > &A, const std::vector< Real > &B, std::vector< Real > &X)