IFPACK  Development
 All Classes Namespaces Files Functions Variables Enumerations Friends Pages
Ifpack_SupportGraph.h
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_SUPPORTGRAPH_H
44 #define IFPACK_SUPPORTGRAPH_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_Condest.h"
54 #include "Ifpack_Preconditioner.h"
55 #include "Ifpack_Amesos.h"
56 #include "Ifpack_Condest.h"
57 #include "Epetra_Map.h"
58 #include "Epetra_Comm.h"
59 #include "Epetra_Time.h"
60 #include "Epetra_Vector.h"
61 #include "Epetra_MultiVector.h"
62 #include "Epetra_LinearProblem.h"
63 #include "Epetra_RowMatrix.h"
64 #include "Epetra_CrsMatrix.h"
65 
66 #include "Teuchos_ParameterList.hpp"
67 #include "Teuchos_RefCountPtr.hpp"
68 
69 #include <boost/graph/adjacency_list.hpp>
70 #include <boost/graph/kruskal_min_spanning_tree.hpp>
71 #include <boost/graph/prim_minimum_spanning_tree.hpp>
72 #include <boost/config.hpp>
73 
74 using Teuchos::RefCountPtr;
75 using Teuchos::rcp;
76 typedef std::pair<int, int> E;
77 using namespace boost;
78 
79 typedef adjacency_list < vecS, vecS, undirectedS,
80  no_property, property < edge_weight_t, double > > Graph;
81 typedef graph_traits < Graph >::edge_descriptor Edge;
82 typedef graph_traits < Graph >::vertex_descriptor Vertex;
83 
84 
85 
86 template<typename T=Ifpack_Amesos> class Ifpack_SupportGraph :
87 public virtual Ifpack_Preconditioner
88 {
89 
90  public:
91 
93 
96 
98 
99 
101 
111  virtual int SetUseTranspose(bool UseTranspose_in);
112 
114 
115 
117 
119 
127  virtual int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
128 
130 
141  virtual int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
142 
144  virtual double NormInf() const {return(0.0);}
145 
147 
148 
150 
152  virtual const char * Label() const;
153 
155  virtual bool UseTranspose() const {return(UseTranspose_);};
156 
158  virtual bool HasNormInf() const {return(false);};
159 
161  virtual const Epetra_Comm & Comm() const {return(Matrix_->Comm());};
162 
164  virtual const Epetra_Map & OperatorDomainMap() const {return(Matrix_->OperatorDomainMap());};
165 
167  virtual const Epetra_Map & OperatorRangeMap() const {return(Matrix_->OperatorRangeMap());};
168 
170 
171 
173 
175  virtual bool IsInitialized() const
176  {
177  return(IsInitialized_);
178  }
179 
181  virtual bool IsComputed() const
182  {
183  return(IsComputed_);
184  }
185 
187 
199  virtual int SetParameters(Teuchos::ParameterList& List);
200 
202 
205  virtual int Initialize();
207 
210  virtual int Compute();
211 
213 
214 
216 
217 
219 
222  virtual double Condest(const Ifpack_CondestType CT = Ifpack_Cheap,
223  const int MaxIters = 1550,
224  const double Tol = 1e-9,
225  Epetra_RowMatrix* Matrix_in = 0);
226 
228  virtual double Condest() const
229  {
230  return(Condest_);
231  }
232 
234  virtual const Epetra_RowMatrix& Matrix() const
235  {
236  return(*Matrix_);
237  }
238 
240  virtual std::ostream& Print(std::ostream&) const;
241 
243  virtual int NumInitialize() const
244  {
245  return(NumInitialize_);
246  }
247 
249  virtual int NumCompute() const
250  {
251  return(NumCompute_);
252  }
253 
255  virtual int NumApplyInverse() const
256  {
257  return(NumApplyInverse_);
258  }
259 
261  virtual double InitializeTime() const
262  {
263  return(InitializeTime_);
264  }
265 
267  virtual double ComputeTime() const
268  {
269  return(ComputeTime_);
270  }
271 
273  virtual double ApplyInverseTime() const
274  {
275  return(ApplyInverseTime_);
276  }
277 
279  virtual double InitializeFlops() const
280  {
281  return(InitializeFlops_);
282  }
283 
285  virtual double ComputeFlops() const
286  {
287  return(ComputeFlops_);
288  }
289 
291  virtual double ApplyInverseFlops() const
292  {
293  return(ApplyInverseFlops_);
294  }
295 
296 
298 
299  protected:
300 
302  int FindSupport();
303 
305  Teuchos::RefCountPtr<const Epetra_RowMatrix> Matrix_;
306 
308  Teuchos::RefCountPtr<Epetra_CrsMatrix> Support_;
309 
311  std::string Label_;
312 
315 
318 
321 
323  Teuchos::ParameterList List_;
324 
326  double Condest_;
327 
330 
333 
335  mutable int NumApplyInverse_;
336 
339 
341  double ComputeTime_;
342 
344  mutable double ApplyInverseTime_;
345 
348 
351 
353  mutable double ApplyInverseFlops_;
354 
356  Teuchos::RefCountPtr<Epetra_Time> Time_;
357 
359  Teuchos::RefCountPtr<T> Inverse_;
360 
363 
365  double DiagPertRel_;
366 
368  double DiagPertAbs_;
369 
371  double KeepDiag_;
372 
375 
376 }; // class Ifpack_SupportGraph<T>
377 
378 
379 
380 //==============================================================================
381 template<typename T>
383 Matrix_(rcp(Matrix_in,false)),
384  IsInitialized_(false),
385  IsComputed_(false),
386  UseTranspose_(false),
387  Condest_(-1.0),
388  NumInitialize_(0),
389  NumCompute_(0),
390  NumApplyInverse_(0),
391  InitializeTime_(0.0),
392  ComputeTime_(0.0),
393  ApplyInverseTime_(0.0),
394  InitializeFlops_(0.0),
395  ComputeFlops_(0.0),
396  ApplyInverseFlops_(0.0),
397  NumForests_(1),
398  DiagPertRel_(1.0),
399  DiagPertAbs_(0.0),
400  KeepDiag_(1.0),
401  Randomize_(0)
402 {
403 
404  Teuchos::ParameterList List_in;
405  SetParameters(List_in);
406 }
407 //==============================================================================
408 template<typename T>
410 {
411 
412  // Extract matrix dimensions
413  long long rows = (*Matrix_).NumGlobalRows64();
414  long long cols = (*Matrix_).NumGlobalCols64();
415  int num_edges = ((*Matrix_).NumMyNonzeros() - (*Matrix_).NumMyDiagonals())/2;
416  std::cout << "global num rows " << rows << std::endl;
417 
418  // Assert square matrix
419  IFPACK_CHK_ERR((rows == cols));
420 
421  if(rows > std::numeric_limits<int>::max())
422  {
423  std::cerr << "Ifpack_SupportGraph<T>::FindSupport: global num rows won't fit an int. " << rows << std::endl;
424  IFPACK_CHK_ERR(1);
425  }
426 
427  // Rename for clarity
428  int num_verts = (int) rows;
429 
430  // Create data structures for the BGL code and temp data structures for extraction
431  E *edge_array = new E[num_edges];
432  double *weights = new double[num_edges];
433 
434  int num_entries;
435  int max_num_entries = (*Matrix_).MaxNumEntries();
436  double *values = new double[max_num_entries];
437  int *indices = new int[max_num_entries];
438 
439  double * diagonal = new double[num_verts];
440 
441 
442  for(int i = 0; i < max_num_entries; i++)
443  {
444  values[i]=0;
445  indices[i]=0;
446  }
447 
448  // Extract from the epetra matrix keeping only one edge per pair (assume symmetric)
449  int k = 0;
450  for(int i = 0; i < num_verts; i++)
451  {
452  (*Matrix_).ExtractMyRowCopy(i,max_num_entries,num_entries,values,indices);
453 
454  for(int j = 0; j < num_entries; j++)
455  {
456 
457  if(i == indices[j])
458  {
459  diagonal[i] = values[j];
460  // Diagonal pertubation, only if requested
461  if (DiagPertRel_)
462  diagonal[i] *= DiagPertRel_;
463  if (DiagPertAbs_)
464  diagonal[i] += DiagPertAbs_;
465  }
466 
467  if(i < indices[j])
468  {
469  edge_array[k] = E(i,indices[j]);
470  weights[k] = values[j];
471  if (Randomize_)
472  {
473  // Add small random pertubation.
474  weights[k] *= (1.0 + 1e-8 * drand48());
475  }
476 
477  k++;
478  }
479  }
480  }
481 
482  // Create BGL graph
483  Graph g(edge_array, edge_array + num_edges, weights, num_verts);
484 
485 
486  property_map < Graph, edge_weight_t >::type weight = get(edge_weight, g);
487 
488  std::vector < Edge > spanning_tree;
489 
490  // Run Kruskal, actually maximal weight ST since edges are negative
491  kruskal_minimum_spanning_tree(g, std::back_inserter(spanning_tree));
492 
493 
494  std::vector<int> NumNz(num_verts,1);
495 
496  //Find the degree of all the vertices
497  for (std::vector < Edge >::iterator ei = spanning_tree.begin();
498  ei != spanning_tree.end(); ++ei)
499  {
500  NumNz[source(*ei,g)] = NumNz[source(*ei,g)] + 1;
501  NumNz[target(*ei,g)] = NumNz[target(*ei,g)] + 1;
502  }
503 
504 
505  // Create an stl vector of stl vectors to hold indices and values (neighbour edges)
506  std::vector< std::vector< int > > Indices(num_verts);
507  // TODO: Optimize for performance, may use arrays instead of vectors
508  //std::vector<int> Indices[num_verts];
509  //std::vector<double> Values[num_verts];
510 
511  std::vector< std::vector< double > > Values(num_verts);
512 
513  for(int i = 0; i < num_verts; i++)
514  {
515  std::vector<int> temp(NumNz[i],0);
516  std::vector<double> temp2(NumNz[i],0);
517  Indices[i] = temp;
518  Values[i] = temp2;
519  }
520 
521  int *l = new int[num_verts];
522  for(int i = 0; i < num_verts; i++)
523  {
524  Indices[i][0] = i;
525  l[i] = 1;
526  }
527 
528  // Add each spanning forest (tree) to the support graph and
529  // remove it from original graph
530  for(int i = 0; i < NumForests_; i++)
531  {
532  if(i > 0)
533  {
534  spanning_tree.clear();
535  kruskal_minimum_spanning_tree(g,std::back_inserter(spanning_tree));
536  for(std::vector < Edge >::iterator ei = spanning_tree.begin();
537  ei != spanning_tree.end(); ++ei)
538  {
539  NumNz[source(*ei,g)] = NumNz[source(*ei,g)] + 1;
540  NumNz[target(*ei,g)] = NumNz[target(*ei,g)] + 1;
541  }
542  for(int i = 0; i < num_verts; i++)
543  {
544  Indices[i].resize(NumNz[i]);
545  Values[i].resize(NumNz[i]);
546  }
547  }
548 
549  for (std::vector < Edge >::iterator ei = spanning_tree.begin();
550  ei != spanning_tree.end(); ++ei)
551  {
552  // Assume standard Laplacian with constant row-sum.
553  // Edge weights are negative, so subtract to make diagonal positive
554  Indices[source(*ei,g)][0] = source(*ei,g);
555  Values[source(*ei,g)][0] = Values[source(*ei,g)][0] - weight[*ei];
556  Indices[target(*ei,g)][0] = target(*ei,g);
557  Values[target(*ei,g)][0] = Values[target(*ei,g)][0] - weight[*ei];
558 
559  Indices[source(*ei,g)][l[source(*ei,g)]] = target(*ei,g);
560  Values[source(*ei,g)][l[source(*ei,g)]] = weight[*ei];
561  l[source(*ei,g)] = l[source(*ei,g)] + 1;
562 
563  Indices[target(*ei,g)][l[target(*ei,g)]] = source(*ei,g);
564  Values[target(*ei,g)][l[target(*ei,g)]] = weight[*ei];
565  l[target(*ei,g)] = l[target(*ei,g)] + 1;
566 
567  remove_edge(*ei,g);
568  }
569 
570  }
571 
572 
573  // Set diagonal to weighted average of Laplacian preconditioner
574  // and the original matrix
575 
576  // First compute the "diagonal surplus" (in the original input matrix)
577  // If input is a (pure, Dirichlet) graph Laplacian , this will be 0
578  Epetra_Vector ones(Matrix_->OperatorDomainMap());
579  Epetra_Vector surplus(Matrix_->OperatorRangeMap());
580 
581  ones.PutScalar(1.0);
582  Matrix_->Multiply(false, ones, surplus);
583 
584  for(int i = 0; i < num_verts; i++)
585  {
586  Values[i][0] += surplus[i];
587  Values[i][0] = KeepDiag_*diagonal[i] +
588  (1.-KeepDiag_) * Values[i][0];
589  }
590 
591  // Create the CrsMatrix for the support graph
592  Support_ = rcp(new Epetra_CrsMatrix(Copy, Matrix().RowMatrixRowMap(),l, false));
593 
594 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
595  if((*Matrix_).RowMatrixRowMap().GlobalIndicesLongLong())
596  {
597  // Fill in the matrix with the stl vectors for each row
598  for(int i = 0; i < num_verts; i++)
599  {
600  std::vector<long long> IndicesLL(l[i]);
601  for(int k = 0; k < l[i]; ++k)
602  IndicesLL[k] = Indices[i][k];
603 
604  (*Support_).InsertGlobalValues(i,l[i],&Values[i][0],&IndicesLL[0]);
605  }
606  }
607  else
608 #endif
609 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
610  if((*Matrix_).RowMatrixRowMap().GlobalIndicesInt())
611  {
612  // Fill in the matrix with the stl vectors for each row
613  for(int i = 0; i < num_verts; i++)
614  {
615  (*Support_).InsertGlobalValues(i,l[i],&Values[i][0],&Indices[i][0]);
616  }
617  }
618  else
619 #endif
620  throw "Ifpack_SupportGraph::FindSupport: GlobalIndices unknown.";;
621 
622  (*Support_).FillComplete();
623 
624  delete edge_array;
625  delete weights;
626  delete values;
627  delete indices;
628  delete l;
629  delete diagonal;
630 
631  return(0);
632 }
633 //==============================================================================
634 template<typename T>
635 int Ifpack_SupportGraph<T>::SetParameters(Teuchos::ParameterList& List_in)
636 {
637  List_ = List_in;
638  NumForests_ = List_in.get("MST: forest number", NumForests_);
639  KeepDiag_ = List_in.get("MST: keep diagonal", KeepDiag_);
640  Randomize_ = List_in.get("MST: randomize", Randomize_);
641  // Diagonal pertubation parameters have weird names to be compatible with rest of Ifpack!
642  DiagPertRel_ = List_in.get("fact: relative threshold", DiagPertRel_);
643  DiagPertAbs_ = List_in.get("fact: absolute threshold", DiagPertAbs_);
644 
645  return(0);
646 }
647 //==============================================================================
648 template<typename T>
650 {
651  IsInitialized_ = false;
652  IsComputed_ = false;
653 
654 
655  if (Time_ == Teuchos::null)
656  {
657  Time_ = Teuchos::rcp( new Epetra_Time(Comm()) );
658  }
659 
660 
661  Time_->ResetStartTime();
662 
663  FindSupport();
664 
665  Inverse_ = Teuchos::rcp(new T(Support_.get()));
666 
667  IFPACK_CHK_ERR(Inverse_->Initialize());
668 
669  IsInitialized_ = true;
670  ++NumInitialize_;
671  InitializeTime_ += Time_->ElapsedTime();
672 
673  return(0);
674 
675 }
676 //==============================================================================
677 template<typename T>
679 {
680  if (IsInitialized() == false)
681  IFPACK_CHK_ERR(Initialize());
682 
683  Time_->ResetStartTime();
684  IsComputed_ = false;
685  Condest_ = -1.0;
686 
687  IFPACK_CHK_ERR(Inverse_->Compute());
688 
689  IsComputed_ = true;
690  ++NumCompute_;
691  ComputeTime_ += Time_->ElapsedTime();
692 
693 
694  return(0);
695 }
696 //==============================================================================
697 template<typename T>
699 {
700  // store the flag -- it will be set in Initialize() if Inverse_ does not
701  // exist.
702  UseTranspose_ = UseTranspose_in;
703 
704  // If Inverse_ exists, pass it right now.
705  if (Inverse_!=Teuchos::null)
706  IFPACK_CHK_ERR(Inverse_->SetUseTranspose(UseTranspose_in));
707 
708  return(0);
709 }
710 //==============================================================================
711 template<typename T>
714 {
715  IFPACK_CHK_ERR(Matrix_->Apply(X,Y));
716  return(0);
717 }
718 //==============================================================================
719 template<typename T>
720 const char * Ifpack_SupportGraph<T>::Label() const
721 {
722  return(Label_.c_str());
723 }
724 //==============================================================================
725 template<typename T>
728 {
729  if (!IsComputed())
730  IFPACK_CHK_ERR(-3);
731 
732  Time_->ResetStartTime();
733 
734 
735  Inverse_->ApplyInverse(X,Y);
736 
737  ++NumApplyInverse_;
738  ApplyInverseTime_ += Time_->ElapsedTime();
739 
740  return(0);
741 }
742 //==============================================================================
743 template<typename T>
744 std::ostream& Ifpack_SupportGraph<T>::
745 Print(std::ostream& os) const
746 {
747  os << "================================================================================" << std::endl;
748  os << "Ifpack_SupportGraph: " << Label () << std::endl << std::endl;
749  os << "Condition number estimate = " << Condest() << std::endl;
750  os << "Global number of rows = " << Matrix_->NumGlobalRows64() << std::endl;
751  os << "Number of edges in support graph = " << (Support_->NumGlobalNonzeros64()-Support_->NumGlobalDiagonals64())/2 << std::endl;
752  os << "Fraction of off diagonals of support graph/off diagonals of original = "
753  << ((double)Support_->NumGlobalNonzeros64()-Support_->NumGlobalDiagonals64())/(Matrix_->NumGlobalNonzeros64()-Matrix_->NumGlobalDiagonals64());
754  os << std::endl;
755  os << "Phase # calls Total Time (s) Total MFlops MFlops/s" << std::endl;
756  os << "----- ------- -------------- ------------ --------" << std::endl;
757  os << "Initialize() " << std::setw(10) << NumInitialize_
758  << " " << std::setw(15) << InitializeTime_
759  << " 0.0 0.0" << std::endl;
760  os << "Compute() " << std::setw(10) << NumCompute_
761  << " " << std::setw(22) << ComputeTime_
762  << " " << std::setw(15) << 1.0e-6 * ComputeFlops_;
763  if (ComputeTime_ != 0.0)
764  os << " " << std::setw(15) << 1.0e-6 * ComputeFlops_ / ComputeTime_ << std::endl;
765  else
766  os << " " << std::setw(15) << 0.0 << std::endl;
767  os << "ApplyInverse() " << std::setw(10) << NumApplyInverse_
768  << " " << std::setw(22) << ApplyInverseTime_
769  << " " << std::setw(15) << 1.0e-6 * ApplyInverseFlops_;
770  if (ApplyInverseTime_ != 0.0)
771  os << " " << std::setw(15) << 1.0e-6 * ApplyInverseFlops_ / ApplyInverseTime_ << std::endl;
772  else
773  os << " " << std::setw(15) << 0.0 << std::endl;
774 
775  os << std::endl << std::endl;
776  os << "Now calling the underlying preconditioner's print()" << std::endl;
777 
778  Inverse_->Print(os);
779 
780  return os;
781 }
782 //==============================================================================
783 template<typename T>
785 Condest(const Ifpack_CondestType CT, const int MaxIters,
786  const double Tol, Epetra_RowMatrix* Matrix_in)
787 {
788  if (!IsComputed()) // cannot compute right now
789  {
790  return(-1.0);
791  }
792 
793  Condest_ = Ifpack_Condest(*this, CT, MaxIters, Tol, Matrix_in);
794 
795  return(Condest_);
796 }
797 
798 #endif // IFPACK_SUPPORTGRAPH_H
double ComputeTime_
Contains the time for all successful calls to Compute().
virtual double Condest() const
Returns the computed condition number.
Teuchos::RefCountPtr< Epetra_Time > Time_
Object used for timing purposes.
int NumApplyInverse_
Contains the number of successful call to ApplyInverse().
bool IsComputed_
If true, the preconditioner has been successfully computed.
virtual const char * Label() const
Returns a character string describing the operator.
virtual int NumApplyInverse() const
Returns the number of calls to ApplyInverse().
virtual const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this operator.
virtual double ApplyInverseFlops() const
Returns the total number of flops to apply the preconditioner.
int NumInitialize_
Contains the number of successful calls to Initialize().
Teuchos::ParameterList List_
Stores a copy of the list given in SetParameters()
virtual double ApplyInverseTime() const
Returns the total time spent in ApplyInverse().
std::string Label_
Contains the label of this object.
int Randomize_
Option to add random pertubation to edge weights, to get random spanning trees.
virtual int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Applies the preconditioner to X, returns the result in Y.
Ifpack_SupportGraph(Epetra_RowMatrix *Matrix_in)
Constructor.
virtual double InitializeTime() const
Returns the total time spent in Initialize().
Teuchos::RefCountPtr< Epetra_CrsMatrix > Support_
Pointers to the matrix of the support graph.
virtual const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this operator.
virtual bool UseTranspose() const
Returns the current UseTranspose setting.
virtual double ComputeFlops() const
Returns the total number of flops to compute the preconditioner.
virtual int SetParameters(Teuchos::ParameterList &List)
Sets all the parameters for the preconditioner.
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Applies the matrix to an Epetra_MultiVector.
double Condest_
Contains the estimated condition number.
virtual bool HasNormInf() const
Returns true if this object can provide an approximate Inf-norm, false otherwise. ...
virtual int SetUseTranspose(bool UseTranspose_in)
If set true, transpose of this operator will be applied (not implemented).
virtual const Epetra_RowMatrix & Matrix() const
Returns a const reference to the internally stored matrix.
Teuchos::RefCountPtr< const Epetra_RowMatrix > Matrix_
Pointers to the matrix to be preconditioned.
int NumCompute_
Contains the number of successful call to Compute().
int NumForests_
Contains the number of forests in the support graph.
Teuchos::RefCountPtr< T > Inverse_
Pointer to the local solver.
Ifpack_Preconditioner: basic class for preconditioning in Ifpack.
virtual double NormInf() const
Returns the infinity norm of the global matrix (not implemented)
virtual const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this operator.
virtual int NumInitialize() const
Returns the number of calls to Initialize().
double InitializeFlops_
Contains the number of flops for Initialize().
virtual int NumCompute() const
Returns the number of calls to Compute().
virtual std::ostream & Print(std::ostream &) const
Prints on ostream basic information about this object.
double ComputeFlops_
Contains the number of flops for Compute().
double KeepDiag_
Contains the option to keep the diagonal of original matrix, or weighted average. ...
double InitializeTime_
Contains the time for all successful calls to Initialize().
bool UseTranspose_
If true, solve with the transpose (not supported by all solvers).
bool IsInitialized_
If true, the preconditioner has been successfully initialized.
virtual bool IsComputed() const
Returns true if the preconditioner has been successfully computed.
virtual int Initialize()
Initialize the preconditioner.
double ApplyInverseTime_
Contains the time for all successful calls to ApplyInverse().
double ApplyInverseFlops_
Contain sthe number of flops for ApplyInverse().
virtual bool IsInitialized() const
Returns true if the preconditioner has been successfully initialized.
virtual int Compute()
Computes the preconditioners.
double DiagPertAbs_
Absolute diagonal pertubation.
virtual double ComputeTime() const
Returns the total time spent in Compute().
int FindSupport()
Compute the support graph.
double DiagPertRel_
Relative diagonal pertubation.
virtual double InitializeFlops() const
Returns the number of flops in the initialization phase.