From 4bc6f3d2488e721f25e27022611464e139391bb5 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 10 Mar 1998 11:55:30 +0000 Subject: [PATCH] Add empty constructor to dsmatrix and some guards. git-svn-id: https://svn.dealii.org/trunk@52 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/dsmatrix.h | 33 +++++++++++++++++++--- deal.II/lac/source/dsmatrix.cc | 44 ++++++++++++++++++++++++------ 2 files changed, 64 insertions(+), 13 deletions(-) diff --git a/deal.II/lac/include/lac/dsmatrix.h b/deal.II/lac/include/lac/dsmatrix.h index 60db825da9..763ceac0aa 100644 --- a/deal.II/lac/include/lac/dsmatrix.h +++ b/deal.II/lac/include/lac/dsmatrix.h @@ -114,10 +114,18 @@ class dSMatrix double* val; int max_len; public: - // - void reinit(); - // - void reinit (dSMatrixStruct &); + + /** + * Constructor; initializes the matrix to be + * empty, without any structure, i.e. the + * matrix is not usable at all. This constructor + * is therefore only useful for matrices which + * are members of a class. You have to initialize + * the matrix before usage with + * #reinit(dSMatrixStruct)#. + */ + dSMatrix (); + // dSMatrix(dSMatrixStruct& c) : cols(&c), val(0), max_len(0) @@ -130,6 +138,12 @@ class dSMatrix delete[] val; } + + // + void reinit(); + // + void reinit (dSMatrixStruct &); + // int m() const { return cols->rows; } // @@ -166,5 +180,16 @@ class dSMatrix * Exception */ DeclException0 (ExcNotCompressed); + /** + * Exception + */ + DeclException0 (ExcMatrixNotInitialized); + /** + * Exception + */ + DeclException2 (ExcDimensionsDontMatch, + int, int, + << "The dimensions " << arg1 << " and " << arg2 + << " do not match properly."); }; #endif diff --git a/deal.II/lac/source/dsmatrix.cc b/deal.II/lac/source/dsmatrix.cc index d2e344f3f3..1124ea772e 100644 --- a/deal.II/lac/source/dsmatrix.cc +++ b/deal.II/lac/source/dsmatrix.cc @@ -111,7 +111,7 @@ inline void quicksort(long r, T* a) } -/*----------------- from sort.h -------------------------*/ +/*----------------- end: from sort.h -------------------------*/ @@ -286,9 +286,21 @@ dSMatrixStruct::bandwidth () const + + +/*-------------------------------------------------------------------------*/ + + +dSMatrix::dSMatrix () : + cols(0), + val(0), + max_len(0) {}; + + void dSMatrix::reinit() { + Assert (cols != 0, ExcMatrixNotInitialized()); Assert (cols->compressed, ExcNotCompressed()); if(max_lenvec_len) @@ -315,8 +327,9 @@ dSMatrix::reinit (dSMatrixStruct &sparsity) { void dSMatrix::vmult(dVector& dst,const dVector& src) { - // Assert(m() = dst.n()) - // Assert(n() = src.n()) + Assert (cols != 0, ExcMatrixNotInitialized()); + Assert(m() == dst.n(), ExcDimensionsDontMatch(m(),dst.n())); + Assert(n() == src.n(), ExcDimensionsDontMatch(n(),src.n())); for (int i=0;irows; ++i) for (int j=cols->rowstart[i]; jrowstart[i+1]; ++j) out << "(" << i << "," << cols->colnums[j] << ") " << val[j] << endl; -- 2.39.5