10 #ifndef STOKHOS_GMRES_DIVISION_EXPANSION_STRATEGY_HPP
11 #define STOKHOS_GMRES_DIVISION_EXPANSION_STRATEGY_HPP
34 template <
typename ordinal_type,
typename value_type,
typename node_type>
120 template <
typename ordinal_type,
typename value_type,
typename node_type>
134 prec_iter(prec_iter_),
155 template <
typename ordinal_type,
typename value_type,
typename node_type>
164 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR
188 if (pb < Cijk->num_k())
189 k_end = Cijk->find_k(pb);
195 j_it != Cijk->j_end(k_it); ++j_it) {
198 i_it != Cijk->i_end(j_it); ++i_it) {
201 (*A)(i,
j) += cijk*cb[k];
209 (*
B)(i,0) = ca[i]*basis->norm_squared(i);
222 (*A)(i,
j)=(*
A)(i,
j)/(D(i,0)*D(j,0));
228 (*B)(i,0)=(*
B)(i,0)/D(i,0);
235 pb = basis->dimension()+1;
237 if (pb < Cijk->num_k())
238 k_end = Cijk->find_k(pb);
242 j_it != Cijk->j_end(k_it); ++j_it) {
245 i_it != Cijk->i_end(j_it); ++i_it) {
248 (*M)(i,
j) += cijk*cb[k];
258 (*M)(i,
j)=(*M)(i,
j)/(D(i,0)*D(j,0));
265 GMRES(*
A,*X,*
B, max_it, tol, prec_iter, basis->order(), basis->dimension(), PrecNum, *M,
diag);
269 GMRES(*
A,*X,*
B, max_it, tol, prec_iter, basis->order(), basis->dimension(), PrecNum, *
A,
diag);
275 (*X)(i,0)=(*X)(i,0)/D(i,0);
281 cc[i] = alpha*(*X)(i,0) + beta*cc[i];
285 cc[i] = alpha*ca[i]/cb[0] + beta*cc[i];
290 template <
typename ordinal_type,
typename value_type,
typename node_type>
330 while (resid > tolerance && k < max_iter){
342 else if (PrecNum == 2){
346 else if (PrecNum == 3){
350 else if (PrecNum == 4){
369 w.
scale(1.0/h(k,k-1));
377 value_type q=c(i,0)*h(i,k-1)+s(i,0)*h(i+1,k-1);
378 h(i+1,k-1)=-1*s(i,0)*h(i,k-1)+c(i,0)*h(i+1,k-1);
387 c(k-1,0)=h(k-1,k-1)/l;
394 bb(k,0)=-s(k-1,0)*bb(k-1,0);
395 bb(k-1,0)=c(k-1,0)*bb(k-1,0);
398 resid =
fabs(bb(k,0));
414 else if (PrecNum == 2){
418 else if (PrecNum == 3){
422 else if (PrecNum == 4){
432 #endif // STOKHOS_DIVISION_EXPANSION_STRATEGY_HPP
ScalarTraits< ScalarType >::magnitudeType normOne() const
ScalarType * values() const
KOKKOS_INLINE_FUNCTION PCE< Storage > sqrt(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > fabs(const PCE< Storage > &a)
#define TEUCHOS_FUNC_TIME_MONITOR(FUNCNAME)
void resize(ordinal_type sz)
Resize coefficient array (coefficients are preserved)
Teuchos::RCP< const Cijk_type > Cijk
Triple product.
virtual ordinal_type ApplyInverse(const Teuchos::SerialDenseMatrix< ordinal_type, value_type > &Input, Teuchos::SerialDenseMatrix< ordinal_type, value_type > &Result, ordinal_type m) const
Returns the result of a Operator inverse applied to a Teuchos::SerialDenseMatrix Input in Result...
Data structure storing a sparse 3-tensor C(i,j,k) in a a compressed format.
ordinal_type prec_iter
Tolerance for GMRES.
int multiply(ETransp transa, ETransp transb, ScalarType alpha, const SerialDenseMatrix< OrdinalType, ScalarType > &A, const SerialDenseMatrix< OrdinalType, ScalarType > &B, ScalarType beta)
void TRTRS(const char &UPLO, const char &TRANS, const char &DIAG, const OrdinalType &n, const OrdinalType &nrhs, const ScalarType *A, const OrdinalType &lda, ScalarType *B, const OrdinalType &ldb, OrdinalType *info) const
Stokhos::Sparse3Tensor< ordinal_type, value_type > Cijk_type
Short-hand for Cijk.
int scale(const ScalarType alpha)
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)
pointer coeff()
Return coefficient array.
Teuchos::RCP< const Stokhos::OrthogPolyBasis< ordinal_type, value_type > > basis
Basis.
ScalarTraits< ScalarType >::magnitudeType normFrobenius() const
virtual ordinal_type ApplyInverse(const Teuchos::SerialDenseMatrix< ordinal_type, value_type > &Input, Teuchos::SerialDenseMatrix< ordinal_type, value_type > &Result, ordinal_type m) const
Returns the result of a Operator inverse applied to a Teuchos::SerialDenseMatrix Input in Result...
Bi-directional iterator for traversing a sparse array.
Abstract base class for multivariate orthogonal polynomials.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::RCP< Teuchos::SerialDenseMatrix< ordinal_type, value_type > > B
virtual ordinal_type ApplyInverse(const Teuchos::SerialDenseMatrix< ordinal_type, value_type > &Input, Teuchos::SerialDenseMatrix< ordinal_type, value_type > &Result, ordinal_type prec_iters) const
Returns the result of a Operator inverse applied to a Teuchos::SerialDenseMatrix Input in Result...
int putScalar(const ScalarType value=Teuchos::ScalarTraits< ScalarType >::zero())
Strategy interface for computing PCE of a/b.
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)
virtual ordinal_type ApplyInverse(const Teuchos::SerialDenseMatrix< ordinal_type, value_type > &Input, Teuchos::SerialDenseMatrix< ordinal_type, value_type > &Result, ordinal_type m) const
Returns the result of a Operator inverse applied to a Teuchos::SerialDenseMatrix Input in Result...
Teuchos::RCP< Teuchos::SerialDenseMatrix< ordinal_type, value_type > > M
Teuchos::RCP< Teuchos::SerialDenseMatrix< ordinal_type, value_type > > X
KOKKOS_INLINE_FUNCTION constexpr std::enable_if< is_view_uq_pce< view_type >::value, typename CijkType< view_type >::type >::type cijk(const view_type &view)
Strategy interface for computing PCE of a/b using only b[0].
Class to store coefficients of a projection onto an orthogonal polynomial basis.
int reshape(OrdinalType numRows, OrdinalType numCols)
virtual ~GMRESDivisionExpansionStrategy()
Destructor.
ordinal_type size() const
Return size.
GMRESDivisionExpansionStrategy & operator=(const GMRESDivisionExpansionStrategy &b)
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.
OrdinalType stride() const
OrdinalType numRows() const
Teuchos::RCP< Teuchos::SerialDenseMatrix< ordinal_type, value_type > > A
Dense matrices for linear system.