![]() |
00001 // Copyright (C) 2002 Johan Hoffman and Anders Logg. 00002 // Licensed under the GNU GPL Version 2. 00003 // 00004 // Modified by Erik Svensson, 2003 00005 00006 #ifndef __DENSE_MATRIX_H 00007 #define __DENSE_MATRIX_H 00008 00009 #include <dolfin/dolfin_log.h> 00010 #include <dolfin/constants.h> 00011 #include <dolfin/GenericMatrix.h> 00012 00013 namespace dolfin { 00014 00015 class SparseMatrix; 00016 00017 class DenseMatrix : public GenericMatrix { 00018 public: 00019 00020 DenseMatrix (); 00021 DenseMatrix (unsigned int m, unsigned int n); 00022 DenseMatrix (const DenseMatrix& A); 00023 DenseMatrix (const SparseMatrix& A); 00024 ~DenseMatrix (); 00025 00026 void init(unsigned int m, unsigned int n); 00027 void clear(); 00028 00029 unsigned int size(unsigned int dim) const; 00030 unsigned int size() const; 00031 unsigned int rowsize(unsigned int i) const; 00032 unsigned int bytes() const; 00033 00034 real operator()(unsigned int i, unsigned int j) const; 00035 real* operator[](unsigned int i); 00036 real operator()(unsigned int i, unsigned int& j, unsigned int pos) const; 00037 00038 void operator= (real a); 00039 void operator= (const DenseMatrix& A); 00040 void operator= (const SparseMatrix& A); 00041 void operator+= (const DenseMatrix& A); 00042 void operator+= (const SparseMatrix& A); 00043 void operator-= (const DenseMatrix& A); 00044 void operator-= (const SparseMatrix& A); 00045 void operator*= (real a); 00046 00047 real norm() const; 00048 00049 real mult (const Vector& x, unsigned int i) const; 00050 void mult (const Vector& x, Vector& Ax) const; 00051 void multt (const Vector& x, Vector& Ax) const; 00052 void mult (const DenseMatrix& B, DenseMatrix& AB) const; 00053 real multrow (const Vector& x, unsigned int i) const; 00054 real multcol (const Vector& x, unsigned int j) const; 00055 00056 void resize(); 00057 void ident(unsigned int i); 00058 void lump(Vector& a) const; 00059 void addrow(); 00060 void addrow(const Vector& x); 00061 void initrow(unsigned int i, unsigned int rowsize); 00062 bool endrow(unsigned int i, unsigned int pos) const; 00063 void settransp(const DenseMatrix& A); 00064 void settransp(const SparseMatrix& A); 00065 real rowmax(unsigned int i) const; 00066 real colmax(unsigned int i) const; 00067 real rowmin(unsigned int i) const; 00068 real colmin(unsigned int i) const; 00069 real rowsum(unsigned int i) const; 00070 real colsum(unsigned int i) const; 00071 real rownorm(unsigned int i, unsigned int type) const; 00072 real colnorm(unsigned int i, unsigned int type) const; 00073 00074 void show() const; 00075 friend LogStream& operator<< (LogStream& stream, const DenseMatrix& A); 00076 00077 friend class SparseMatrix; 00078 00079 protected: 00080 00081 void alloc(unsigned int m, unsigned int n); 00082 00083 real read (unsigned int i, unsigned int j) const; 00084 void write (unsigned int i, unsigned int j, real value); 00085 void add (unsigned int i, unsigned int j, real value); 00086 void sub (unsigned int i, unsigned int j, real value); 00087 void mult (unsigned int i, unsigned int j, real value); 00088 void div (unsigned int i, unsigned int j, real value); 00089 00090 real** getvalues(); 00091 real** const getvalues() const; 00092 00093 void initperm(); 00094 void clearperm(); 00095 00096 unsigned int* getperm(); 00097 unsigned int* const getperm() const; 00098 00099 private: 00100 00101 real** values; 00102 00103 unsigned int* permutation; 00104 00105 }; 00106 00107 } 00108 00109 #endif
Documentation automatically generated with Doxygen on 10 Sep 2004.