From 2d750caffad7bff126090663dfc24a241beb1083 Mon Sep 17 00:00:00 2001
From: Eric Bechet <eric.bechet@ulg.ac.be>
Date: Thu, 10 Dec 2009 10:32:46 +0000
Subject: [PATCH] added resize function to fullMatrix

---
 Numeric/fullMatrix.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/Numeric/fullMatrix.h b/Numeric/fullMatrix.h
index da87ddb23f..94fd3c8f07 100644
--- a/Numeric/fullMatrix.h
+++ b/Numeric/fullMatrix.h
@@ -173,6 +173,20 @@ class fullMatrix
   }
   fullMatrix() : _own_data(false),_r(0), _c(0), _data(0) {}
   ~fullMatrix() { if(_data && _own_data) delete [] _data; }
+
+  bool resize(int r, int c) // data will be owned (same as constructor)
+  {
+    if ((r!=_r||c!=_c)||(!_own_data))
+    {
+      _r=r;_c=c;
+      if ((_own_data)&&(_data)) delete[] _data;
+      _data = new scalar[_r * _c];
+      _own_data = true;
+      return true;
+    }
+    return false; // no reallocation
+  }
+
   void setAsProxy(fullMatrix<scalar> &original, int c_start, int c) {
     if(_data && _own_data)
       delete [] _data;
-- 
GitLab