Epetra_MultiVector.h

Go to the documentation of this file.
00001 
00002 //@HEADER
00003 /*
00004 ************************************************************************
00005 
00006               Epetra: Linear Algebra Services Package 
00007                 Copyright (2001) Sandia Corporation
00008 
00009 Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00010 license for use of this work by or on behalf of the U.S. Government.
00011 
00012 This library is free software; you can redistribute it and/or modify
00013 it under the terms of the GNU Lesser General Public License as
00014 published by the Free Software Foundation; either version 2.1 of the
00015 License, or (at your option) any later version.
00016  
00017 This library is distributed in the hope that it will be useful, but
00018 WITHOUT ANY WARRANTY; without even the implied warranty of
00019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020 Lesser General Public License for more details.
00021  
00022 You should have received a copy of the GNU Lesser General Public
00023 License along with this library; if not, write to the Free Software
00024 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00025 USA
00026 Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00027 
00028 ************************************************************************
00029 */
00030 //@HEADER
00031 
00032 #ifndef EPETRA_MULTIVECTOR_H
00033 #define EPETRA_MULTIVECTOR_H
00034 
00035 class Epetra_Comm;
00036 class Epetra_BlockMap;
00037 class Epetra_Map;
00038 class Epetra_Import;
00039 class Epetra_Export;
00040 class Epetra_Distributor;
00041 class Epetra_Vector;
00042 
00043 #include "Epetra_DistObject.h"
00044 #include "Epetra_CompObject.h"
00045 #include "Epetra_BLAS.h"
00046 #include "Epetra_Util.h"
00047 
00049 
00170 //==========================================================================
00171 class Epetra_MultiVector: public Epetra_DistObject, public Epetra_CompObject, public Epetra_BLAS {
00172 
00173  public:
00174 
00176 
00177 
00178 
00195   Epetra_MultiVector(const Epetra_BlockMap& Map, int NumVectors, bool zeroOut = true);
00196 
00198   
00199   Epetra_MultiVector(const Epetra_MultiVector& Source);
00200   
00202 
00221   Epetra_MultiVector(Epetra_DataAccess CV, const Epetra_BlockMap& Map, 
00222          double *A, int MyLDA, int NumVectors);
00223 
00225 
00240   Epetra_MultiVector(Epetra_DataAccess CV, const Epetra_BlockMap& Map, 
00241          double **ArrayOfPointers, int NumVectors);
00242 
00244 
00258   Epetra_MultiVector(Epetra_DataAccess CV,  
00259          const Epetra_MultiVector& Source, int *Indices, int NumVectors);
00260 
00262 
00276   Epetra_MultiVector(Epetra_DataAccess CV, 
00277          const Epetra_MultiVector& Source, int StartIndex, 
00278          int NumVectors);
00279   
00281   virtual ~Epetra_MultiVector();
00283 
00285 
00286 
00288 
00307   int ReplaceGlobalValue(int GlobalRow, int VectorIndex, double ScalarValue);
00308 
00309 
00311 
00329   int ReplaceGlobalValue(int GlobalBlockRow, int BlockRowOffset, int VectorIndex, double ScalarValue);
00330 
00331 
00333 
00352   int SumIntoGlobalValue(int GlobalRow, int VectorIndex, double ScalarValue);
00353 
00354 
00356 
00374   int SumIntoGlobalValue(int GlobalBlockRow, int BlockRowOffset, int VectorIndex, double ScalarValue);
00375 
00377 
00401   int ReplaceMyValue(int MyRow, int VectorIndex, double ScalarValue);
00402 
00403 
00405 
00423   int ReplaceMyValue(int MyBlockRow, int BlockRowOffset, int VectorIndex, double ScalarValue);
00424 
00425 
00427 
00446   int SumIntoMyValue(int MyRow, int VectorIndex, double ScalarValue);
00447 
00448 
00450 
00468   int SumIntoMyValue(int MyBlockRow, int BlockRowOffset, int VectorIndex, double ScalarValue);
00469 
00471 
00477   int PutScalar (double ScalarConstant);
00478   
00480 
00486   int Random();
00487 
00489 
00491 
00492 
00494 
00508   int ExtractCopy(double *A, int MyLDA) const;
00509 
00511 
00521   int ExtractCopy(double **ArrayOfPointers) const;
00522 
00523   // ExtractView functions
00524 
00525   
00527 
00541   int ExtractView(double **A, int *MyLDA) const;
00542 
00544 
00554   int ExtractView(double ***ArrayOfPointers) const;
00555 
00557 
00559 
00560 
00562 
00570   int Dot(const Epetra_MultiVector& A, double *Result) const;
00571 
00573 
00583   int Abs(const Epetra_MultiVector& A);
00584 
00586 
00601   int Reciprocal(const Epetra_MultiVector& A);
00602 
00604 
00612   int Scale(double ScalarValue);
00613 
00615 
00625   int Scale(double ScalarA, const Epetra_MultiVector& A);
00626 
00628 
00640   int Update(double ScalarA, const Epetra_MultiVector& A, double ScalarThis);
00641 
00643 
00659   int Update(double ScalarA, const Epetra_MultiVector& A, 
00660        double ScalarB, const Epetra_MultiVector& B, double ScalarThis);
00661 
00663 
00669   int Norm1   (double * Result) const;
00670 
00672 
00678   int Norm2   (double * Result) const;
00679 
00681 
00687   int NormInf (double * Result) const;
00688 
00690 
00705   int NormWeighted   (const Epetra_MultiVector& Weights, double * Result) const;
00706 
00708 
00717   int MinValue  (double * Result) const;
00718 
00720 
00729   int MaxValue  (double * Result) const;
00730 
00732 
00738   int MeanValue (double * Result) const;
00739   
00740   
00742 
00793   int Multiply(char TransA, char TransB, double ScalarAB, 
00794          const Epetra_MultiVector& A, const Epetra_MultiVector& B,
00795          double ScalarThis );
00796   
00797 
00798 
00800 
00806   int Multiply(double ScalarAB, const Epetra_MultiVector& A, const Epetra_MultiVector& B,
00807          double ScalarThis );
00808 
00809 
00811 
00817   int ReciprocalMultiply(double ScalarAB, const Epetra_MultiVector& A, const Epetra_MultiVector& B,
00818        double ScalarThis );
00819 
00821 
00823 
00824 
00825 
00827 
00833   int SetSeed(unsigned int Seed_in){return(Util_.SetSeed(Seed_in));};
00834 
00836 
00839   unsigned int Seed(){return(Util_.Seed());};
00840 
00842 
00844 
00845 
00847 
00853   Epetra_MultiVector& operator = (const Epetra_MultiVector& Source);
00854   
00855   // Local element access functions
00856 
00857   // 
00858 
00860 
00863   double*& operator [] (int i) { return Pointers_[i]; }
00865 
00868   //  const double*& operator [] (int i) const;
00869   double * const & operator [] (int i) const { return Pointers_[i]; }
00870 
00872 
00875   Epetra_Vector * & operator () (int i);
00877 
00880   const Epetra_Vector * & operator () (int i) const;
00881 
00883 
00885 
00886   
00888   int NumVectors() const {return(NumVectors_);};
00889 
00891   int MyLength() const {return(MyLength_);};
00892 
00894   int GlobalLength() const {return(GlobalLength_);};
00895 
00897   int Stride() const {return(Stride_);};
00898   
00900   bool ConstantStride() const {return(ConstantStride_);};
00902 
00906   int ReplaceMap(const Epetra_BlockMap& map);
00907 
00909 
00910 
00912   virtual void Print(ostream & os) const;
00914 
00916 
00917 
00919 
00938   int ResetView(double ** ArrayOfPointers);
00939 
00941   double* Values() const {return Values_;};
00942 
00944   double** Pointers() const {return Pointers_;};
00946 
00947   // Expert-only function
00948   int Reduce(); 
00949 
00950  protected:
00951 
00952   // Internal utilities
00953   void Assign(const Epetra_MultiVector& rhs);
00954   int CheckInput();
00955 
00956   double *Values_;    // local MultiVector coefficients
00957 
00958  private:
00959 
00960 
00961   // Internal utilities
00962 
00963   int AllocateForCopy(void);
00964   int DoCopy(void);
00965 
00966   inline void UpdateDoubleTemp() const
00967   {if (DoubleTemp_==0) DoubleTemp_=new double[NumVectors_+1]; return;}
00968 
00969   inline void UpdateVectors()  const {if (Vectors_==0) { Vectors_ = new Epetra_Vector *[NumVectors_]; 
00970     for (int i=0; i<NumVectors_; i++) Vectors_[i] = 0;}
00971     return;
00972   }
00973 
00974   int AllocateForView(void);
00975   int DoView(void);
00976   int ChangeGlobalValue(int GlobalBlockRow,
00977                         int BlockRowOffset, 
00978                         int VectorIndex,
00979                         double ScalarValue,
00980                         bool SumInto);
00981   int ChangeMyValue(int MyBlockRow,
00982                     int BlockRowOffset, 
00983                     int VectorIndex,
00984                     double ScalarValue,
00985                     bool SumInto);
00986 
00987   int CheckSizes(const Epetra_SrcDistObject& A);
00988 
00989   int CopyAndPermute(const Epetra_SrcDistObject & Source,
00990                      int NumSameIDs, 
00991                      int NumPermuteIDs,
00992                      int * PermuteToLIDs,
00993                      int * PermuteFromLIDs,
00994                      const Epetra_OffsetIndex * Indexor);
00995 
00996   int PackAndPrepare(const Epetra_SrcDistObject & Source,
00997                      int NumExportIDs,
00998                      int * ExportLIDs,
00999                      int & LenExports,
01000                      char * & Exports,
01001                      int & SizeOfPacket,
01002                      int * Sizes,
01003                      bool & VarSizes,
01004                      Epetra_Distributor & Distor);
01005   
01006   int UnpackAndCombine(const Epetra_SrcDistObject & Source,
01007                        int NumImportIDs,
01008                        int * ImportLIDs, 
01009                        int LenImports, 
01010                        char * Imports,
01011                        int & SizeOfPacket, 
01012                        Epetra_Distributor & Distor,
01013                        Epetra_CombineMode CombineMode,
01014                        const Epetra_OffsetIndex * Indexor );
01015 
01016   double **Pointers_;        // Pointers to each vector;
01017   
01018   int MyLength_;
01019   int GlobalLength_;
01020   int NumVectors_;
01021   bool UserAllocated_;
01022   bool ConstantStride_;
01023   int Stride_;
01024   bool Allocated_;
01025   mutable double * DoubleTemp_;
01026   mutable Epetra_Vector ** Vectors_;
01027   Epetra_Util Util_;
01028 
01029 };
01030 
01031 #endif /* EPETRA_MULTIVECTOR_H */

Generated on Wed May 12 21:41:05 2010 for Epetra Package Browser (Single Doxygen Collection) by  doxygen 1.4.7