PlayaDenseSerialMatrix.hpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 //
00003  /* @HEADER@ */
00004 
00005 
00006 
00007 #ifndef PLAYA_DENSE_SERIAL_MATRIX_H
00008 #define PLAYA_DENSE_SERIAL_MATRIX_H
00009 
00010 #include "PlayaDefs.hpp"
00011 #include "Teuchos_Array.hpp"
00012 #include "Teuchos_RCP.hpp"
00013 #include "PlayaPrintable.hpp"
00014 #include "Teuchos_Describable.hpp"
00015 #include "PlayaLinearOpWithSpacesDecl.hpp"
00016 #include "PlayaSerialVectorSpace.hpp"
00017 #include "PlayaLoadableMatrix.hpp"
00018 #include "PlayaSolverState.hpp"
00019 
00020 namespace Playa
00021 {
00022 using namespace Teuchos;
00023 
00024 template <class T> class LinearOperator;
00025 
00026 /**
00027  * Linear operator implemented as a dense matrix.
00028  */
00029 
00030 class DenseSerialMatrix : public LinearOpWithSpaces<double>,
00031                           public LoadableMatrix<double>,
00032                           public Playa::Printable
00033 {
00034 public:
00035   /** Construct with domain and range spaces, which should be
00036    * DenseSerialVectorSpace objects */
00037   DenseSerialMatrix(
00038     const VectorSpace<double>& domain,
00039     const VectorSpace<double>& range);
00040 
00041   /** Virtual dtor */
00042   ~DenseSerialMatrix(){;}
00043 
00044   /** 
00045    * Apply either the operator or its transpose
00046    */
00047   virtual void apply(Teuchos::ETransp transApplyType,
00048     const Vector<double>& in,
00049     Vector<double> out) const ;
00050 
00051   /** Insert a set of elements in a row, adding to any previously
00052    * existing values.  The nonzero structure of the matrix must have
00053    * been determined at construction time. 
00054    *
00055    * @param globalRowIndex the global index of the row to which these
00056    * elements belong.
00057    * @param nElemsToInsert the number of elements being inserted in this
00058    * step
00059    * @param globalColumnIndices array of column indices. Must 
00060    * be nElemsToInsert in length. 
00061    * @param elements array of element values. Must be nElemsToInsert in
00062    * length
00063    */
00064   virtual void addToRow(int globalRowIndex,
00065     int nElemsToInsert,
00066     const int* globalColumnIndices,
00067     const double* elementValues) ;
00068 
00069   /** Set all elements to zero, preserving the existing structure */
00070   virtual void zero() ;
00071 
00072 
00073 
00074   /** write to a stream */
00075   void print(std::ostream& os) const ;
00076 
00077   /** */
00078   const double * const dataPtr() const {return &(data_[0]);}
00079 
00080   /** */
00081   double* dataPtr() {return &(data_[0]);}
00082 
00083   /** */
00084   int numRows() const {return nRows_;}
00085 
00086   /** */
00087   int numCols() const {return nCols_;}
00088 
00089   /** */
00090   void setRow(int row, const Array<double>& rowVals);
00091 
00092 
00093 private:
00094 
00095   int nRows_;
00096   int nCols_;
00097   Array<double> data_;
00098 };
00099 
00100 
00101 /** \relates DenseSerialMatrix */
00102 void denseSVD(const LinearOperator<double>& A,
00103   LinearOperator<double>& U,  
00104   Vector<double>& Sigma,
00105   LinearOperator<double>& Vt);
00106 
00107 /** \relates DenseSerialMatrix */
00108 SolverState<double> denseSolve(const LinearOperator<double>& A,
00109   const Vector<double>& b,
00110   Vector<double>& x);
00111 
00112 }
00113 
00114 #endif

Site Contact