changeset 1756:1af643fa00e3

[project @ 1996-01-22 04:55:17 by jwe]
author jwe
date Mon, 22 Jan 1996 04:55:17 +0000
parents 3a9462b655f1
children 949303ac0fa1
files liboctave/Array.h liboctave/CmplxSCHUR.cc liboctave/CmplxSCHUR.h liboctave/dbleSCHUR.cc liboctave/dbleSCHUR.h
diffstat 5 files changed, 42 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/Array.h	Mon Jan 22 04:47:22 1996 +0000
+++ b/liboctave/Array.h	Mon Jan 22 04:55:17 1996 +0000
@@ -31,6 +31,7 @@
 #define HEAVYWEIGHT_INDEXING 1
 
 #include <cassert>
+#include <cstdlib>
 
 #include "lo-error.h"
 
@@ -86,6 +87,11 @@
     T& elem (int n) { return data[n]; }
 
     T elem (int n) const { return data[n]; }
+
+    void qsort (int (*compare) (const void *, const void *))
+      {
+	::qsort (data, len, sizeof (T), compare);
+      }
   };
 
 #ifdef HEAVYWEIGHT_INDEXING
@@ -182,6 +188,17 @@
 
   T *fortran_vec (void);
 
+  void qsort (int (*compare) (const void *, const void *))
+    {
+      if (rep->count > 1)
+	{
+	  --rep->count;
+	  rep = new ArrayRep (*rep);
+	}
+
+      rep->qsort (compare);
+    }
+
 #ifdef HEAVYWEIGHT_INDEXING
   void set_max_indices (int mi) { max_indices = mi; }
 
--- a/liboctave/CmplxSCHUR.cc	Mon Jan 22 04:47:22 1996 +0000
+++ b/liboctave/CmplxSCHUR.cc	Mon Jan 22 04:55:17 1996 +0000
@@ -58,7 +58,7 @@
 }
 
 int
-ComplexSCHUR::init (const ComplexMatrix& a, const char *ord)
+ComplexSCHUR::init (const ComplexMatrix& a, const string& ord)
 {
   int a_nr = a.rows ();
   int a_nc = a.cols ();
@@ -71,7 +71,10 @@
 
   char *jobvs = "V";
   char *sort;
-  if (*ord == 'A' || *ord == 'D' || *ord == 'a' || *ord == 'd')
+
+  char ord_char = ord.empty () ? 'U' : ord[0];
+
+  if (ord_char == 'A' || ord_char == 'D' || ord_char == 'a' || ord_char == 'd')
      sort = "S";
    else
      sort = "N";
@@ -90,7 +93,7 @@
   // bwork is not referenced for non-ordered Schur.
 
   int *bwork = 0;
-  if (*ord == 'A' || *ord == 'D' || *ord == 'a' || *ord == 'd')
+  if (ord_char == 'A' || ord_char == 'D' || ord_char == 'a' || ord_char == 'd')
     bwork = new int [n];
 
   Complex *s = dup (a.data (), a.length ());
@@ -99,14 +102,14 @@
   Complex *q = new Complex [n*n];
   Complex *w = new Complex [n];
 
-  if (*ord == 'A' || *ord == 'a')
+  if (ord_char == 'A' || ord_char == 'a')
     {
       F77_FCN (zgeesx, ZGEESX) (jobvs, sort, complex_select_ana,
 				sense, n, s, n, sdim, w, q, n, rconde,
 				rcondv, work, lwork, rwork, bwork,
 				info, 1L, 1L);
     }
-  else if (*ord == 'D' || *ord == 'd')
+  else if (ord_char == 'D' || ord_char == 'd')
     {
       F77_FCN (zgeesx, ZGEESX) (jobvs, sort, complex_select_dig,
 				sense, n, s, n, sdim, w, q, n, rconde,
--- a/liboctave/CmplxSCHUR.h	Mon Jan 22 04:47:22 1996 +0000
+++ b/liboctave/CmplxSCHUR.h	Mon Jan 22 04:55:17 1996 +0000
@@ -30,6 +30,8 @@
 
 class ostream;
 
+#include <string>
+
 #include "CMatrix.h"
 
 class ComplexSCHUR
@@ -40,12 +42,12 @@
 
   ComplexSCHUR (void) { }
 
-  ComplexSCHUR (const ComplexMatrix& a, const char *ord)
+  ComplexSCHUR (const ComplexMatrix& a, const string& ord)
     {
       init (a,ord);
     }
 
-  ComplexSCHUR (const ComplexMatrix& a, const char *ord, int& info)
+  ComplexSCHUR (const ComplexMatrix& a, const string& ord, int& info)
     {
       info = init (a,ord);
     }
@@ -78,7 +80,7 @@
 
 private:
 
-  int init (const ComplexMatrix& a, const char *ord);
+  int init (const ComplexMatrix& a, const string& ord);
 
   ComplexMatrix schur_mat;
   ComplexMatrix unitary_mat;
--- a/liboctave/dbleSCHUR.cc	Mon Jan 22 04:47:22 1996 +0000
+++ b/liboctave/dbleSCHUR.cc	Mon Jan 22 04:55:17 1996 +0000
@@ -60,7 +60,7 @@
 }
 
 int
-SCHUR::init (const Matrix& a, const char *ord)
+SCHUR::init (const Matrix& a, const string& ord)
 {
   int a_nr = a.rows ();
   int a_nc = a.cols ();
@@ -73,7 +73,9 @@
   char *jobvs = "V";
   char *sort;
 
-  if (*ord == 'A' || *ord == 'D' || *ord == 'a' || *ord == 'd')
+  char ord_char = ord.empty () ? 'U' : ord[0];
+
+  if (ord_char == 'A' || ord_char == 'D' || ord_char == 'a' || ord_char == 'd')
     sort = "S";
   else
     sort = "N";
@@ -99,20 +101,20 @@
 
   int *iwork = 0;
   int *bwork = 0;
-  if (*ord == 'A' || *ord == 'D' || *ord == 'a' || *ord == 'd')
+  if (ord_char == 'A' || ord_char == 'D' || ord_char == 'a' || ord_char == 'd')
     {
       iwork = new int [liwork];
       bwork = new int [n];
     }
 
-  if (*ord == 'A' || *ord == 'a')
+  if (ord_char == 'A' || ord_char == 'a')
     {
       F77_FCN (dgeesx, DGEESX) (jobvs, sort, select_ana, sense, n, s,
 				n, sdim, wr, wi, q, n, rconde, rcondv,
 				work, lwork, iwork, liwork, bwork,
 				info, 1L, 1L);
     }
-  else if (*ord == 'D' || *ord == 'd')
+  else if (ord_char == 'D' || ord_char == 'd')
     {
       F77_FCN (dgeesx, DGEESX) (jobvs, sort, select_dig, sense, n, s,
 				n, sdim, wr, wi, q, n, rconde, rcondv,
--- a/liboctave/dbleSCHUR.h	Mon Jan 22 04:47:22 1996 +0000
+++ b/liboctave/dbleSCHUR.h	Mon Jan 22 04:55:17 1996 +0000
@@ -30,6 +30,8 @@
 
 class ostream;
 
+#include <string>
+
 #include "dMatrix.h"
 
 class SCHUR
@@ -40,9 +42,9 @@
 
   SCHUR (void) { }
 
-  SCHUR (const Matrix& a, const char *ord) { init (a, ord); }
+  SCHUR (const Matrix& a, const string& ord) { init (a, ord); }
 
-  SCHUR (const Matrix& a, const char *ord, int& info)
+  SCHUR (const Matrix& a, const string& ord, int& info)
     {
       info = init (a, ord);
     }
@@ -69,7 +71,7 @@
 
 private:
 
-  int init (const Matrix& a, const char *ord);
+  int init (const Matrix& a, const string& ord);
 
   Matrix schur_mat;
   Matrix unitary_mat;