PlayaSerialVector.hpp

00001 /* @HEADER@ */
00002 //
00003  /* @HEADER@ */
00004 
00005 #ifndef PLAYA_SERIAL_VECTOR_HPP
00006 #define PLAYA_SERIAL_VECTOR_HPP
00007 
00008 #include "PlayaDefs.hpp"
00009 #include "PlayaSingleChunkVector.hpp"
00010 #include "PlayaLoadableVector.hpp"
00011 #include "PlayaVectorSpaceDecl.hpp"
00012 #include "Teuchos_Array.hpp"
00013 
00014 namespace Playa
00015 {
00016 using namespace Teuchos;
00017 
00018 template <class Scalar> class Vector;
00019 
00026 class SerialVector : public SingleChunkVector<double>,
00027                      public LoadableVector<double>,
00028                      public Describable
00029 {
00030 public:
00031 
00033   SerialVector(const VectorSpace<double>& vs);
00034 
00038   RCP<const VectorSpaceBase<double> > space() const {return vecSpace_.ptr();}
00040 
00044   void setElement(int globalIndex, const double& value);
00045 
00047   void addToElement(int globalIndex, const double& value);
00048 
00050   void setElements(int numElems, const int* globalIndices, 
00051     const double* values);
00052 
00053 
00055   void addToElements(int numElems, const int* globalIndices, 
00056     const double* values);
00057 
00059   void finalizeAssembly();
00061 
00065   std::string description() const ;
00067 
00068 
00069 
00073   void getElements(const int* globalIndices, int numElems,
00074     Array<double>& elems) const ;
00076 
00078   static const SerialVector* getConcrete(const Vector<double>& x);
00080   static SerialVector* getConcrete(Vector<double>& x);
00081 
00082       
00086   virtual const double* dataPtr() const {return &(data_[0]);}
00088   virtual double* dataPtr() {return &(data_[0]);}
00089 
00091   virtual int chunkSize() const {return dim_;}
00093 
00094 
00095 
00096   
00097 private:
00098 
00099   VectorSpace<double> vecSpace_;
00100 
00101   Array<double> data_;
00102 
00103   int dim_;
00104 };
00105   
00106 }
00107 
00108 
00109 #endif

doxygen