]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Restructuring and more error checks
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 18 Mar 1998 16:00:56 +0000 (16:00 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 18 Mar 1998 16:00:56 +0000 (16:00 +0000)
git-svn-id: https://svn.dealii.org/trunk@83 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/dsmatrix.h
deal.II/lac/source/dsmatrix.cc

index 46b188952eceec49c15f7546ca52aff3d81e51e1..d6c3ec9c60cfec89e2e7fcb5e24d5835c5f687f4 100644 (file)
@@ -1,4 +1,9 @@
-// $Id$
+/*----------------------------   dsmatrix.h     ---------------------------*/
+/*      <Id:>                 */
+#ifndef __dsmatrix_H
+#define __dsmatrix_H
+/*----------------------------   dsmatrix.h     ---------------------------*/
+
 
 // This file is part of the DEAL Library
 // DEAL is Copyright(1995) by
@@ -41,24 +46,13 @@ class dSMatrixStruct
 public:
   //////////
   void reinit(int m, int n, int max_per_row);
-  //////////
-  dSMatrixStruct(int m, int n, int max_per_row) 
-    : max_dim(0), max_vec_len(0), rowstart(0), colnums(0)
-      {
-       reinit(m,n,max_per_row);
-      }
-  //////////
-  dSMatrixStruct(int n, int max_per_row)
-    : max_dim(0), max_vec_len(0), rowstart(0), colnums(0)
-      {
-       reinit(n,n,max_per_row);
-      }
-  //////////
-  ~dSMatrixStruct()
-    {
-      delete[] rowstart;
-      delete[] colnums;
-    }
+                                    //////////
+  dSMatrixStruct(int m, int n, int max_per_row);
+    
+                                    //////////
+  dSMatrixStruct(int n, int max_per_row);
+                                    //////////
+  ~dSMatrixStruct();
   //////////
   void compress();
   //////////
@@ -74,10 +68,10 @@ public:
   //////////
   void add_matrix(const iVector& rows, const iVector& cols);
 
-  void print_gnuplot (ostream &) const;
-  int n_rows () const {  return rows;   };
-  int n_cols () const {  return cols;   };
-  int bandwidth () const;
+    void print_gnuplot (ostream &) const;
+    int n_rows () const;
+    int n_cols () const;
+    int bandwidth () const;
 
     friend class ConstraintMatrix;
     friend class DoFHandler<1>;
@@ -108,8 +102,6 @@ public:
 
 
 
-
-
 /*
 CLASS
    dSMatrix
@@ -133,17 +125,11 @@ class dSMatrix
     dSMatrix ();
     
                                     //
-    dSMatrix(dSMatrixStruct& c)
-                   : cols(&c), val(0), max_len(0)
-      {
-       reinit();
-      }
+    dSMatrix(dSMatrixStruct& c);
+    
                                     //
-    ~dSMatrix()
-      {
-       delete[] val;
-      }
-
+    ~dSMatrix();
+    
 
                                     //
     void reinit();
@@ -151,23 +137,15 @@ class dSMatrix
     void reinit (dSMatrixStruct &);
 
                                     //
-    int m() const { return cols->rows; }
+    int m() const;
                                     //
-    int n() const { return cols->cols; }
+    int n() const;
 
                                     //
-    void set(int i,int j,double value) {
-      Assert (cols->operator()(i,j) != -1,
-             ExcInvalidIndex(i,j));
-      val[cols->operator()(i,j)] = value;
-    }
+    void set (int i, int j, double value);
                                     //
-    void add(int i,int j,double value) {
-      Assert (cols->operator()(i,j) != -1,
-             ExcInvalidIndex(i,j));
-      val[cols->operator()(i,j)]+= value;
-    }
-  
+    void add (int i, int j, double value);
+    
                                     //
     void vmult (dVector& dst,const dVector& src) const;
                                     //
@@ -217,4 +195,73 @@ class dSMatrix
 
   friend class ConstraintMatrix;
 };
+
+
+
+
+
+/*---------------------- Inline functions -----------------------------------*/
+
+inline
+int dSMatrixStruct::n_rows () const {
+  return rows;
+};
+
+
+
+inline
+int dSMatrixStruct::n_cols () const {
+  return cols;
+};
+
+
+
+
+
+inline
+int dSMatrix::m () const
+{
+  return cols->rows;
+};
+
+
+
+inline
+int dSMatrix::n () const
+{
+  return cols->cols;
+};
+
+
+
+inline
+void dSMatrix::set (int i, int j, double value) {
+  Assert (cols->operator()(i,j) != -1,
+         ExcInvalidIndex(i,j));
+  val[cols->operator()(i,j)] = value;
+};
+
+
+
+inline
+void dSMatrix::add (int i, int j, double value) {
+  Assert (cols->operator()(i,j) != -1,
+         ExcInvalidIndex(i,j));
+  val[cols->operator()(i,j)]+= value;
+};
+
+
+
+
+
+
+
+
+
+
+
+
+/*----------------------------   dsmatrix.h     ---------------------------*/
+/* end of #ifndef __dsmatrix_H */
 #endif
+/*----------------------------   dsmatrix.h     ---------------------------*/
index d70f3826b38ab0b9b38fa09a03fdc1dbff673b4c..b0d90fddd59c47ef7b1fb0f1d5e03fbacf9bc230 100644 (file)
@@ -115,6 +115,40 @@ inline void quicksort(long r, T* a)
 
 
 
+
+dSMatrixStruct::dSMatrixStruct(int m, int n, int max_per_row) 
+               : max_dim(0),
+                 max_vec_len(0),
+                 rowstart(0),
+                 colnums(0)
+{
+  reinit (m,n,max_per_row);
+};
+
+
+
+dSMatrixStruct::dSMatrixStruct(int n, int max_per_row)
+               : max_dim(0),
+                 max_vec_len(0),
+                 rowstart(0),
+                 colnums(0)
+{
+  reinit (n,n,max_per_row);
+};
+
+
+
+dSMatrixStruct::~dSMatrixStruct ()
+{
+  if (rowstart != 0)
+    delete[] rowstart;
+  if (colnums != 0)
+    delete[] colnums;
+}
+
+
+
+
 void
 dSMatrixStruct::reinit(int m, int n, int max_per_row)
 {
@@ -150,6 +184,7 @@ dSMatrixStruct::reinit(int m, int n, int max_per_row)
   compressed = 0;
 }
 
+
 void
 dSMatrixStruct::compress()
 {
@@ -191,6 +226,7 @@ dSMatrixStruct::compress()
   delete[] entries;
 }
 
+
 int
 dSMatrixStruct::operator () (int i, int j)
 {
@@ -199,6 +235,7 @@ dSMatrixStruct::operator () (int i, int j)
   return -1;
 }
 
+
 void
 dSMatrixStruct::add (int i, int j)
 {
@@ -224,6 +261,8 @@ dSMatrixStruct::add (int i, int j)
   Assert (false, ExcNotEnoughSpace(i));
 }
 
+
+
 void
 dSMatrixStruct::add_matrix(int n, int* rowcols)
 {
@@ -234,6 +273,7 @@ dSMatrixStruct::add_matrix(int n, int* rowcols)
 }
 
 
+
 void
 dSMatrixStruct::add_matrix(int m, int n, int* rows, int* cols)
 {
@@ -243,6 +283,8 @@ dSMatrixStruct::add_matrix(int m, int n, int* rows, int* cols)
       add(rows[i], cols[j]);
 }
 
+
+
 void
 dSMatrixStruct::add_matrix(const iVector& rowcols)
 {
@@ -253,6 +295,7 @@ dSMatrixStruct::add_matrix(const iVector& rowcols)
 }
 
 
+
 void
 dSMatrixStruct::add_matrix(const iVector& rows, const iVector& cols)
 {
@@ -263,6 +306,7 @@ dSMatrixStruct::add_matrix(const iVector& rows, const iVector& cols)
 }
 
 
+
 void
 dSMatrixStruct::print_gnuplot (ostream &out) const
 {
@@ -273,6 +317,7 @@ dSMatrixStruct::print_gnuplot (ostream &out) const
 }
 
 
+
 int
 dSMatrixStruct::bandwidth () const
 {
@@ -304,13 +349,29 @@ dSMatrix::dSMatrix () :
                max_len(0) {};
 
 
+
+dSMatrix::dSMatrix (dSMatrixStruct &c)
+               : cols(&c), val(0), max_len(0)
+{
+  reinit();
+};
+
+
+
+dSMatrix::~dSMatrix ()
+{
+  delete[] val;
+};
+
+
+
 void
 dSMatrix::reinit()
 {
   Assert (cols != 0, ExcMatrixNotInitialized());
   Assert (cols->compressed, ExcNotCompressed());
   
-  if(max_len<cols->vec_len)
+  if (max_len<cols->vec_len)
   {
     if (val) delete[] val;
     val = new double[cols->vec_len];
@@ -350,6 +411,7 @@ dSMatrix::vmult(dVector& dst,const dVector& src) const
     }
 }
 
+
 void
 dSMatrix::Tvmult(dVector& dst,const dVector& src) const
 {

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.