changeset 1926:3ce2c289c978

[project @ 1996-02-11 21:25:35 by jwe]
author jwe
date Sun, 11 Feb 1996 21:25:35 +0000
parents f69f71d23771
children e379c781ae7e
files liboctave/CmplxLU.cc liboctave/CmplxLU.h liboctave/dbleLU.cc liboctave/dbleLU.h
diffstat 4 files changed, 30 insertions(+), 56 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/CmplxLU.cc	Sun Feb 11 20:42:45 1996 +0000
+++ b/liboctave/CmplxLU.cc	Sun Feb 11 21:25:35 1996 +0000
@@ -43,9 +43,6 @@
 
 ComplexLU::ComplexLU (const ComplexMatrix& a)
 {
-  ipvt = 0;
-  pvt = 0;
-
   int a_nr = a.rows ();
   int a_nc = a.cols ();
 
@@ -57,8 +54,9 @@
 
   int n = a_nr;
 
-  ipvt = new int [n];
-  pvt = new int [n];
+  Array<int> ipvt (n);
+
+  int *pipvt = ipvt.fortran_vec ();
 
   ComplexMatrix A_fact = a;
   Complex *tmp_data = A_fact.fortran_vec ();
@@ -66,26 +64,29 @@
   int info = 0;
   Complex *dummy = 0;
 
-  F77_XFCN (zgesv, ZGESV, (n, 0, tmp_data, n, ipvt, dummy, n, info));
+  F77_XFCN (zgesv, ZGESV, (n, 0, tmp_data, n, pipvt, dummy, n, info));
 
   if (f77_exception_encountered)
     (*current_liboctave_error_handler) ("unrecoverable error in zgesv");
   else
     {
+      Array<int> pvt (n);
+
       for (int i = 0; i < n; i++)
 	{
-	  ipvt[i] -= 1;
-	  pvt[i] = i;
+	  ipvt.elem (i) -= 1;
+	  pvt.elem (i) = i;
 	}
 
       for (int i = 0; i < n - 1; i++)
 	{
-	  int k = ipvt[i];
+	  int k = ipvt.elem (i);
+
 	  if (k != i)
 	    {
-	      int tmp = pvt[k];
-	      pvt[k] = pvt[i];
-	      pvt[i] = tmp;
+	      int tmp = pvt.elem (k);
+	      pvt.elem (k) = pvt.elem (i);
+	      pvt.elem (i)= tmp;
 	    }
 	}
 
@@ -95,7 +96,7 @@
 
       for (int i = 0; i < n; i++)
 	{
-	  p.elem (i, pvt[i]) = 1.0;
+	  p.elem (i, pvt.elem (i)) = 1.0;
 
 	  l.elem (i, i) = 1.0;
 	  for (int j = 0; j < i; j++)
@@ -105,12 +106,6 @@
 	    u.elem (i, j) = A_fact.elem (i, j);
 	}
     }
-
-  delete [] ipvt;
-  ipvt = 0;
-
-  delete [] pvt;
-  pvt = 0;
 }
 
 /*
--- a/liboctave/CmplxLU.h	Sun Feb 11 20:42:45 1996 +0000
+++ b/liboctave/CmplxLU.h	Sun Feb 11 21:25:35 1996 +0000
@@ -38,7 +38,7 @@
 {
 public:
 
-  ComplexLU (void) : l (), u (), p (), ipvt (0), pvt (0) { }
+  ComplexLU (void) : l (), u (), p () { }
 
   ComplexLU (const ComplexMatrix& a);
 
@@ -55,11 +55,7 @@
       return *this;
     }
 
-  ~ComplexLU (void)
-    {
-      delete [] ipvt;
-      delete [] pvt;
-    }
+  ~ComplexLU (void) { }
 
   ComplexMatrix L (void) const { return l; }
   ComplexMatrix U (void) const { return u; }
@@ -73,9 +69,6 @@
   ComplexMatrix l;
   ComplexMatrix u;
   Matrix p;
-
-  int *ipvt;
-  int *pvt;
 };
 
 #endif
--- a/liboctave/dbleLU.cc	Sun Feb 11 20:42:45 1996 +0000
+++ b/liboctave/dbleLU.cc	Sun Feb 11 21:25:35 1996 +0000
@@ -43,9 +43,6 @@
 
 LU::LU (const Matrix& a)
 {
-  ipvt = 0;
-  pvt = 0;
-
   int a_nr = a.rows ();
   int a_nc = a.cols ();
 
@@ -57,8 +54,8 @@
 
   int n = a_nr;
 
-  ipvt = new int [n];
-  pvt = new int [n];
+  Array<int> ipvt (n);
+  int *pipvt = ipvt.fortran_vec ();
 
   Matrix A_fact = a;
   double *tmp_data = A_fact.fortran_vec ();
@@ -66,26 +63,28 @@
   int info = 0;
   double dummy = 0;
 
-  F77_XFCN (dgesv, DGESV, (n, 0, tmp_data, n, ipvt, dummy, n, info));
+  F77_XFCN (dgesv, DGESV, (n, 0, tmp_data, n, pipvt, dummy, n, info));
 
   if (f77_exception_encountered)
     (*current_liboctave_error_handler) ("unrecoverable error in dgesv");
   else
     {
+      Array<int> pvt (n);
+
       for (int i = 0; i < n; i++)
 	{
-	  ipvt[i] -= 1;
-	  pvt[i] = i;
+	  ipvt.elem (i) -= 1;
+	  pvt.elem (i) = i;
 	}
 
       for (int i = 0; i < n - 1; i++)
 	{
-	  int k = ipvt[i];
+	  int k = ipvt.elem (i);
 	  if (k != i)
 	    {
-	      int tmp = pvt[k];
-	      pvt[k] = pvt[i];
-	      pvt[i] = tmp;
+	      int tmp = pvt.elem (k);
+	      pvt.elem (k) = pvt.elem (i);
+	      pvt.elem (i) = tmp;
 	    }
 	}
 
@@ -95,7 +94,7 @@
 
       for (int i = 0; i < n; i++)
 	{
-	  p.elem (i, pvt[i]) = 1.0;
+	  p.elem (i, pvt.elem (i)) = 1.0;
 
 	  l.elem (i, i) = 1.0;
 	  for (int j = 0; j < i; j++)
@@ -105,12 +104,6 @@
 	    u.elem (i, j) = A_fact.elem (i, j);
 	}
     }
-
-  delete [] ipvt;
-  ipvt = 0;
-
-  delete [] pvt;
-  pvt = 0;
 }
 
 /*
--- a/liboctave/dbleLU.h	Sun Feb 11 20:42:45 1996 +0000
+++ b/liboctave/dbleLU.h	Sun Feb 11 21:25:35 1996 +0000
@@ -36,7 +36,7 @@
 {
 public:
 
-  LU (void) : l (), u (), p (), ipvt (0), pvt (0) { }
+  LU (void) : l (), u (), p () { }
 
   LU (const Matrix& a);
 
@@ -53,11 +53,7 @@
       return *this;
     }
 
-  ~LU (void)
-    {
-      delete [] ipvt;
-      delete [] pvt;
-    }
+  ~LU (void) { }
 
   Matrix L (void) const { return l; }
 
@@ -72,9 +68,6 @@
   Matrix l;
   Matrix u;
   Matrix p;
-
-  int *ipvt;
-  int *pvt;
 };
 
 #endif