fei_Aztec_Vector.hpp

00001 #ifndef _fei_Aztec_Vector_hpp_
00002 #define _fei_Aztec_Vector_hpp_
00003 
00004 /*--------------------------------------------------------------------*/
00005 /*    Copyright 2005 Sandia Corporation.                              */
00006 /*    Under the terms of Contract DE-AC04-94AL85000, there is a       */
00007 /*    non-exclusive license for use of this work by or on behalf      */
00008 /*    of the U.S. Government.  Export of this program may require     */
00009 /*    a license from the United States Government.                    */
00010 /*--------------------------------------------------------------------*/
00011 
00012 //
00013 // This class provides a vector that can be used with the AztecDMSR_matrix
00014 // and the AztecDVBR_Matrix.
00015 //
00016 // An important restriction to note:
00017 //
00018 // * An Aztec_Vector can not be constructed until AFTER the AztecDMSR_Matrix
00019 //   (or AztecDVBR_Matrix) that it is to be used with has been completely
00020 //   initialized and filled (e.g., A.loadComplete() has been called (which
00021 //   means, most importantly, that AZ_transform has been called)). This is
00022 //   because the local data array for an aztec vector must be allocated
00023 //   with enough extra space to hold 'boundary elements' that are exchanged
00024 //   with other processors during the calculation of a parallel matrix-vector
00025 //   product, and we don't know how much memory that requires until after
00026 //   AZ_transform has been called.
00027 //
00028 // * Also, the calling code is responsible for keeping track of any 
00029 //   re-ordering that AZ_transform has done. i.e., Aztec_Vector is just
00030 //   like a raw array with respect to indexing of entries. If v is an
00031 //   instantiation of an Aztec_Vector, then v[9] literally returns the
00032 //   entry at position 9 (the 10th entry, since indexing is 0-based).
00033 //
00034 namespace fei_trilinos {
00035 
00036 class Aztec_Map;
00037 
00039 class Aztec_Vector {
00040   public:
00041     // Constructor.
00042     Aztec_Vector(const Aztec_Map& map, int* data_org);
00043 
00044     Aztec_Vector(const Aztec_Vector& source);  // copy constructor
00045 
00046     virtual ~Aztec_Vector ();
00047 
00048     Aztec_Vector* newVector() const;
00049 
00050     // Mathematical functions.
00051     double dotProd (const Aztec_Vector& y) const;
00052     void scale (double s);
00053     void linComb (const Aztec_Vector& b, double s, const Aztec_Vector& c);
00054     void addVec (double s, const Aztec_Vector& c);
00055     double norm () const;
00056     double norm1 () const;
00057  
00058     // operator=
00059     Aztec_Vector& operator = (const Aztec_Vector& rhs);
00060     
00061     // Access functions.
00062     double& operator [] (int index);
00063     const double& operator [] (int index) const;
00064     
00065     void put (double scalar);
00066 
00067     const double* startPointer() const {return localCoeffs_;};
00068 
00069     //Special function
00070     bool readFromFile(const char *fileName);
00071     bool writeToFile(const char *fileName) const;
00072     
00073   protected:
00074     virtual void assign(const Aztec_Vector& rhs);
00075     
00076   private:
00077     void checkInput();
00078     int inUpdate(int globalIndex, int& localIndex) const;
00079 
00080     const Aztec_Map& amap_;
00081     double *localCoeffs_;        // local vector coefficients
00082     int length_;
00083 };
00084 
00085 }//namespace fei_trilinos
00086 
00087 #endif

Generated on Wed May 12 21:30:40 2010 for FEI by  doxygen 1.4.7