From: Wolfgang Bangerth Date: Wed, 18 Mar 1998 16:15:14 +0000 (+0000) Subject: Restructuring and more error checks X-Git-Tag: v8.0.0~23167 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0333ea8fdb291a1542618c1e642b64ec7456bdaa;p=dealii.git Restructuring and more error checks git-svn-id: https://svn.dealii.org/trunk@84 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/dsmatrix.h b/deal.II/lac/include/lac/dsmatrix.h index d6c3ec9c60..74fd455190 100644 --- a/deal.II/lac/include/lac/dsmatrix.h +++ b/deal.II/lac/include/lac/dsmatrix.h @@ -1,5 +1,5 @@ /*---------------------------- dsmatrix.h ---------------------------*/ -/* */ +/* $Id$ */ #ifndef __dsmatrix_H #define __dsmatrix_H /*---------------------------- dsmatrix.h ---------------------------*/ @@ -10,9 +10,6 @@ // Roland Becker, Guido Kanschat, Franz-Theo Suttmeier -#ifndef __lac_dsmatrix_h -#define __lac_dsmatrix_h - #include #ifndef __lac_dvector_h #include diff --git a/deal.II/lac/include/lac/ivector.h b/deal.II/lac/include/lac/ivector.h index 39023fffd6..fb39a78523 100644 --- a/deal.II/lac/include/lac/ivector.h +++ b/deal.II/lac/include/lac/ivector.h @@ -90,6 +90,11 @@ protected: * on fast=0 vector is filled by 0. */ void reinit(const iVector& V, int fast = 0); + + /** + * Set all elements to zero. + */ + void clear (); /** * Inquire Dimension. returns Dimension , @@ -168,15 +173,21 @@ inline int iVector::n() const return dim; } + + inline int iVector::operator() (int i) const { Assert ((i>=0) || (i=0) || (i #include -dVector::dVector() : val(0) -{ - dim=maxdim=0; -} +dVector::dVector() : + dim(0), + maxdim(0), + val(0) +{} -dVector::dVector(int n) : val(0) + +dVector::dVector(int n) { Assert (n>0, ExcInvalidNumber(n)); @@ -22,11 +24,14 @@ dVector::dVector(int n) : val(0) { val = new double[maxdim]; Assert (val != 0, ExcOutOfMemory()); - (*this) = 0.; + clear (); } + else + val = 0; } -dVector::dVector(const dVector& v) : val(0) + +dVector::dVector(const dVector& v) { dim = v.n(); maxdim = v.n(); @@ -35,10 +40,15 @@ dVector::dVector(const dVector& v) : val(0) { val = new double[maxdim]; Assert (val != 0, ExcOutOfMemory()); - for (int i=0;i0, ExcInvalidNumber(n)); @@ -50,9 +60,12 @@ void dVector::reinit(int n, int fast) maxdim = n; } dim = n; - if (!fast) (*this) = 0.; + if (!fast) + clear (); } + + void dVector::reinit(const dVector& v, int fast) { int n = v.n(); @@ -68,6 +81,8 @@ void dVector::reinit(const dVector& v, int fast) clear (); } + + dVector::~dVector() { if (val) delete[] val; @@ -245,6 +260,7 @@ dVector& dVector::operator = (const dVector& v) } + void dVector::cadd(int i, const VectorBase& V, double s, int j) { const dVector& v = (const dVector&) V; @@ -255,6 +271,8 @@ void dVector::cadd(int i, const VectorBase& V, double s, int j) val[i] += s*v.val[j]; } + + void dVector::cadd(int i, const VectorBase& V, double s, int j, double t, int k) { const dVector& v = (const dVector&) V; @@ -282,12 +300,16 @@ void dVector::cadd(int i, const VectorBase& V, double s, int j, val[i] += s*v.val[j] + t*v.val[k] + q*v.val[l] + r*v.val[m]; } + + void dVector::czero(int i) { Assert ((i>=0) && (i0, ExcInvalidNumber(n)); @@ -45,9 +49,12 @@ void iVector::reinit(int n, int fast) maxdim = n; } dim = n; - if (!fast) (*this) = 0; + if (!fast) + clear (); } + + void iVector::reinit(const iVector& v, int fast) { int n = v.n(); @@ -59,45 +66,59 @@ void iVector::reinit(const iVector& v, int fast) maxdim = n; } dim = n; - if (!fast) (*this) = 0; + if (!fast) + clear (); } + + iVector::~iVector() { - delete[] val; + if (val) + delete[] val; +} + + + +void iVector::clear () { + for (int i=0; i