Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stokhos_JacobiPreconditioner.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Stokhos Package
4 //
5 // Copyright 2009 NTESS and the Stokhos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef STOKHOS_JACOBIPRECONDITIONER_HPP
11 #define STOKHOS_JACOBIPRECONDITIONER_HPP
12 
13 #include "Teuchos_RCP.hpp"
14 #include "Stokhos_Operator.hpp"
16 
17 namespace Stokhos {
18 
19  template <typename ordinal_type, typename value_type>
21  public Stokhos::Operator<ordinal_type,value_type> {
22 
23  public:
24 
28 
30  virtual ~JacobiPreconditioner() {}
31 
35  ordinal_type m) const {
36  ordinal_type n=Input.numRows();
39  for (ordinal_type j=0; j<m; j++){
40  if (j==0){ // Compute z=D-1r
41  for (ordinal_type i=0; i<n; i++)
42  z(i,0)=Input(i,0)/A(i,i);
43  }
44  else {
45  //Compute G=invD(-L-U)=I-inv(D)A
46  for (ordinal_type i=0; i<n; i++){
47  for (ordinal_type j=0; j<n; j++){
48  if (j==i)
49  G(i,j)=0;
50  else
51  G(i,j)=-A(i,j)/A(i,i);
52  }
53  }
54 
55  Result.assign(z);
56  //z=Gz+inv(D)r
57  Result.multiply(Teuchos::NO_TRANS,Teuchos::NO_TRANS,1.0, G, z, 1.0);
58 
59  }
60  }
61 
62  return 0;
63  }
64 
65  protected:
67  }; // class JacobiPreconditioner
68 
69 } // namespace Stokhos
70 
71 #endif // STOKHOS_JACOBIPRECONDITIONER_HPP
72 
JacobiPreconditioner(const Teuchos::SerialDenseMatrix< ordinal_type, value_type > &A_)
Constructor.
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...
int multiply(ETransp transa, ETransp transb, ScalarType alpha, const SerialDenseMatrix< OrdinalType, ScalarType > &A, const SerialDenseMatrix< OrdinalType, ScalarType > &B, ScalarType beta)
const Teuchos::SerialDenseMatrix< ordinal_type, value_type > & A
SerialDenseMatrix< OrdinalType, ScalarType > & assign(const SerialDenseMatrix< OrdinalType, ScalarType > &Source)
int n
OrdinalType numRows() const