327GMRES(
const Teuchos::SerialDenseMatrix<ordinal_type, value_type> &
A,
328 Teuchos::SerialDenseMatrix<ordinal_type,value_type> &
X,
329 const Teuchos::SerialDenseMatrix<ordinal_type,value_type> &
B,
336 const Teuchos::SerialDenseMatrix<ordinal_type, value_type> &
M,
342 Teuchos::SerialDenseMatrix<ordinal_type, value_type> P(n,n);
343 Teuchos::SerialDenseMatrix<ordinal_type, value_type> Ax(n,1);
344 Ax.multiply(Teuchos::NO_TRANS,Teuchos::NO_TRANS,1.0,
A,
X, 0.0);
345 Teuchos::SerialDenseMatrix<ordinal_type, value_type> r0(Teuchos::Copy,
B);
347 resid=r0.normFrobenius();
349 Teuchos::SerialDenseMatrix<ordinal_type, value_type> v(n,1);
351 Teuchos::SerialDenseMatrix<ordinal_type, value_type> h(1,1);
353 Teuchos::SerialDenseMatrix<ordinal_type, value_type> V(n,1);
359 Teuchos::SerialDenseMatrix<ordinal_type, value_type> bb(1,1);
361 Teuchos::SerialDenseMatrix<ordinal_type, value_type> w(n,1);
362 Teuchos::SerialDenseMatrix<ordinal_type, value_type> c;
363 Teuchos::SerialDenseMatrix<ordinal_type, value_type> s;
364 while (resid > tolerance && k < max_iter){
369 Teuchos::SerialDenseMatrix<ordinal_type, value_type> vk(Teuchos::Copy, V, n,1,0,k-1);
371 Teuchos::SerialDenseMatrix<ordinal_type, value_type> z(vk);
389 w.multiply(Teuchos::NO_TRANS, Teuchos::NO_TRANS, 1,
A, z, 0.0);
390 Teuchos::SerialDenseMatrix<ordinal_type, value_type> vi(n,1);
391 Teuchos::SerialDenseMatrix<ordinal_type, value_type> ip(1,1);
394 Teuchos::SerialDenseMatrix<ordinal_type, value_type> vi(Teuchos::Copy, V, n,1,0,i);
396 ip.multiply(Teuchos::TRANS, Teuchos::NO_TRANS, 1.0, vi, w, 0.0);
402 h(k,k-1)=w.normFrobenius();
403 w.scale(1.0/h(k,k-1));
411 value_type q=c(i,0)*h(i,k-1)+s(i,0)*h(i+1,k-1);
412 h(i+1,k-1)=-1*s(i,0)*h(i,k-1)+c(i,0)*h(i+1,k-1);
421 c(k-1,0)=h(k-1,k-1)/l;
428 bb(k,0)=-s(k-1,0)*bb(k-1,0);
429 bb(k-1,0)=c(k-1,0)*bb(k-1,0);
432 resid =
fabs(bb(k,0));
436 bb.reshape(h.numRows()-1 ,1);
439 Teuchos::LAPACK<ordinal_type, value_type> lapack;
440 lapack.TRTRS(
'U',
'N',
'N', h.numRows()-1, 1, h.values(), h.stride(), bb.values(), bb.stride(),&info);
441 Teuchos::SerialDenseMatrix<ordinal_type, value_type> ans(
X);
443 ans.multiply(Teuchos::NO_TRANS, Teuchos::NO_TRANS, 1.0, V, bb, 0.0);
GMRESDivisionExpansionStrategy(const Teuchos::RCP< const Stokhos::OrthogPolyBasis< ordinal_type, value_type > > &basis_, const Teuchos::RCP< const Stokhos::Sparse3Tensor< ordinal_type, value_type > > &Cijk_, const ordinal_type prec_iter_, const value_type tol_, const ordinal_type PrecNum_, const ordinal_type max_it_, const ordinal_type linear_, const ordinal_type diag_, const ordinal_type equil_)
Constructor.
ordinal_type GMRES(const Teuchos::SerialDenseMatrix< ordinal_type, value_type > &A, Teuchos::SerialDenseMatrix< ordinal_type, value_type > &X, const Teuchos::SerialDenseMatrix< ordinal_type, value_type > &B, ordinal_type max_iter, value_type tolerance, ordinal_type prec_iter, ordinal_type order, ordinal_type dim, ordinal_type PrecNum, const Teuchos::SerialDenseMatrix< ordinal_type, value_type > &M, ordinal_type diag)
virtual void divide(Stokhos::OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const value_type &alpha, const Stokhos::OrthogPolyApprox< ordinal_type, value_type, node_type > &a, const Stokhos::OrthogPolyApprox< ordinal_type, value_type, node_type > &b, const value_type &beta)