Ifpack Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Ifpack_Polynomial.h
Go to the documentation of this file.
1 /*@HEADER
2 // ***********************************************************************
3 //
4 // Ifpack: Object-Oriented Algebraic Preconditioner Package
5 // Copyright (2002) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ***********************************************************************
40 //@HEADER
41 */
42 
43 #ifndef IFPACK_POLYNOMIAL_H
44 #define IFPACK_POLYNOMIAL_H
45 
46 #if defined(Ifpack_SHOW_DEPRECATED_WARNINGS)
47 #ifdef __GNUC__
48 #warning "The Ifpack package is deprecated"
49 #endif
50 #endif
51 
52 #include "Ifpack_ConfigDefs.h"
53 #include "Ifpack_Preconditioner.h"
54 #include "Teuchos_RefCountPtr.hpp"
55 #include "Teuchos_LAPACK.hpp"
56 #include "Teuchos_SerialDenseMatrix.hpp"
57 
58 namespace Teuchos {
59  class ParameterList;
60 }
61 
62 class Epetra_MultiVector;
63 class Epetra_Vector;
64 class Epetra_Map;
65 class Epetra_Comm;
66 class Epetra_Time;
67 class Epetra_Vector;
68 class Epetra_Operator;
69 class Epetra_RowMatrix;
70 
71 #ifdef HAVE_IFPACK_EPETRAEXT
73 #endif
74 
76 
106 
107 public:
108 
110 
117 
119 
124  Ifpack_Polynomial(const Epetra_RowMatrix* Matrix);
125 
127  virtual ~Ifpack_Polynomial() {};
128 
130 
137  virtual inline int SetUseTranspose(bool UseTranspose_in)
138  {
139  UseTranspose_ = UseTranspose_in;
140  return(0);
141  }
142 
144 
146 
148 
156  virtual int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
157 
159 
169  virtual int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
170 
172  virtual double NormInf() const
173  {
174  return(-1.0);
175  }
177 
179 
180  virtual const char * Label() const
181  {
182  return(Label_.c_str());
183  }
184 
186  virtual bool UseTranspose() const
187  {
188  return(UseTranspose_);
189  }
190 
192  virtual bool HasNormInf() const
193  {
194  return(false);
195  }
196 
198  virtual const Epetra_Comm & Comm() const;
199 
201  virtual const Epetra_Map & OperatorDomainMap() const;
202 
204  virtual const Epetra_Map & OperatorRangeMap() const;
205 
206  virtual int Initialize();
207 
208  virtual bool IsInitialized() const
209  {
210  return(IsInitialized_);
211  }
212 
214  virtual inline bool IsComputed() const
215  {
216  return(IsComputed_);
217  }
218 
220  virtual int Compute();
221 
223 
224  virtual const Epetra_RowMatrix& Matrix() const
225  {
226  return(*Matrix_);
227  }
228 
230  virtual double Condest(const Ifpack_CondestType CT = Ifpack_Cheap,
231  const int MaxIters = 1550,
232  const double Tol = 1e-9,
233  Epetra_RowMatrix* Matrix_in = 0);
234 
236  virtual double Condest() const
237  {
238  return(Condest_);
239  }
240 
242  virtual int SetParameters(Teuchos::ParameterList& List);
243 
245  virtual std::ostream& Print(std::ostream & os) const;
246 
248 
250 
252  virtual int NumInitialize() const
253  {
254  return(NumInitialize_);
255  }
256 
258  virtual int NumCompute() const
259  {
260  return(NumCompute_);
261  }
262 
264  virtual int NumApplyInverse() const
265  {
266  return(NumApplyInverse_);
267  }
268 
270  virtual double InitializeTime() const
271  {
272  return(InitializeTime_);
273  }
274 
276  virtual double ComputeTime() const
277  {
278  return(ComputeTime_);
279  }
280 
282  virtual double ApplyInverseTime() const
283  {
284  return(ApplyInverseTime_);
285  }
286 
288  virtual double InitializeFlops() const
289  {
290  return(0.0);
291  }
292 
294  virtual double ComputeFlops() const
295  {
296  return(ComputeFlops_);
297  }
298 
300  virtual double ApplyInverseFlops() const
301  {
302  return(ApplyInverseFlops_);
303  }
304 
305  // @}
306  // @{ \name Utility methods
307 
309  static int PowerMethod(const Epetra_Operator& Operator,
310  const Epetra_Vector& InvPointDiagonal,
311  const int MaximumIterations,
312  double& LambdaMax);
313 
315  static int CG(const Epetra_Operator& Operator,
316  const Epetra_Vector& InvPointDiagonal,
317  const int MaximumIterations,
318  double& lambda_min, double& lambda_max);
319 
320 #ifdef HAVE_IFPACK_EPETRAEXT
321  // WARNING: This only works in Block Mode.
323  int CG(const int MaximumIterations,
324  double& lambda_min, double& lambda_max);
326  // WARNING: This only works in Block Mode.
327  int PowerMethod(const int MaximumIterations,double& lambda_max);
328 #endif
329 
331  int GMRES(const Epetra_Operator& Operator,
332  const Epetra_Vector& InvPointDiagonal,
333  const int MaximumIterations,
334  double& lambda_real_min, double& lambda_real_max,
335  double& lambda_imag_min, double& lambda_imag_max);
336 
337 private:
338 
339  // @}
340  // @{ \name Private methods
341 
343  virtual void SetLabel();
344 
347  {}
348 
351  {
352  return(*this);
353  }
354 
355  // @{ Initializations, timing and flops
369  mutable int NumApplyInverse_;
373  double ComputeTime_;
375  mutable double ApplyInverseTime_;
379  mutable double ApplyInverseFlops_;
380  // @}
381 
382  // @{ Settings
390  double Condest_;
391 #if 0
392  // Unused; commented out to avoid build warnings
393 
395  bool ComputeCondest_;
396 #endif // 0
403  std::string Label_;
409  std::vector<double> coeff_;
410 
411  // @{ Other data
417  long long NumGlobalRows_;
421  Teuchos::RefCountPtr<const Epetra_Operator> Operator_;
423  Teuchos::RefCountPtr<const Epetra_RowMatrix> Matrix_;
425  mutable Teuchos::RefCountPtr<Epetra_Vector> InvDiagonal_;
428 #ifdef HAVE_IFPACK_EPETRAEXT
429  Teuchos::ParameterList BlockList_;
431  Teuchos::RefCountPtr<EpetraExt_PointToBlockDiagPermute> InvBlockDiagonal_;
432 #endif
433 
434 
437 
441  Teuchos::RefCountPtr<Epetra_Time> Time_;
444 
445  // @}
446 
447 };
448 
449 
450 #endif // IFPACK_POLYNOMIAL_H
int GMRES(const Epetra_Operator &Operator, const Epetra_Vector &InvPointDiagonal, const int MaximumIterations, double &lambda_real_min, double &lambda_real_max, double &lambda_imag_min, double &lambda_imag_max)
Uses AztecOO&#39;s GMRES to estimate the height and width of the spectrum.
bool IsInitialized_
If true, the preconditioner has been computed successfully.
Ifpack_Polynomial(const Ifpack_Polynomial &)
Copy constructor (PRIVATE, should not be used)
bool ZeroStartingSolution_
If true, the starting solution is always the zero vector.
Teuchos::RefCountPtr< Epetra_Vector > InvDiagonal_
Contains the inverse of diagonal elements of Matrix.
int NumCompute_
Contains the number of successful call to Compute().
virtual bool HasNormInf() const
Returns true if the this object can provide an approximate Inf-norm, false otherwise.
double ApplyInverseFlops_
Contain sthe number of flops for ApplyInverse().
virtual int NumInitialize() const
Returns the number of calls to Initialize().
virtual double ComputeTime() const
Returns the time spent in Compute().
virtual bool UseTranspose() const
Returns the current UseTranspose setting.
virtual const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this operator.
double Condest_
Contains the estimated condition number.
virtual int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Applies the preconditioner to X, returns the result in Y.
virtual int Initialize()
Computes all it is necessary to initialize the preconditioner.
double ApplyInverseTime_
Contains the time for all successful calls to ApplyInverse().
virtual int NumApplyInverse() const
Returns the number of calls to ApplyInverse().
long long NumGlobalNonzeros_
Number of global nonzeros.
int LSPointsReal_
Contains the number of discretization points of the least squares problem.
double RealEigRatio_
Contains the ratio such that the rectangular domain in the complex plane is [-LambdaRealMax_ / EigRat...
virtual int SetUseTranspose(bool UseTranspose_in)
virtual double NormInf() const
Returns the infinity norm of the global matrix (not implemented)
long long NumGlobalRows_
Number of global rows.
double ComputeFlops_
Contains the number of flops for Compute().
bool UseTranspose_
If true, use the tranpose of Matrix_.
Teuchos::RefCountPtr< const Epetra_RowMatrix > Matrix_
Pointers to the matrix to be preconditioned as an Epetra_RowMatrix.
std::string Label_
Contains the label of this object.
int NumApplyInverse_
Contains the number of successful call to ApplyInverse().
Teuchos::RefCountPtr< Epetra_Time > Time_
Time object to track timing.
Ifpack_CondestType
Ifpack_CondestType: enum to define the type of condition number estimate.
static int CG(const Epetra_Operator &Operator, const Epetra_Vector &InvPointDiagonal, const int MaximumIterations, double &lambda_min, double &lambda_max)
Uses AztecOO&#39;s CG to estimate lambda_min and lambda_max.
Ifpack_Polynomial & operator=(const Ifpack_Polynomial &)
operator = (PRIVATE, should not be used)
virtual ~Ifpack_Polynomial()
Destructor.
virtual int Compute()
Computes the preconditioners.
std::vector< double > coeff_
coefficients of the polynomial
int PolyDegree_
Contains the degree of the least squares polynomial.
virtual bool IsInitialized() const
Returns true if the preconditioner has been successfully initialized, false otherwise.
Ifpack_Preconditioner: basic class for preconditioning in Ifpack.
Teuchos::RefCountPtr< const Epetra_Operator > Operator_
Pointers to the matrix to be preconditioned as an Epetra_Operator.
double InitializeTime_
Contains the time for all successful calls to Initialize().
double MinDiagonalValue_
Contains the minimum value on the diagonal.
Ifpack_Polynomial(const Epetra_Operator *Matrix)
Ifpack_Polynomial constructor with given Epetra_Operator/Epetra_RowMatrix.
int NumMyNonzeros_
Number of local nonzeros.
double ComputeTime_
Contains the time for all successful calls to Compute().
virtual int SetParameters(Teuchos::ParameterList &List)
Sets all the parameters for the preconditioner.
Ifpack_Polynomial: class for preconditioning with least squares polynomials in Ifpack.
bool IsComputed_
If true, the preconditioner has been computed successfully.
virtual const char * Label() const
virtual bool IsComputed() const
Returns true if the preconditioner has been successfully computed.
virtual const Epetra_RowMatrix & Matrix() const
Returns a pointer to the matrix to be preconditioned.
virtual std::ostream & Print(std::ostream &os) const
Prints object to an output stream.
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Applies the matrix to an Epetra_MultiVector.
int NumMyRows_
Number of local rows.
cheap estimate
virtual double InitializeFlops() const
Returns the number of flops in the initialization phase.
bool IsIndefinite_
If true, have to compute polynomial for a spectrum with negative eigenvalues.
int EigMaxIters_
Max number of iterations to use in eigenvalue estimation (if automatic).
bool SolveNormalEquations_
Run on the normal equations.
virtual int NumCompute() const
Returns the number of calls to Compute().
static int PowerMethod(const Epetra_Operator &Operator, const Epetra_Vector &InvPointDiagonal, const int MaximumIterations, double &LambdaMax)
Simple power method to compute lambda_max.
virtual double InitializeTime() const
Returns the time spent in Initialize().
bool UseBlockMode_
Use Block Preconditioning.
bool IsRowMatrix_
If true, the Operator_ is an Epetra_RowMatrix.
double LambdaRealMin_
Bounds on the spectrum.
virtual double ApplyInverseFlops() const
Returns the number of flops for the application of the preconditioner.
virtual double ApplyInverseTime() const
Returns the time spent in ApplyInverse().
virtual double ComputeFlops() const
Returns the number of flops in the computation phase.
int NumInitialize_
Contains the number of successful calls to Initialize().
bool IsComplex_
If true, have to compute polynomial for a spectrum with nonzero imaginary part.
virtual const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this operator.
virtual void SetLabel()
Sets the label.
virtual const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this operator.
virtual double Condest() const
Returns the condition number estimate, or -1.0 if not computed.