Epetra Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Epetra_MultiVector.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_MULTIVECTOR_H
45 #define EPETRA_MULTIVECTOR_H
46 
47 #if defined(Epetra_SHOW_DEPRECATED_WARNINGS)
48 #ifdef __GNUC__
49 #warning "The Epetra package is deprecated"
50 #endif
51 #endif
52 
53 
54 
55 class Epetra_Comm;
56 class Epetra_BlockMap;
57 class Epetra_Map;
58 class Epetra_Import;
59 class Epetra_Export;
60 class Epetra_Distributor;
61 class Epetra_Vector;
62 
63 #include "Epetra_ConfigDefs.h"
64 #include "Epetra_DistObject.h"
65 #include "Epetra_CompObject.h"
66 #include "Epetra_BLAS.h"
67 #include "Epetra_Util.h"
68 
70 
191 //==========================================================================
192 class EPETRA_LIB_DLL_EXPORT Epetra_MultiVector: public Epetra_DistObject, public Epetra_CompObject, public Epetra_BLAS {
193 
194  public:
195 
197 
198 
216  Epetra_MultiVector(const Epetra_BlockMap& Map, int NumVectors, bool zeroOut = true);
217 
219 
220  Epetra_MultiVector(const Epetra_MultiVector& Source);
221 
223 
243  double *A, int MyLDA, int NumVectors);
244 
246 
262  double **ArrayOfPointers, int NumVectors);
263 
265 
280  const Epetra_MultiVector& Source, int *Indices, int NumVectors);
281 
283 
298  const Epetra_MultiVector& Source, int StartIndex,
299  int NumVectors);
300 
302  virtual ~Epetra_MultiVector();
304 
306 
307 
309 
328 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
329  int ReplaceGlobalValue(int GlobalRow, int VectorIndex, double ScalarValue);
330 #endif
331 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
332  int ReplaceGlobalValue(long long GlobalRow, int VectorIndex, double ScalarValue);
333 #endif
334 
335 
337 
355 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
356  int ReplaceGlobalValue(int GlobalBlockRow, int BlockRowOffset, int VectorIndex, double ScalarValue);
357 #endif
358 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
359  int ReplaceGlobalValue(long long GlobalBlockRow, int BlockRowOffset, int VectorIndex, double ScalarValue);
360 #endif
361 
362 
364 
383 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
384  int SumIntoGlobalValue(int GlobalRow, int VectorIndex, double ScalarValue);
385 #endif
386 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
387  int SumIntoGlobalValue(long long GlobalRow, int VectorIndex, double ScalarValue);
388 #endif
389 
390 
392 
410 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
411  int SumIntoGlobalValue(int GlobalBlockRow, int BlockRowOffset, int VectorIndex, double ScalarValue);
412 #endif
413 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
414  int SumIntoGlobalValue(long long GlobalBlockRow, int BlockRowOffset, int VectorIndex, double ScalarValue);
415 #endif
416 
418 
442  int ReplaceMyValue(int MyRow, int VectorIndex, double ScalarValue);
443 
444 
446 
464  int ReplaceMyValue(int MyBlockRow, int BlockRowOffset, int VectorIndex, double ScalarValue);
465 
466 
468 
487  int SumIntoMyValue(int MyRow, int VectorIndex, double ScalarValue);
488 
489 
491 
509  int SumIntoMyValue(int MyBlockRow, int BlockRowOffset, int VectorIndex, double ScalarValue);
510 
512 
518  int PutScalar (double ScalarConstant);
519 
521 
527  int Random();
528 
530 
532 
533 
535 
549  int ExtractCopy(double *A, int MyLDA) const;
550 
552 
562  int ExtractCopy(double **ArrayOfPointers) const;
563 
564  // ExtractView functions
565 
566 
568 
582  int ExtractView(double **A, int *MyLDA) const;
583 
585 
595  int ExtractView(double ***ArrayOfPointers) const;
596 
598 
600 
601 
603 
611  int Dot(const Epetra_MultiVector& A, double *Result) const;
612 
614 
624  int Abs(const Epetra_MultiVector& A);
625 
627 
642  int Reciprocal(const Epetra_MultiVector& A);
643 
645 
653  int Scale(double ScalarValue);
654 
656 
666  int Scale(double ScalarA, const Epetra_MultiVector& A);
667 
669 
681  int Update(double ScalarA, const Epetra_MultiVector& A, double ScalarThis);
682 
684 
700  int Update(double ScalarA, const Epetra_MultiVector& A,
701  double ScalarB, const Epetra_MultiVector& B, double ScalarThis);
702 
704 
711  int Norm1 (double * Result) const;
712 
714 
721  int Norm2 (double * Result) const;
722 
724 
730  int NormInf (double * Result) const;
731 
733 
748  int NormWeighted (const Epetra_MultiVector& Weights, double * Result) const;
749 
751 
760  int MinValue (double * Result) const;
761 
763 
772  int MaxValue (double * Result) const;
773 
775 
782  int MeanValue (double * Result) const;
783 
784 
786 
838  int Multiply(char TransA, char TransB, double ScalarAB,
839  const Epetra_MultiVector& A, const Epetra_MultiVector& B,
840  double ScalarThis );
841 
842 
843 
845 
851  int Multiply(double ScalarAB, const Epetra_MultiVector& A, const Epetra_MultiVector& B,
852  double ScalarThis );
853 
854 
856 
862  int ReciprocalMultiply(double ScalarAB, const Epetra_MultiVector& A, const Epetra_MultiVector& B,
863  double ScalarThis );
864 
866 
868 
869 
870 
872 
878  int SetSeed(unsigned int Seed_in){return(Util_.SetSeed(Seed_in));};
879 
881 
884  unsigned int Seed(){return(Util_.Seed());};
885 
887 
889 
890 
892 
899 
900  // Local element access functions
901 
902  //
903 
905 
908  double*& operator [] (int i) { return Pointers_[i]; }
910 
913  // const double*& operator [] (int i) const;
914  double * const & operator [] (int i) const { return Pointers_[i]; }
915 
917 
920  Epetra_Vector * & operator () (int i);
922 
925  const Epetra_Vector * & operator () (int i) const;
926 
928 
930 
931 
933  int NumVectors() const {return(NumVectors_);};
934 
936  int MyLength() const {return(MyLength_);};
937 
939  int GlobalLength() const { int ret_val = GlobalLength_; return ret_val; }
940 
942  long long GlobalLength64() const {return(GlobalLength_);};
943 
945  int Stride() const {return(Stride_);};
946 
948  bool ConstantStride() const {return(ConstantStride_);};
950 
954  int ReplaceMap(const Epetra_BlockMap& map);
955 
957 
958 
960  virtual void Print(std::ostream & os) const;
962 
964 
965 
967 
986  int ResetView(double ** ArrayOfPointers);
987 
989  double* Values() const {return Values_;};
990 
992  double** Pointers() const {return Pointers_;};
994 
995  // Expert-only function
996 #ifdef Reduce
997 #undef Reduce
998 #endif
999  int Reduce();
1000 
1001  protected:
1002 
1003  // Internal utilities
1004  void Assign(const Epetra_MultiVector& rhs);
1005  int CheckInput();
1006 
1007  double *Values_; // local MultiVector coefficients
1008 
1009  private:
1010 
1011 
1012  // Internal utilities
1013 
1014  int AllocateForCopy(void);
1015  int DoCopy(void);
1016 
1017  inline void UpdateDoubleTemp() const
1018  {if (DoubleTemp_==0) DoubleTemp_=new double[NumVectors_+1]; return;}
1019 
1020  inline void UpdateVectors() const {if (Vectors_==0) { Vectors_ = new Epetra_Vector *[NumVectors_];
1021  for (int i=0; i<NumVectors_; i++) Vectors_[i] = 0;}
1022  return;
1023  }
1024 
1025  int AllocateForView(void);
1026  int DoView(void);
1027  template<typename int_type>
1028  int ChangeGlobalValue(int_type GlobalBlockRow,
1029  int BlockRowOffset,
1030  int VectorIndex,
1031  double ScalarValue,
1032  bool SumInto);
1033  int ChangeMyValue(int MyBlockRow,
1034  int BlockRowOffset,
1035  int VectorIndex,
1036  double ScalarValue,
1037  bool SumInto);
1038 
1039  int CheckSizes(const Epetra_SrcDistObject& A);
1040 
1041  int CopyAndPermute(const Epetra_SrcDistObject & Source,
1042  int NumSameIDs,
1043  int NumPermuteIDs,
1044  int * PermuteToLIDs,
1045  int * PermuteFromLIDs,
1046  const Epetra_OffsetIndex * Indexor,
1047  Epetra_CombineMode CombineMode = Zero);
1048 
1049  int PackAndPrepare(const Epetra_SrcDistObject & Source,
1050  int NumExportIDs,
1051  int * ExportLIDs,
1052  int & LenExports,
1053  char * & Exports,
1054  int & SizeOfPacket,
1055  int * Sizes,
1056  bool & VarSizes,
1057  Epetra_Distributor & Distor);
1058 
1059  int UnpackAndCombine(const Epetra_SrcDistObject & Source,
1060  int NumImportIDs,
1061  int * ImportLIDs,
1062  int LenImports,
1063  char * Imports,
1064  int & SizeOfPacket,
1065  Epetra_Distributor & Distor,
1066  Epetra_CombineMode CombineMode,
1067  const Epetra_OffsetIndex * Indexor );
1068 
1069  double **Pointers_; // Pointers to each vector;
1070 
1072  long long GlobalLength_;
1076  int Stride_;
1078  mutable double * DoubleTemp_;
1081 
1082 };
1083 
1084 #endif /* EPETRA_MULTIVECTOR_H */
Epetra_MultiVector: A class for constructing and using dense multi-vectors, vectors and matrices in p...
int GlobalLength() const
Returns the global vector length of vectors in the multi-vector.
Epetra_Map: A class for partitioning vectors and matrices.
Definition: Epetra_Map.h:127
Epetra_Distributor: The Epetra Gather/Scatter Setup Base Class.
virtual int CopyAndPermute(const Epetra_SrcDistObject &Source, int NumSameIDs, int NumPermuteIDs, int *PermuteToLIDs, int *PermuteFromLIDs, const Epetra_OffsetIndex *Indexor, Epetra_CombineMode CombineMode=Zero)=0
Perform ID copies and permutations that are on processor.
Epetra_OffsetIndex: This class builds index for efficient mapping of data from one Epetra_CrsGraph ba...
virtual void Print(std::ostream &os) const
Print method.
int MyLength() const
Returns the local vector length on the calling processor of vectors in the multi-vector.
double ** Pointers() const
Get pointer to individual vector pointers.
Epetra_Export: This class builds an export object for efficient exporting of off-processor elements...
Definition: Epetra_Export.h:70
Epetra_Vector: A class for constructing and using dense vectors on a parallel computer.
Epetra_CompObject & operator=(const Epetra_CompObject &src)
int SetSeed(unsigned int Seed_in)
Set seed for Random function.
Epetra_Import: This class builds an import object for efficient importing of off-processor elements...
Definition: Epetra_Import.h:71
int NumVectors() const
Returns the number of vectors in the multi-vector.
virtual int CheckSizes(const Epetra_SrcDistObject &Source)=0
Allows the source and target (this) objects to be compared for compatibility, return nonzero if not...
void UpdateDoubleTemp() const
Epetra_Vector ** Vectors_
Epetra_Util: The Epetra Util Wrapper Class.
Definition: Epetra_Util.h:87
Epetra_BLAS: The Epetra BLAS Wrapper Class.
Definition: Epetra_BLAS.h:78
Epetra_Comm: The Epetra Communication Abstract Base Class.
Definition: Epetra_Comm.h:81
long long GlobalLength64() const
Returns the 64-bit global vector length of vectors in the multi-vector.
void UpdateVectors() const
Epetra_CompObject: Functionality and data that is common to all computational classes.
virtual int UnpackAndCombine(const Epetra_SrcDistObject &Source, int NumImportIDs, int *ImportLIDs, int LenImports, char *Imports, int &SizeOfPacket, Epetra_Distributor &Distor, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex *Indexor)=0
Perform any unpacking and combining after call to DoTransfer().
Epetra_BlockMap: A class for partitioning block element vectors and matrices.
int Stride() const
Returns the stride between vectors in the multi-vector (only meaningful if ConstantStride() is true)...
bool ConstantStride() const
Returns true if this multi-vector has constant stride between vectors.
double * Values() const
Get pointer to MultiVector values.
unsigned int Seed()
Get seed from Random function.
Epetra_CombineMode
Epetra_SrcDistObject: A class for supporting flexible source distributed objects for import/export op...
Epetra_DataAccess
Epetra_DistObject: A class for constructing and using dense multi-vectors, vectors and matrices in pa...
virtual int PackAndPrepare(const Epetra_SrcDistObject &Source, int NumExportIDs, int *ExportLIDs, int &LenExports, char *&Exports, int &SizeOfPacket, int *Sizes, bool &VarSizes, Epetra_Distributor &Distor)=0
Perform any packing or preparation required for call to DoTransfer().