Epetra Package Browser (Single Doxygen Collection) Development
Loading...
Searching...
No Matches
Epetra_BasicRowMatrix.h
Go to the documentation of this file.
1/*
2//@HEADER
3// ************************************************************************
4//
5// Epetra: Linear Algebra Services Package
6// Copyright 2011 Sandia Corporation
7//
8// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9// the U.S. Government retains certain rights in this software.
10//
11// Redistribution and use in source and binary forms, with or without
12// modification, are permitted provided that the following conditions are
13// met:
14//
15// 1. Redistributions of source code must retain the above copyright
16// notice, this list of conditions and the following disclaimer.
17//
18// 2. Redistributions in binary form must reproduce the above copyright
19// notice, this list of conditions and the following disclaimer in the
20// documentation and/or other materials provided with the distribution.
21//
22// 3. Neither the name of the Corporation nor the names of the
23// contributors may be used to endorse or promote products derived from
24// this software without specific prior written permission.
25//
26// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37//
38// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
39//
40// ************************************************************************
41//@HEADER
42*/
43
44#ifndef EPETRA_BASICROWMATRIX_H
45#define EPETRA_BASICROWMATRIX_H
46
47#include "Epetra_ConfigDefs.h"
48#include "Epetra_RowMatrix.h"
49#include "Epetra_Object.h"
50#include "Epetra_CompObject.h"
51#include "Epetra_Map.h"
52#include "Epetra_Comm.h"
55#include "Epetra_MultiVector.h"
56
57class Epetra_Vector;
58class Epetra_Import;
59class Epetra_Export;
60
62
110class EPETRA_LIB_DLL_EXPORT Epetra_BasicRowMatrix: public Epetra_CompObject, public Epetra_Object, public virtual Epetra_RowMatrix {
111
112 public:
113
115
116
124
126 virtual ~Epetra_BasicRowMatrix();
128
130
131
143 void SetMaps(const Epetra_Map & RowMap, const Epetra_Map & ColMap);
144
157 void SetMaps(const Epetra_Map & RowMap, const Epetra_Map & ColMap,
158 const Epetra_Map & DomainMap, const Epetra_Map & RangeMap);
159
161
162
164
165
167
176 virtual int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const = 0;
177
179
187 virtual int ExtractMyEntryView(int CurEntry, double * & Value, int & RowIndex, int & ColIndex) = 0;
188
190
198 virtual int ExtractMyEntryView(int CurEntry, double const * & Value, int & RowIndex, int & ColIndex) const = 0;
199
201
208 virtual int NumMyRowEntries(int MyRow, int & NumEntries) const = 0;
210
212
213
215
222 virtual int Multiply(bool TransA, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
223
225
234 virtual int Solve(bool Upper, bool Trans, bool UnitDiagonal,
235 const Epetra_MultiVector& X,
236 Epetra_MultiVector& Y) const
237 {
238 (void)Upper;
239 (void)Trans;
240 (void)UnitDiagonal;
241 (void)X;
242 (void)Y;
243 return(-1);
244 }
245
247
252 virtual int ExtractDiagonalCopy(Epetra_Vector & Diagonal) const;
253
255
264 virtual int InvRowSums(Epetra_Vector& x) const;
265
267
273 virtual int LeftScale(const Epetra_Vector& x);
274
276
285 virtual int InvColSums(Epetra_Vector& x) const;
286
288
294 virtual int RightScale(const Epetra_Vector& x);
296
298
299
300
302 virtual bool Filled() const {return(true);}
303
305 bool LowerTriangular() const {if (!HaveNumericConstants_) ComputeNumericConstants(); return(LowerTriangular_);}
306
308 virtual bool UpperTriangular() const {if (!HaveNumericConstants_) ComputeNumericConstants(); return(UpperTriangular_);}
309
311
313
314
323 virtual double NormInf() const{if (!HaveNumericConstants_) ComputeNumericConstants(); return(NormInf_);}
324
333 virtual double NormOne() const{if (!HaveNumericConstants_) ComputeNumericConstants(); return(NormOne_);}
334
341#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
342 virtual int NumGlobalNonzeros() const {
343 if(OperatorRangeMap().GlobalIndicesInt() && OperatorDomainMap().GlobalIndicesInt()) {
344 if (!HaveStructureConstants_)
345 ComputeStructureConstants();
346 return (int) NumGlobalNonzeros_;
347 }
348
349 throw "Epetra_BasicRowMatrix::NumGlobalNonzeros: GlobalIndices not int.";
350 }
351#endif
352 virtual long long NumGlobalNonzeros64() const{if (!HaveStructureConstants_) ComputeStructureConstants(); return(NumGlobalNonzeros_);}
353
355#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
356 virtual int NumGlobalRows() const {
357 if(OperatorRangeMap().GlobalIndicesInt()) {
358 return (int) NumGlobalRows64();
359 }
360
361 throw "Epetra_BasicRowMatrix::NumGlobalRows: GlobalIndices not int.";
362 }
363#endif
364 virtual long long NumGlobalRows64() const {return(OperatorRangeMap().NumGlobalPoints64());}
365
367#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
368 virtual int NumGlobalCols() const {
369 if(OperatorDomainMap().GlobalIndicesInt()) {
370 return (int) NumGlobalCols64();
371 }
372
373 throw "Epetra_BasicRowMatrix::NumGlobalCols: GlobalIndices not int.";
374 }
375#endif
376 virtual long long NumGlobalCols64() const {return(OperatorDomainMap().NumGlobalPoints64());}
377
379#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
380 virtual int NumGlobalDiagonals() const {
381 if(OperatorDomainMap().GlobalIndicesInt()) {
382 return (int) NumGlobalDiagonals64();
383 }
384
385 throw "Epetra_BasicRowMatrix::NumGlobalDiagonals: GlobalIndices not int.";
386 }
387#endif
388 virtual long long NumGlobalDiagonals64() const{return(OperatorDomainMap().NumGlobalPoints64());}
389
391 virtual int NumMyNonzeros() const{if (!HaveStructureConstants_) ComputeStructureConstants(); return(NumMyNonzeros_);}
392
394 virtual int NumMyRows() const {return(OperatorRangeMap().NumMyPoints());}
395
397 virtual int NumMyCols() const {return(RowMatrixColMap().NumMyPoints());}
398
400 virtual int NumMyDiagonals() const {return(OperatorRangeMap().NumMyPoints());}
401
403 virtual int MaxNumEntries() const{ if (!HaveStructureConstants_) ComputeStructureConstants(); return(MaxNumEntries_);}
404
406 virtual const Epetra_Map & OperatorDomainMap() const {return(OperatorDomainMap_);}
407
409 virtual const Epetra_Map & OperatorRangeMap() const {return(OperatorRangeMap_);}
410
412 virtual const Epetra_BlockMap& Map() const {return(RowMatrixRowMap());}
413
415 virtual const Epetra_Map & RowMatrixRowMap() const {return(RowMatrixRowMap_);}
416
418 virtual const Epetra_Map & RowMatrixColMap() const {return(RowMatrixColMap_);}
419
421 virtual const Epetra_Import * RowMatrixImporter() const {return(Importer_);}
422
424 virtual const Epetra_Comm & Comm() const {return(*Comm_);}
426
427
429
430
432 virtual void Print(std::ostream & os) const;
434
436
437
439
447 virtual int SetUseTranspose(bool use_transpose) {UseTranspose_ = use_transpose; return(0);}
448
450 virtual const char* Label() const {return(Epetra_Object::Label());}
451
453
459 virtual int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const {
461
463
471 virtual int ApplyInverse(const Epetra_MultiVector& X,
472 Epetra_MultiVector& Y) const
473 {
474 (void)X;
475 (void)Y;
476 return(-1);
477 }
478
480 bool HasNormInf() const {return(true);}
481
483 virtual bool UseTranspose() const {return(UseTranspose_);}
484
486
488
489
491
499 virtual const Epetra_Import* Importer() const {return(Importer_);}
500
502
511 virtual const Epetra_Export* Exporter() const {return(Exporter_);}
512
514
515 protected:
516
518
519
520 /* Several constants are pre-computed to save excess computations. However, if the structure of the
521 problem changes, specifically if the nonzero count in any given row changes, then this function should be called
522 to update these constants.
523 */
524 virtual void ComputeStructureConstants() const;
526 /* Several numeric constants are pre-computed to save excess computations. However, if the values of the
527 problem change, then this function should be called to update these constants.
528 */
529 virtual void ComputeNumericConstants() const;
531
532 void Setup();
533 void UpdateImportVector(int NumVectors) const;
534 void UpdateExportVector(int NumVectors) const;
535 void SetImportExport();
541
542 mutable int NumMyNonzeros_;
543 mutable long long NumGlobalNonzeros_;
544 mutable int MaxNumEntries_;
545 mutable double NormInf_;
546 mutable double NormOne_;
549
552 mutable bool LowerTriangular_;
553 mutable bool UpperTriangular_;
556 mutable bool HaveMaps_;
557
558
563
564};
565#endif /* EPETRA_BASICROWMATRIX_H */
Epetra_BasicRowMatrix: A class for simplifying the development of Epetra_RowMatrix adapters.
virtual int NumGlobalDiagonals() const
Returns the number of global nonzero diagonal entries.
virtual const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this operator.
Epetra_MultiVector * ImportVector_
virtual int NumMyDiagonals() const
Returns the number of local nonzero diagonal entries.
virtual int NumMyNonzeros() const
Returns the number of nonzero entries in the calling processor's portion of the matrix.
virtual const Epetra_Import * RowMatrixImporter() const
Returns the Epetra_Import object that contains the import operations for distributed operations.
virtual const Epetra_Map & RowMatrixColMap() const
Returns the Column Map object needed for implementing Epetra_RowMatrix.
virtual bool UseTranspose() const
Returns the current UseTranspose setting.
virtual const Epetra_Export * Exporter() const
Returns the Epetra_Export object that contains the export operations for distributed operations,...
virtual int NumMyCols() const
Returns the number of matrix columns owned by the calling processor.
virtual const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this operator (same as domain).
bool HasNormInf() const
Returns true because this class can compute an Inf-norm.
virtual double NormInf() const
Returns the infinity norm of the global matrix.
virtual int MaxNumEntries() const
Returns the maximum number of nonzero entries across all rows on this processor.
virtual long long NumGlobalCols64() const
virtual long long NumGlobalDiagonals64() const
virtual long long NumGlobalNonzeros64() const
virtual int NumMyRowEntries(int MyRow, int &NumEntries) const =0
Return the current number of values stored for the specified local row.
virtual int ExtractMyEntryView(int CurEntry, double *&Value, int &RowIndex, int &ColIndex)=0
Returns a reference to the ith entry in the matrix, along with its row and column index.
virtual int NumGlobalCols() const
Returns the number of global matrix columns.
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Returns the result of a Epetra_RowMatrix applied to a Epetra_MultiVector X in Y.
virtual const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this matrix.
virtual int NumMyRows() const
Returns the number of matrix rows owned by the calling processor.
virtual long long NumGlobalRows64() const
virtual const Epetra_Import * Importer() const
Returns the Epetra_Import object that contains the import operations for distributed operations,...
virtual int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Returns the result of a Epetra_RowMatrix inverse applied to an Epetra_MultiVector X in Y.
virtual int SetUseTranspose(bool use_transpose)
If set true, transpose of this operator will be applied.
virtual double NormOne() const
Returns the one norm of the global matrix.
virtual int ExtractMyEntryView(int CurEntry, double const *&Value, int &RowIndex, int &ColIndex) const =0
Returns a const reference to the ith entry in the matrix, along with its row and column index.
virtual int NumGlobalRows() const
Returns the number of global matrix rows.
virtual int ExtractMyRowCopy(int MyRow, int Length, int &NumEntries, double *Values, int *Indices) const =0
Returns a copy of the specified local row in user-provided arrays.
bool LowerTriangular() const
If matrix is lower triangular, this query returns true, otherwise it returns false.
virtual const Epetra_Map & RowMatrixRowMap() const
Returns the Row Map object needed for implementing Epetra_RowMatrix.
Epetra_MultiVector * ExportVector_
virtual bool Filled() const
If FillComplete() has been called, this query returns true, otherwise it returns false,...
virtual int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Returns the result of a Epetra_BasicRowMatrix solve with a Epetra_MultiVector X in Y (not implemented...
virtual int NumGlobalNonzeros() const
Returns the number of nonzero entries in the global matrix.
virtual const char * Label() const
Returns a character string describing the operator.
virtual const Epetra_BlockMap & Map() const
Implement the Epetra_SrcDistObjec::Map() function.
virtual bool UpperTriangular() const
If matrix is upper triangular, this query returns true, otherwise it returns false.
Epetra_BlockMap: A class for partitioning block element vectors and matrices.
Epetra_Comm: The Epetra Communication Abstract Base Class.
Definition: Epetra_Comm.h:73
Epetra_CompObject: Functionality and data that is common to all computational classes.
Epetra_Export: This class builds an export object for efficient exporting of off-processor elements.
Definition: Epetra_Export.h:62
Epetra_Import: This class builds an import object for efficient importing of off-processor elements.
Definition: Epetra_Import.h:63
Epetra_Map: A class for partitioning vectors and matrices.
Definition: Epetra_Map.h:119
Epetra_MultiVector: A class for constructing and using dense multi-vectors, vectors and matrices in p...
Epetra_Object: The base Epetra class.
Definition: Epetra_Object.h:57
virtual void Print(std::ostream &os) const
Print object to an output stream Print method.
virtual const char * Label() const
Epetra_Object Label access funtion.
virtual const Epetra_Map & OperatorDomainMap() const =0
Returns the Epetra_Map object associated with the domain of this operator.
virtual const Epetra_Map & OperatorRangeMap() const =0
Returns the Epetra_Map object associated with the range of this operator.
Epetra_RowMatrix: A pure virtual class for using real-valued double-precision row matrices.
virtual int Multiply(bool TransA, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const =0
Returns the result of a Epetra_RowMatrix multiplied by a Epetra_MultiVector X in Y.
virtual int ExtractDiagonalCopy(Epetra_Vector &Diagonal) const =0
Returns a copy of the main diagonal in a user-provided vector.
virtual long long NumGlobalRows64() const =0
virtual const Epetra_Map & RowMatrixColMap() const =0
Returns the Epetra_Map object associated with the columns of this matrix.
virtual const Epetra_Map & RowMatrixRowMap() const =0
Returns the Epetra_Map object associated with the rows of this matrix.
virtual long long NumGlobalCols64() const =0
virtual int InvRowSums(Epetra_Vector &x) const =0
Computes the sum of absolute values of the rows of the Epetra_RowMatrix, results returned in x.
virtual int RightScale(const Epetra_Vector &x)=0
Scales the Epetra_RowMatrix on the right with a Epetra_Vector x.
virtual int InvColSums(Epetra_Vector &x) const =0
Computes the sum of absolute values of the columns of the Epetra_RowMatrix, results returned in x.
virtual long long NumGlobalDiagonals64() const =0
virtual int LeftScale(const Epetra_Vector &x)=0
Scales the Epetra_RowMatrix on the left with a Epetra_Vector x.
Epetra_Vector: A class for constructing and using dense vectors on a parallel computer.