00001
00002
00003
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
00028
00029
00030 class DenseSerialMatrix : public LinearOpWithSpaces<double>,
00031 public LoadableMatrix<double>,
00032 public Playa::Printable
00033 {
00034 public:
00035
00036
00037 DenseSerialMatrix(
00038 const VectorSpace<double>& domain,
00039 const VectorSpace<double>& range);
00040
00041
00042 ~DenseSerialMatrix(){;}
00043
00044
00045
00046
00047 virtual void apply(Teuchos::ETransp transApplyType,
00048 const Vector<double>& in,
00049 Vector<double> out) const ;
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 virtual void addToRow(int globalRowIndex,
00065 int nElemsToInsert,
00066 const int* globalColumnIndices,
00067 const double* elementValues) ;
00068
00069
00070 virtual void zero() ;
00071
00072
00073
00074
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
00102 void denseSVD(const LinearOperator<double>& A,
00103 LinearOperator<double>& U,
00104 Vector<double>& Sigma,
00105 LinearOperator<double>& Vt);
00106
00107
00108 SolverState<double> denseSolve(const LinearOperator<double>& A,
00109 const Vector<double>& b,
00110 Vector<double>& x);
00111
00112 }
00113
00114 #endif