From a5e9a8ab998fb3437c42df15c3014a9667399d53 Mon Sep 17 00:00:00 2001
From: Jonathan Lambrechts <jonathan.lambrechts@uclouvain.be>
Date: Wed, 8 Sep 2010 15:29:42 +0000
Subject: [PATCH] linearSystemCSR : accept zeroMatrix/zeroRHS even if
 matrix/rhs not yet allocated

---
 Solver/linearSystemCSR.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Solver/linearSystemCSR.h b/Solver/linearSystemCSR.h
index a6ff91c600..9309816813 100644
--- a/Solver/linearSystemCSR.h
+++ b/Solver/linearSystemCSR.h
@@ -35,7 +35,7 @@ class linearSystemCSR : public linearSystem<scalar> {
   std::vector<scalar> *_b, *_x;
  public:
   linearSystemCSR()
-    : sorted(false), _a(0) {}
+    : sorted(false), _a(0), _b(0), _x(0) {}
   virtual bool isAllocated() const { return _a != 0; }
   virtual void allocate(int) ;
   virtual void clear()
@@ -105,12 +105,14 @@ class linearSystemCSR : public linearSystem<scalar> {
   }
   virtual void zeroMatrix()
   {
+    if (!_a) return;
     int N = CSRList_Nbr(_a);
     scalar *a = (scalar*) _a->array;
     for (int i = 0; i < N; i++) a[i] = 0;
   }
   virtual void zeroRightHandSide()
   {
+    if (!_b) return;
     for(unsigned int i = 0; i < _b->size(); i++) (*_b)[i] = 0.;
   }
   virtual double normInfRightHandSide() const
-- 
GitLab