]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add standard constructor for ProductMatrix
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Fri, 18 Nov 2005 20:51:56 +0000 (20:51 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Fri, 18 Nov 2005 20:51:56 +0000 (20:51 +0000)
git-svn-id: https://svn.dealii.org/trunk@11771 0785d39b-7218-0410-832d-ea1e28bc413d

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

index d66b060557a2270c835f6b18fab7c2cde4ec6376..31ea9468be0d9f07b5eb3be0496ec511f400a917 100644 (file)
@@ -43,9 +43,17 @@ template<class VECTOR>
 class ProductMatrix : public PointerMatrixBase<VECTOR>
 {
   public:
+                                    /**
+                                     * Standard constructor. Matrices
+                                     * and the memory pool must be
+                                     * added later using
+                                     * initialize().
+                                     */
+    ProductMatrix();
+    
                                     /**
                                      * Constructor only assigning the
-                                     * memory pool. Matricesmust be
+                                     * memory pool. Matrices must be
                                      * added by reinit() later.
                                      */
     ProductMatrix(VectorMemory<VECTOR>& mem);
@@ -67,6 +75,13 @@ class ProductMatrix : public PointerMatrixBase<VECTOR>
     template <class MATRIX1, class MATRIX2>
     void reinit(const MATRIX1& m1, const MATRIX2& m2);
     
+                                    /**
+                                     * Change the matrices and memory pool.
+                                     */
+    template <class MATRIX1, class MATRIX2>
+    void initialize(const MATRIX1& m1, const MATRIX2& m2,
+                   VectorMemory<VECTOR>& mem);
+    
                                     /**
                                      * Destructor.
                                      */
@@ -401,6 +416,12 @@ class InverseMatrixRichardson
 /*@}*/
 //---------------------------------------------------------------------------
 
+template<class VECTOR>
+ProductMatrix<VECTOR>::ProductMatrix ()
+  : m1(0), m2(0), mem(0, typeid(*this).name())
+{}
+
+
 template<class VECTOR>
 ProductMatrix<VECTOR>::ProductMatrix (VectorMemory<VECTOR>& m)
   : m1(0), m2(0), mem(&m, typeid(*this).name())
@@ -434,6 +455,22 @@ ProductMatrix<VECTOR>::reinit (
 }
 
 
+template<class VECTOR>
+template<class MATRIX1, class MATRIX2>
+void
+ProductMatrix<VECTOR>::initialize (
+  const MATRIX1& mat1,
+  const MATRIX2& mat2,
+  VectorMemory<VECTOR>& memory)
+{
+  mem = &memory;
+  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());
+}
+
+
 template<class VECTOR>
 ProductMatrix<VECTOR>::~ProductMatrix ()
 {
@@ -446,6 +483,7 @@ template<class VECTOR>
 void
 ProductMatrix<VECTOR>::vmult (VECTOR& dst, const VECTOR& src) const
 {
+  Assert (mem != 0, ExcNotInitialized());
   Assert (m1 != 0, ExcNotInitialized());
   Assert (m2 != 0, ExcNotInitialized());
   
@@ -461,6 +499,7 @@ template<class VECTOR>
 void
 ProductMatrix<VECTOR>::vmult_add (VECTOR& dst, const VECTOR& src) const
 {
+  Assert (mem != 0, ExcNotInitialized());
   Assert (m1 != 0, ExcNotInitialized());
   Assert (m2 != 0, ExcNotInitialized());
   
@@ -476,6 +515,7 @@ template<class VECTOR>
 void
 ProductMatrix<VECTOR>::Tvmult (VECTOR& dst, const VECTOR& src) const
 {
+  Assert (mem != 0, ExcNotInitialized());
   Assert (m1 != 0, ExcNotInitialized());
   Assert (m2 != 0, ExcNotInitialized());
   
@@ -491,6 +531,7 @@ template<class VECTOR>
 void
 ProductMatrix<VECTOR>::Tvmult_add (VECTOR& dst, const VECTOR& src) const
 {
+  Assert (mem != 0, ExcNotInitialized());
   Assert (m1 != 0, ExcNotInitialized());
   Assert (m2 != 0, ExcNotInitialized());
   

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.