]> https://gitweb.dealii.org/ - dealii.git/commitdiff
allow uninitialized product
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Thu, 17 Nov 2005 09:33:59 +0000 (09:33 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Thu, 17 Nov 2005 09:33:59 +0000 (09:33 +0000)
git-svn-id: https://svn.dealii.org/trunk@11770 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/matrix_lib.h

index a3da23c287652f6b634b80f8d27812a8b1cff788..d66b060557a2270c835f6b18fab7c2cde4ec6376 100644 (file)
@@ -43,6 +43,13 @@ template<class VECTOR>
 class ProductMatrix : public PointerMatrixBase<VECTOR>
 {
   public:
+                                    /**
+                                     * Constructor only assigning the
+                                     * memory pool. Matricesmust be
+                                     * added by reinit() later.
+                                     */
+    ProductMatrix(VectorMemory<VECTOR>& mem);
+    
                                     /**
                                      * Constructor.  Additionally to
                                      * the two constituting matrices, a
@@ -394,6 +401,12 @@ class InverseMatrixRichardson
 /*@}*/
 //---------------------------------------------------------------------------
 
+template<class VECTOR>
+ProductMatrix<VECTOR>::ProductMatrix (VectorMemory<VECTOR>& m)
+  : m1(0), m2(0), mem(&m, typeid(*this).name())
+{}
+
+
 template<class VECTOR>
 template<class MATRIX1, class MATRIX2>
 ProductMatrix<VECTOR>::ProductMatrix (
@@ -414,8 +427,8 @@ ProductMatrix<VECTOR>::reinit (
   const MATRIX1& mat1,
   const MATRIX2& mat2)
 {
-  delete m1;
-  delete m2;
+  if (m1) delete m1;
+  if (m2) delete m2;
   m1 = new PointerMatrix<MATRIX1, VECTOR>(&mat1, typeid(*this).name());
   m2 = new PointerMatrix<MATRIX2, VECTOR>(&mat2, typeid(*this).name());
 }
@@ -424,8 +437,8 @@ ProductMatrix<VECTOR>::reinit (
 template<class VECTOR>
 ProductMatrix<VECTOR>::~ProductMatrix ()
 {
-  delete m1;
-  delete m2;
+  if (m1) delete m1;
+  if (m2) delete m2;
 }
 
 
@@ -433,6 +446,9 @@ template<class VECTOR>
 void
 ProductMatrix<VECTOR>::vmult (VECTOR& dst, const VECTOR& src) const
 {
+  Assert (m1 != 0, ExcNotInitialized());
+  Assert (m2 != 0, ExcNotInitialized());
+  
   VECTOR* v = mem->alloc();
   v->reinit(dst);
   m2->vmult (*v, src);
@@ -445,6 +461,9 @@ template<class VECTOR>
 void
 ProductMatrix<VECTOR>::vmult_add (VECTOR& dst, const VECTOR& src) const
 {
+  Assert (m1 != 0, ExcNotInitialized());
+  Assert (m2 != 0, ExcNotInitialized());
+  
   VECTOR* v = mem->alloc();
   v->reinit(dst);
   m2->vmult (*v, src);
@@ -457,6 +476,9 @@ template<class VECTOR>
 void
 ProductMatrix<VECTOR>::Tvmult (VECTOR& dst, const VECTOR& src) const
 {
+  Assert (m1 != 0, ExcNotInitialized());
+  Assert (m2 != 0, ExcNotInitialized());
+  
   VECTOR* v = mem->alloc();
   v->reinit(dst);
   m1->Tvmult (*v, src);
@@ -469,6 +491,9 @@ template<class VECTOR>
 void
 ProductMatrix<VECTOR>::Tvmult_add (VECTOR& dst, const VECTOR& src) const
 {
+  Assert (m1 != 0, ExcNotInitialized());
+  Assert (m2 != 0, ExcNotInitialized());
+  
   VECTOR* v = mem->alloc();
   v->reinit(dst);
   m1->Tvmult (*v, src);

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.