changeset 1730:a744f4d0ba59

[project @ 1996-01-09 12:16:29 by jwe]
author jwe
date Tue, 09 Jan 1996 12:18:45 +0000
parents 227706b05144
children c43d042f20be
files liboctave/CmplxAEPBAL.cc liboctave/CmplxAEPBAL.h liboctave/dbleAEPBAL.cc liboctave/dbleAEPBAL.h liboctave/dbleGEPBAL.cc liboctave/dbleGEPBAL.h src/balance.cc
diffstat 7 files changed, 48 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/CmplxAEPBAL.cc	Tue Jan 09 12:00:58 1996 +0000
+++ b/liboctave/CmplxAEPBAL.cc	Tue Jan 09 12:18:45 1996 +0000
@@ -29,6 +29,8 @@
 #include <config.h>
 #endif
 
+#include <string>
+
 #include "CmplxAEPBAL.h"
 #include "dMatrix.h"
 #include "f77-uscore.h"
@@ -46,10 +48,17 @@
 }
 
 int
-ComplexAEPBALANCE::init (const ComplexMatrix& a, const char *balance_job)
+ComplexAEPBALANCE::init (const ComplexMatrix& a, const string& balance_job)
 {
+  int a_nc = a.cols ();
 
-  int n = a.cols ();
+  if (a.rows () != a_nc)
+    {
+      (*current_liboctave_error_handler) ("AEPBALANCE requires square matrix");
+      return -1;
+    }
+
+  int n = a_nc;
 
   // Parameters for balance call.
 
@@ -62,7 +71,9 @@
 
   balanced_mat = a;
 
-  F77_FCN (zgebal, ZGEBAL) (balance_job, n,
+  char bal_job = balance_job[0];
+
+  F77_FCN (zgebal, ZGEBAL) (&bal_job, n,
 			    balanced_mat.fortran_vec (), n, ilo, ihi,
 			    scale, info, 1L, 1L);
 
@@ -72,7 +83,7 @@
   for (int i = 0; i < n; i++)
     balancing_mat (i, i) = 1.0;
 
-  F77_FCN (zgebak, ZGEBAK) (balance_job, "R", n, ilo, ihi, scale, n, 
+  F77_FCN (zgebak, ZGEBAK) (&bal_job, "R", n, ilo, ihi, scale, n, 
 			    balancing_mat.fortran_vec (), n, info, 1L,
 			    1L);
 
--- a/liboctave/CmplxAEPBAL.h	Tue Jan 09 12:00:58 1996 +0000
+++ b/liboctave/CmplxAEPBAL.h	Tue Jan 09 12:18:45 1996 +0000
@@ -30,6 +30,8 @@
 
 class ostream;
 
+#include <string>
+
 #include "CMatrix.h"
 
 class ComplexAEPBALANCE
@@ -40,7 +42,7 @@
 
   ComplexAEPBALANCE (void) { }
 
-  ComplexAEPBALANCE (const ComplexMatrix& a, const char * balance_job)
+  ComplexAEPBALANCE (const ComplexMatrix& a, const string& balance_job)
     {
       init (a, balance_job); 
     }
@@ -67,7 +69,7 @@
 
 private:
 
-  int init (const ComplexMatrix& a, const char * balance_job);
+  int init (const ComplexMatrix& a, const string& balance_job);
 
   ComplexMatrix balanced_mat;
   ComplexMatrix balancing_mat;
--- a/liboctave/dbleAEPBAL.cc	Tue Jan 09 12:00:58 1996 +0000
+++ b/liboctave/dbleAEPBAL.cc	Tue Jan 09 12:18:45 1996 +0000
@@ -29,6 +29,8 @@
 #include <config.h>
 #endif
 
+#include <string>
+
 #include "dbleAEPBAL.h"
 #include "f77-uscore.h"
 
@@ -45,9 +47,10 @@
 }
 
 int
-AEPBALANCE::init (const Matrix& a, const char *balance_job)
+AEPBALANCE::init (const Matrix& a, const string& balance_job)
 {
   int a_nc = a.cols ();
+
   if (a.rows () != a_nc)
     {
       (*current_liboctave_error_handler) ("AEPBALANCE requires square matrix");
@@ -67,7 +70,9 @@
 
   balanced_mat = a;
 
-  F77_FCN (dgebal, DGEBAL) (balance_job, n,
+  char bal_job = balance_job[0];
+
+  F77_FCN (dgebal, DGEBAL) (&bal_job, n,
 			    balanced_mat.fortran_vec (), n, ilo, ihi,
 			    scale, info, 1L, 1L);
 
@@ -77,7 +82,7 @@
   for (int i = 0; i < n; i++)
     balancing_mat.elem (i ,i) = 1.0;
 
-  F77_FCN (dgebak, DGEBAK) (balance_job, "R", n, ilo, ihi, scale, n,
+  F77_FCN (dgebak, DGEBAK) (&bal_job, "R", n, ilo, ihi, scale, n,
 			    balancing_mat.fortran_vec (), n, info, 1L,
 			    1L);
 
--- a/liboctave/dbleAEPBAL.h	Tue Jan 09 12:00:58 1996 +0000
+++ b/liboctave/dbleAEPBAL.h	Tue Jan 09 12:18:45 1996 +0000
@@ -30,6 +30,8 @@
 
 class ostream;
 
+#include <string>
+
 #include "dMatrix.h"
 
 class AEPBALANCE
@@ -40,7 +42,7 @@
 
   AEPBALANCE (void) { }
 
-  AEPBALANCE (const Matrix& a,const char * balance_job)
+  AEPBALANCE (const Matrix& a,const string& balance_job)
     {
       init (a, balance_job); 
     }
@@ -67,7 +69,7 @@
 
 private:
 
-  int init (const Matrix& a, const char * balance_job);
+  int init (const Matrix& a, const string& balance_job);
 
   Matrix balanced_mat;
   Matrix balancing_mat;
--- a/liboctave/dbleGEPBAL.cc	Tue Jan 09 12:00:58 1996 +0000
+++ b/liboctave/dbleGEPBAL.cc	Tue Jan 09 12:18:45 1996 +0000
@@ -31,6 +31,8 @@
 
 #include <cmath>
 
+#include <string>
+
 #include "dbleGEPBAL.h"
 #include "f77-uscore.h"
 
@@ -56,11 +58,12 @@
 }
 
 int
-GEPBALANCE::init (const Matrix& a, const Matrix& b, const char *balance_job)
+GEPBALANCE::init (const Matrix& a, const Matrix& b, const string& balance_job)
 {
   int a_nr = a.rows ();
   int a_nc = a.cols ();
   int b_nr = b.rows ();
+
   if (a_nr != a_nc || a_nr != b_nr || b_nr != b.cols ())
     {
       (*current_liboctave_error_handler)
@@ -109,7 +112,9 @@
 
   // Check for permutation option.
 
-  if (*balance_job == 'P' || *balance_job == 'B')
+  char bal_job = balance_job[0];
+
+  if (bal_job == 'P' || bal_job == 'B')
     {
       F77_FCN (reduce, REDUCE) (n, n, balanced_a_mat.fortran_vec (),
 				n, balanced_b_mat.fortran_vec (), ilo,
@@ -125,7 +130,7 @@
 
   // Check for scaling option.
 
-  if ((*balance_job == 'S' || *balance_job == 'B') && ilo != ihi)
+  if ((bal_job == 'S' || bal_job == 'B') && ilo != ihi)
     {
       F77_FCN (scaleg, SCALEG) (n, n, balanced_a_mat.fortran_vec (), 
 				n, balanced_b_mat.fortran_vec (), ilo,
@@ -152,13 +157,13 @@
 
   // Column permutations/scaling.
 
-  F77_FCN (dgebak, DGEBAK) (balance_job, "R", n, ilo, ihi, cscale, n, 
+  F77_FCN (dgebak, DGEBAK) (&bal_job, "R", n, ilo, ihi, cscale, n, 
 			    right_balancing_mat.fortran_vec (), n,
 			    info, 1L, 1L);
     
   // Row permutations/scaling.
 
-  F77_FCN (dgebak, DGEBAK) (balance_job, "L", n, ilo, ihi,
+  F77_FCN (dgebak, DGEBAK) (&bal_job, "L", n, ilo, ihi,
 			    wk.fortran_vec (), n,
 			    left_balancing_mat.fortran_vec (), n,
 			    info, 1L, 1L);
@@ -168,7 +173,7 @@
   // here they are.
 
 #if 0
-  if ((*balance_job == 'P' || *balance_job == 'B') && ilo != ihi)
+  if ((bal_job == 'P' || bal_job == 'B') && ilo != ihi)
     {
       F77_FCN (gradeq, GRADEQ) (n, n, balanced_a_mat.fortran_vec (),
 				n, balanced_b_mat.fortran_vec (), ilo,
--- a/liboctave/dbleGEPBAL.h	Tue Jan 09 12:00:58 1996 +0000
+++ b/liboctave/dbleGEPBAL.h	Tue Jan 09 12:18:45 1996 +0000
@@ -30,6 +30,8 @@
 
 class ostream;
 
+#include <string>
+
 #include "dMatrix.h"
 
 class GEPBALANCE
@@ -40,7 +42,7 @@
 
   GEPBALANCE (void) { }
 
-  GEPBALANCE (const Matrix& a, const Matrix& b, const char * balance_job)
+  GEPBALANCE (const Matrix& a, const Matrix& b, const string& balance_job)
     {
       init (a, b, balance_job); 
     }
@@ -73,7 +75,7 @@
 
 private:
 
-  int init (const Matrix& a, const Matrix& b, const char * balance_job);
+  int init (const Matrix& a, const Matrix& b, const string& balance_job);
 
   Matrix balanced_a_mat;
   Matrix balanced_b_mat;
--- a/src/balance.cc	Tue Jan 09 12:00:58 1996 +0000
+++ b/src/balance.cc	Tue Jan 09 12:18:45 1996 +0000
@@ -74,8 +74,7 @@
       return retval;
     }
 
-  const char *bal_job;
-  string tstr;
+  string bal_job;
   int my_nargin;		// # args w/o optional string arg
 
   // Determine if balancing option is listed.  Set my_nargin to the
@@ -83,8 +82,7 @@
 
   if (args(nargin-1).is_string ())
     {
-      tstr = args(nargin-1).string_value ();
-      bal_job = tstr.c_str ();
+      bal_job = args(nargin-1).string_value ();
       my_nargin = nargin-1;
     }
   else