]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Doc update and move some functions from the class declaration to the inline section...
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 25 May 1998 22:30:33 +0000 (22:30 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 25 May 1998 22:30:33 +0000 (22:30 +0000)
git-svn-id: https://svn.dealii.org/trunk@362 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 4a579bc3d6a89dce23714611bf86113c19c360f3..134be26e3004fdd8a415bb510d1ed45feb2dca21 100644 (file)
@@ -50,34 +50,35 @@ class dFMatrix
     void init (const unsigned int m, const unsigned int n);
     
                                     /**
-                                     *   Access Elements. returns A(i,j)
+                                     * Return a read-write reference to the
+                                     * element #(i,j)#.
+                                     *
+                                     * This function does no bounds checking.
                                      */
-    double& el (const unsigned int i, const unsigned int j)  {
-      return val[i*dim_range+j];
-    };
+    double& el (const unsigned int i, const unsigned int j);
     
                                     /**
-                                     *   Access Elements. returns A(i,j)
+                                     * Return the value of the element #(i,j)#.
+                                     *
+                                     * This function does no bounds checking.
                                      */
-    double el (const unsigned int i, const unsigned int j) const {
-      return val[i*dim_range+j];
-    };
+    double el (const unsigned int i, const unsigned int j) const;
     
     
   public:
                                     /**@name 1: Basic Object-handling */
                                     //@{
                                     /**
-                                     *       Constructor. Dimension = (n,n) <p>
-                                     *       ->   quadratic matrix (n rows , n columns)
+                                     * Constructor. Initialize the matrix as
+                                     * a square matrix with dimension #n#.
                                      */
-    dFMatrix (const unsigned int n = 1) { init(n,n); }
+    dFMatrix (const unsigned int n = 1);
     
                                     /**
-                                     *       Constructor. Dimension = (m,n) <p>
-                                     *       -> rectangular matrix (m rows , n columns)
+                                     * Constructor. Initialize the matrix as
+                                     * a rectangular #m# times #n# matrix.
                                      */
-    dFMatrix (const unsigned int m,unsigned int n) { init(m,n); }
+    dFMatrix (const unsigned int m, const unsigned int n);
     
                                     /** 
                                      * Copy constructor. Be very careful with
@@ -88,14 +89,16 @@ class dFMatrix
     dFMatrix (const dFMatrix&);
 
                                     /**
-                                     *        Destructor. Clears memory
+                                     * Destructor. Release all memory.
                                      */
     ~dFMatrix();
     
-                                     /**
+                                    /**
                                      * Comparison operator. Be careful with
                                      * this thing, it may eat up huge amounts
-                                     * of computing time!
+                                     * of computing time! It is most commonly
+                                     * used for internal consistency checks
+                                     * of programs.
                                      */
     bool operator == (const dFMatrix &) const;
 
@@ -123,24 +126,28 @@ class dFMatrix
                                      * Set dimension to (n,n) <p>
                                      * ( reinit quadratic matrix )
                                      */
-    void reinit (const unsigned int n) { reinit(n,n); }
+    void reinit (const unsigned int n);
     
                                     /**
                                      * Adjust  Dimension.
                                      * Set dimension to ( m(B),n(B) ) <p>
                                      * ( adjust to dimensions of another matrix B )
                                      */
-    void reinit (const dFMatrix& B) { reinit(B.m(), B.n()); }
+    void reinit (const dFMatrix &B);
     
                                     /**
-                                     *  Inquire Dimension (Row) . returns Number of Rows
+                                     * Return number of rows of this matrix.
+                                     * To remember: this matrix is an
+                                     * $m \times n$-matrix.
                                      */
-    unsigned int m() const { return dim_image; }
+    unsigned int m () const;
     
                                     /**
-                                     *  Inquire Dimension (Col) . returns Number of Columns
+                                     * Return number of columns of this matrix.
+                                     * To remember: this matrix is an
+                                     * $m \times n$-matrix.
                                      */
-    unsigned int n () const { return dim_range; }
+    unsigned int n () const;
 
                                     /**
                                      * Return whether the matrix contains only
@@ -162,28 +169,23 @@ class dFMatrix
                                      *   Access Elements. returns element at relative 'address' i <p>
                                      *   ( -> access to A(i/n , i mod n) )
                                      */
-    double el (const unsigned int i) const { return val[i]; }
+    double el (const unsigned int i) const;
     
                                     /**
-                                     *   Access Elements. returns A(i,j)
+                                     * Return the value of the element #(i,j)#.
+                                     * Does the same as the #el(i,j)# function
+                                     * but does bounds checking.
                                      */
-    double operator() (const unsigned int i, const unsigned int j) const
-      {
-       Assert (i<dim_image, ExcInvalidIndex (i, dim_image));
-       Assert (j<dim_range, ExcInvalidIndex (i, dim_range));
-       return el(i,j);
-      }
-
+    double operator() (const unsigned int i, const unsigned int j) const;
+    
                                     /**
-                                     *   Access Elements. returns A(i,j)
+                                     * Return a read-write reference to
+                                     * the element #(i,j)#.
+                                     * Does the same as the #el(i,j)# function
+                                     * but does bounds checking.
                                      */
-    double& operator() (const unsigned int i, const unsigned int j)
-      {
-       Assert (i<dim_image, ExcInvalidIndex (i, dim_image));
-       Assert (j<dim_range, ExcInvalidIndex (i, dim_range));
-       return el(i,j);
-      }
-
+    double& operator() (const unsigned int i, const unsigned int j);
+    
                                     /**
                                      * Set all entries in the matrix to
                                      * zero.
@@ -223,7 +225,7 @@ class dFMatrix
                                      *  w (+)= A*v.
                                      *  Matrix-vector-multiplication ; <p>
                                      *  ( application of this to a vector v )
-                                     *  flag adding=true : w=+A*v
+                                     *  flag adding=true : w+=A*v
                                      */
     void vmult (dVector& w, const dVector& v, const bool adding=false) const;
     
@@ -437,6 +439,64 @@ class dFMatrix
 
 
 
+
+/*-------------------------Inline functions -------------------------------*/
+
+
+inline
+double & dFMatrix::el (const unsigned int i, const unsigned int j)  {
+  return val[i*dim_range+j];
+};
+
+
+
+inline
+double dFMatrix::el (const unsigned int i, const unsigned int j) const {
+  return val[i*dim_range+j];
+};
+
+
+
+inline
+unsigned int dFMatrix::m() const {
+  return dim_image;
+};
+
+
+
+inline
+unsigned int dFMatrix::n() const {
+  return dim_range;
+};
+
+
+
+inline
+double dFMatrix::el (const unsigned int i) const {
+  return val[i];
+};
+
+
+
+inline
+double dFMatrix::operator() (const unsigned int i, const unsigned int j) const {  
+  Assert (i<dim_image, ExcInvalidIndex (i, dim_image));
+  Assert (j<dim_range, ExcInvalidIndex (i, dim_range));
+  return el(i,j);
+};
+
+
+
+inline
+double & dFMatrix::operator() (const unsigned int i, const unsigned int j) {
+  Assert (i<dim_image, ExcInvalidIndex (i, dim_image));
+  Assert (j<dim_range, ExcInvalidIndex (i, dim_range));
+  return el(i,j);
+}
+
+
+
+
 /*----------------------------   dfmatrix.h     ---------------------------*/
 /* end of #ifndef __dfmatrix_H */
 #endif
index c3034a894f5dc23b81ca440995944462321a305b..def3ec4c2ccf910694571b2cf8f5973ae4b6823c 100644 (file)
@@ -8,14 +8,31 @@
 
 
 
+dFMatrix::dFMatrix (const unsigned int n) {
+  init (n,n);
+};
+
+
+
+dFMatrix::dFMatrix (const unsigned int m, const unsigned int n) {
+  init (m,n);
+};
+
+
 
 dFMatrix::dFMatrix (const dFMatrix &m) 
 {
   init (m.dim_image, m.dim_range);
-  for (unsigned int i=0; i!=dim_image*dim_range; ++i)
-    val[i] = m.val[i];
+  double       *       p = &val[0];
+  const double *      vp = &m.val[0];
+  const double * const e = &val[dim_image*dim_range];
+
+  while (p!=e)
+    *p++ = *vp++;
 };
 
+
+
 void dFMatrix::init (const unsigned int mm, const unsigned int nn)
 {
   val_size = nn*mm;
@@ -23,12 +40,14 @@ void dFMatrix::init (const unsigned int mm, const unsigned int nn)
   dim_range = nn;
   dim_image = mm;
   clear ();
-}
+};
 
-dFMatrix::~dFMatrix ()
-{
+
+
+dFMatrix::~dFMatrix () {
   delete[] val;
-}
+};
+
 
 
 bool dFMatrix::all_zero () const {
@@ -59,6 +78,20 @@ void dFMatrix::reinit (const unsigned int mm, const unsigned int nn)
     }
 }
 
+
+
+void dFMatrix::reinit (const unsigned int n) {
+  reinit (n, n);
+};
+
+
+
+void dFMatrix::reinit (const dFMatrix &B) {
+  reinit (B.m(), B.n());
+};
+
+
+
 void dFMatrix::vmult (dVector& dst, const dVector& src,
                      const bool adding) const
 {
@@ -389,12 +422,16 @@ void dFMatrix::backward (dVector& dst, const dVector& src) const
     }
 }
 
-dFMatrix& dFMatrix::operator = (const dFMatrix& M)
-{
-  reinit(M);
-  unsigned int nn = n()*m();
-  for (unsigned int i=0; i<nn; ++i)
-    val[i] = M.val[i];
+dFMatrix& dFMatrix::operator = (const dFMatrix& m) {
+  reinit(m);
+
+  double *             p = &val[0];
+  const double *      vp = &m.val[0];
+  const double * const e = &val[dim_image*dim_range];
+
+  while (p!=e)
+    *p++ = *vp++;
+
   return *this;
 }
 

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.