4 #include"Teuchos_LAPACK.hpp" 6 #ifndef __INNER_PRODUCT_MATRIX__ 7 #define __INNER_PRODUCT_MATRIX__ 14 const std::vector<Real> &V,
15 const std::vector<Real> &w,
19 const std::vector<Real> &V,
20 const std::vector<Real> &w,
21 const std::vector<Real> &a);
25 void update(
const std::vector<Real> &a);
29 void apply(Teuchos::RCP<
const std::vector<Real> > xp,
30 Teuchos::RCP<std::vector<Real> > bp);
32 void applyadd(Teuchos::RCP<
const std::vector<Real> > xp,
33 Teuchos::RCP<std::vector<Real> > bp);
36 Teuchos::RCP<std::vector<Real> > bp, Real factor);
39 Real
inner(Teuchos::RCP<
const std::vector<Real> > up,
40 Teuchos::RCP<
const std::vector<Real> > vp);
43 virtual void solve(Teuchos::RCP<
const std::vector<Real> > bp,
44 Teuchos::RCP<std::vector<Real> > xp){};
47 virtual Real
inv_inner(Teuchos::RCP<
const std::vector<Real> > up,
48 Teuchos::RCP<
const std::vector<Real> > vp){
54 const std::vector<Real>
U_;
55 const std::vector<Real>
V_;
56 const std::vector<Real>
w_;
67 const std::vector<Real> &V,
68 const std::vector<Real> &w,
72 for(
int i=0;i<
ni_;++i) {
73 for(
int j=0;j<
ni_;++j) {
74 for(
int k=0;k<
nq_;++k) {
83 const std::vector<Real> &V,
84 const std::vector<Real> &w,
85 const std::vector<Real> &a ) :
88 for(
int i=0;i<
ni_;++i) {
89 for(
int j=0;j<
ni_;++j) {
90 for(
int k=0;k<
nq_;++k) {
103 Teuchos::RCP<std::vector<Real> > bp ) {
104 for(
int i=0;i<
ni_;++i) {
106 for(
int j=0;j<
ni_;++j ) {
107 (*bp)[i] +=
M_[i+ni_*j]*(*xp)[j];
114 Teuchos::RCP<std::vector<Real> > bp ) {
115 for(
int i=0;i<
ni_;++i) {
116 for(
int j=0;j<
ni_;++j ) {
117 (*bp)[i] +=
M_[i+ni_*j]*(*xp)[j];
124 Teuchos::RCP<std::vector<Real> > bp, Real factor ) {
125 for(
int i=0;i<
ni_;++i) {
126 for(
int j=0;j<
ni_;++j ) {
127 (*bp)[i] += factor*
M_[i+ni_*j]*(*xp)[j];
135 std::fill(
M_.begin(),
M_.end(),0);
136 for(
int i=0;i<
ni_;++i) {
137 for(
int j=0;j<
ni_;++j) {
138 for(
int k=0;k<
nq_;++k) {
152 Teuchos::RCP<
const std::vector<Real> > vp ) {
154 Teuchos::RCP<std::vector<Real> > Mvp = Teuchos::rcp(
new std::vector<Real> (
ni_,0) );
156 for(
int i=0;i<
ni_;++i) {
157 J += (*up)[i]*(*Mvp)[i];
171 Teuchos::RCP<Teuchos::LAPACK<int,Real> >
lapack_;
174 std::vector<Real>
M_;
184 const std::vector<Real> &U=std::vector<Real>(),
185 const std::vector<Real> &V=std::vector<Real>(),
186 const std::vector<Real> &w=std::vector<Real>(),
190 const std::vector<Real> &U=std::vector<Real>(),
191 const std::vector<Real> &V=std::vector<Real>(),
192 const std::vector<Real> &w=std::vector<Real>(),
193 const std::vector<Real> &a=std::vector<Real>());
195 void solve(Teuchos::RCP<
const std::vector<Real> > bp,
196 Teuchos::RCP<std::vector<Real> > xp);
198 Real
inv_inner(Teuchos::RCP<
const std::vector<Real> > up,
199 Teuchos::RCP<
const std::vector<Real> > vp);
205 const std::vector<Real> &U,
206 const std::vector<Real> &V,
207 const std::vector<Real> &w,
214 TRANS_(
'N'), ipiv_(ni_,0), PLU_(ni_*ni_,0),
219 lapack->GETRF(ni_,ni_,&PLU_[0],ni_,&ipiv_[0],&info_);
225 const std::vector<Real> &U,
226 const std::vector<Real> &V,
227 const std::vector<Real> &w,
228 const std::vector<Real> &a):
234 TRANS_(
'N'), ipiv_(ni_,0), PLU_(ni_*ni_,0),
239 lapack->GETRF(ni_,ni_,&PLU_[0],ni_,&ipiv_[0],&info_);
246 Teuchos::RCP<std::vector<Real> > xp){
248 int nrhs = bp->size()/
ni_;
253 lapack_->GETRS(TRANS_,ni_,nrhs,&PLU_[0],ni_,&ipiv_[0],&(*xp)[0],ni_,&info_);
260 Teuchos::RCP<
const std::vector<Real> > vp ) {
262 Teuchos::RCP<std::vector<Real> > Mivp = Teuchos::rcp(
new std::vector<Real> (ni_,0) );
263 this->
solve(vp,Mivp);
264 for(
int i=0;i<
ni_;++i) {
266 J += (*up)[i]*(*Mivp)[i];
InnerProductMatrixSolver(Teuchos::RCP< Teuchos::LAPACK< int, Real > > lapack, const std::vector< Real > &U=std::vector< Real >(), const std::vector< Real > &V=std::vector< Real >(), const std::vector< Real > &w=std::vector< Real >(), const int a=1)
void applyaddtimes(Teuchos::RCP< const std::vector< Real > > xp, Teuchos::RCP< std::vector< Real > > bp, Real factor)
const std::vector< Real > U_
Teuchos::RCP< Teuchos::LAPACK< int, Real > > lapack_
void apply(Teuchos::RCP< const std::vector< Real > > xp, Teuchos::RCP< std::vector< Real > > bp)
const std::vector< Real > w_
InnerProductMatrix(const std::vector< Real > &U, const std::vector< Real > &V, const std::vector< Real > &w, const int a=1)
virtual void solve(Teuchos::RCP< const std::vector< Real > > bp, Teuchos::RCP< std::vector< Real > > xp)
const std::vector< Real > V_
void solve(Teuchos::RCP< const std::vector< Real > > bp, Teuchos::RCP< std::vector< Real > > xp)
solve for
virtual Real inv_inner(Teuchos::RCP< const std::vector< Real > > up, Teuchos::RCP< const std::vector< Real > > vp)
This class adds a solve method.
Real inner(Teuchos::RCP< const std::vector< Real > > up, Teuchos::RCP< const std::vector< Real > > vp)
Compute the inner product .
virtual ~InnerProductMatrix()
void applyadd(Teuchos::RCP< const std::vector< Real > > xp, Teuchos::RCP< std::vector< Real > > bp)
Real inv_inner(Teuchos::RCP< const std::vector< Real > > up, Teuchos::RCP< const std::vector< Real > > vp)
Compute the inner product .
void update(const std::vector< Real > &a)