From 0c78fe56a70f51de21479f31c21a188e09d220e9 Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Mon, 28 Apr 2014 07:14:13 +0000 Subject: [PATCH] matrix --- libsrc/linalg/densemat.hpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/libsrc/linalg/densemat.hpp b/libsrc/linalg/densemat.hpp index 5d721b5a..28ca59ba 100644 --- a/libsrc/linalg/densemat.hpp +++ b/libsrc/linalg/densemat.hpp @@ -158,25 +158,29 @@ class MatrixFixWidth protected: int height; double * data; - + bool ownmem; public: /// MatrixFixWidth () - { height = 0; data = 0; } + { height = 0; data = 0; ownmem = false; } /// MatrixFixWidth (int h) - { height = h; data = new double[WIDTH*height]; } + { height = h; data = new double[WIDTH*height]; ownmem = true; } + /// + MatrixFixWidth (int h, double * adata) + { height = h; data = adata; ownmem = false; } /// ~MatrixFixWidth () - { delete [] data; } + { if (ownmem) delete [] data; } void SetSize (int h) { if (h != height) { - delete data; + if (ownmem) delete data; height = h; data = new double[WIDTH*height]; + ownmem = true; } }