]> https://gitweb.dealii.org/ - dealii.git/commitdiff
allow unitialized ProductSparseMatrix
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Fri, 25 Nov 2005 10:39:42 +0000 (10:39 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Fri, 25 Nov 2005 10:39:42 +0000 (10:39 +0000)
git-svn-id: https://svn.dealii.org/trunk@11790 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 443cd07c264ede492a5aaf150c652f3bc0e8f4cc..4b6c2dbb2f287b78d30e081bee0b165c90b9c58b 100644 (file)
@@ -181,6 +181,22 @@ class ProductSparseMatrix : public PointerMatrixBase<Vector<vector_number> >
                        const MatrixType& m2,
                        VectorMemory<VectorType>& mem);
 
+                                    /**
+                                     * Constructor leaving an
+                                     * unitialized
+                                     * matrix. initialize() must be
+                                     * called, before the matrix can
+                                     * be used.
+                                     */
+    ProductSparseMatrix();
+    
+    void initialize(const MatrixType& m1,
+                   const MatrixType& m2,
+                   VectorMemory<VectorType>& mem);
+    
+                                    // Doc in PointerMatrixBase
+    void clear();
+    
                                     /**
                                      * Matrix-vector product <i>w =
                                      * m1 * m2 * v</i>.
index 0f4ee74df04ceded9aac4891c43dc8fb7a2539ec..57c1ebbaeba627256adeac8d586d8cf21ab45f9c 100644 (file)
@@ -35,10 +35,46 @@ ProductSparseMatrix<number, vnumber>::ProductSparseMatrix(
 }
 
 
+template<typename number, typename vnumber>
+ProductSparseMatrix<number, vnumber>::ProductSparseMatrix()
+               :
+               m1(0, typeid(*this).name()),
+               m2(0, typeid(*this).name()),
+               mem(0, typeid(*this).name())
+{}
+
+
+template<typename number, typename vnumber>
+void
+ProductSparseMatrix<number, vnumber>::initialize(
+  const MatrixType& mat1,
+  const MatrixType& mat2,
+  VectorMemory<VectorType>& memory)
+{
+  Assert(mat1.n() == mat2.m(), ExcDimensionMismatch(mat1.n(),mat2.m()));
+  mem = &memory;
+  m1 = &mat1;
+  m2 = &mat2;
+}
+
+
+template<typename number, typename vnumber>
+void
+ProductSparseMatrix<number, vnumber>::clear()
+{
+  m1 = 0;
+  m2 = 0;
+}
+
+
 template<typename number, typename vnumber>
 void
 ProductSparseMatrix<number, vnumber>::vmult (VectorType& dst, const VectorType& src) const
 {
+  Assert(mem != 0, ExcNotInitialized());
+  Assert(m1 != 0, ExcNotInitialized());
+  Assert(m2 != 0, ExcNotInitialized());
+  
   VectorType* v = mem->alloc();
   v->reinit(m1->n());
   m2->vmult (*v, src);
@@ -51,6 +87,10 @@ template<typename number, typename vnumber>
 void
 ProductSparseMatrix<number, vnumber>::vmult_add (VectorType& dst, const VectorType& src) const
 {
+  Assert(mem != 0, ExcNotInitialized());
+  Assert(m1 != 0, ExcNotInitialized());
+  Assert(m2 != 0, ExcNotInitialized());
+  
   VectorType* v = mem->alloc();
   v->reinit(m1->n());
   m2->vmult (*v, src);
@@ -63,6 +103,10 @@ template<typename number, typename vnumber>
 void
 ProductSparseMatrix<number, vnumber>::Tvmult (VectorType& dst, const VectorType& src) const
 {
+  Assert(mem != 0, ExcNotInitialized());
+  Assert(m1 != 0, ExcNotInitialized());
+  Assert(m2 != 0, ExcNotInitialized());
+  
   VectorType* v = mem->alloc();
   v->reinit(m1->n());
   m1->Tvmult (*v, src);
@@ -75,6 +119,10 @@ template<typename number, typename vnumber>
 void
 ProductSparseMatrix<number, vnumber>::Tvmult_add (VectorType& dst, const VectorType& src) const
 {
+  Assert(mem != 0, ExcNotInitialized());
+  Assert(m1 != 0, ExcNotInitialized());
+  Assert(m2 != 0, ExcNotInitialized());
+  
   VectorType* v = mem->alloc();
   v->reinit(m1->n());
   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.