changeset 4628:c0121a3b9cbe

[project @ 2003-11-17 20:19:07 by jwe]
author jwe
date Mon, 17 Nov 2003 20:19:07 +0000
parents 212fc2115e09
children ed92d574b55b
files src/ChangeLog src/DLD-FUNCTIONS/balance.cc src/DLD-FUNCTIONS/daspk.cc src/DLD-FUNCTIONS/dasrt.cc src/DLD-FUNCTIONS/dassl.cc src/DLD-FUNCTIONS/find.cc src/DLD-FUNCTIONS/fsolve.cc src/DLD-FUNCTIONS/lsode.cc src/DLD-FUNCTIONS/odessa.cc src/DLD-FUNCTIONS/sort.cc
diffstat 10 files changed, 57 insertions(+), 189 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Mon Nov 17 03:48:04 2003 +0000
+++ b/src/ChangeLog	Mon Nov 17 20:19:07 2003 +0000
@@ -1,3 +1,21 @@
+2003-11-17  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* DLD-FUNCTIONS/sort.cc (Fsort): Use const qualifier as appropriate.
+
+	* DLD-FUNCTIONS/balance.cc (balance): Use data() instead of
+	fortran_vec where appropriate in call to dggbak.
+
+	* DLD-FUNCTIONS/dasrt.cc (dasrt_user_j): Simplify inserting x and
+	xdot in arg vector.
+	(dasrt_user_f): Likewise.
+	(dasrt_user_cf): Likewise.
+	* DLD-FUNCTIONS/dassl.cc (dassl_user_function): Likewise.
+	(dassl_user_jacobian): Likewise.
+	* DLD-FUNCTIONS/lsode.cc (lsode_user_function): Likewise.
+	(lsode_user_jacobian): Likewise.
+	* DLD-FUNCTIONS/daspk.cc (daspk_user_function): Likewise.
+	(daspk_user_jacobian): Likewise.
+
 2003-11-16  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* ov-range.h (octave_range::reshape): New function.
--- a/src/DLD-FUNCTIONS/balance.cc	Mon Nov 17 03:48:04 2003 +0000
+++ b/src/DLD-FUNCTIONS/balance.cc	Mon Nov 17 20:19:07 2003 +0000
@@ -294,8 +294,8 @@
       F77_XFCN (dggbak, DGGBAK,
 		(F77_CONST_CHAR_ARG2 (&job, 1),
 		 F77_CONST_CHAR_ARG2 ("L", 1),
-		 nn, ilo, ihi, lscale.fortran_vec (),
-		 rscale.fortran_vec(), nn, Pl.fortran_vec (), nn, info
+		 nn, ilo, ihi, lscale.data (), rscale.data (),
+		 nn, Pl.fortran_vec (), nn, info
 		 F77_CHAR_ARG_LEN (1)
 		 F77_CHAR_ARG_LEN (1)));
       
@@ -309,8 +309,8 @@
       F77_XFCN (dggbak, DGGBAK,
 		(F77_CONST_CHAR_ARG2 (&job, 1),
 		 F77_CONST_CHAR_ARG2 ("R", 1),
-		 nn, ilo, ihi, lscale.fortran_vec (),
-		 rscale.fortran_vec (), nn, Pr.fortran_vec (), nn, info
+		 nn, ilo, ihi, lscale.data (), rscale.data (),
+		 nn, Pr.fortran_vec (), nn, info
 		 F77_CHAR_ARG_LEN (1)
 		 F77_CHAR_ARG_LEN (1)));
 
--- a/src/DLD-FUNCTIONS/daspk.cc	Mon Nov 17 03:48:04 2003 +0000
+++ b/src/DLD-FUNCTIONS/daspk.cc	Mon Nov 17 20:19:07 2003 +0000
@@ -62,36 +62,13 @@
 {
   ColumnVector retval;
 
-  int nstates = x.capacity ();
-
-  assert (nstates == xdot.capacity ());
+  assert (x.capacity () == xdot.capacity ());
 
   octave_value_list args;
+
   args(2) = t;
-
-  if (nstates > 1)
-    {
-      Matrix m1 (nstates, 1);
-      Matrix m2 (nstates, 1);
-      for (int i = 0; i < nstates; i++)
-	{
-	  m1 (i, 0) = x (i);
-	  m2 (i, 0) = xdot (i);
-	}
-      octave_value state (m1);
-      octave_value deriv (m2);
-      args(1) = deriv;
-      args(0) = state;
-    }
-  else
-    {
-      double d1 = x (0);
-      double d2 = xdot (0);
-      octave_value state (d1);
-      octave_value deriv (d2);
-      args(1) = deriv;
-      args(0) = state;
-    }
+  args(1) = xdot;
+  args(0) = x;
 
   if (daspk_fcn)
     {
@@ -133,38 +110,14 @@
 {
   Matrix retval;
 
-  int nstates = x.capacity ();
-
-  assert (nstates == xdot.capacity ());
+  assert (x.capacity () == xdot.capacity ());
 
   octave_value_list args;
 
   args(3) = cj;
   args(2) = t;
-
-  if (nstates > 1)
-    {
-      Matrix m1 (nstates, 1);
-      Matrix m2 (nstates, 1);
-      for (int i = 0; i < nstates; i++)
-	{
-	  m1 (i, 0) = x (i);
-	  m2 (i, 0) = xdot (i);
-	}
-      octave_value state (m1);
-      octave_value deriv (m2);
-      args(1) = deriv;
-      args(0) = state;
-    }
-  else
-    {
-      double d1 = x (0);
-      double d2 = xdot (0);
-      octave_value state (d1);
-      octave_value deriv (d2);
-      args(1) = deriv;
-      args(0) = state;
-    }
+  args(1) = xdot;
+  args(0) = x;
 
   if (daspk_jac)
     {
--- a/src/DLD-FUNCTIONS/dasrt.cc	Mon Nov 17 03:48:04 2003 +0000
+++ b/src/DLD-FUNCTIONS/dasrt.cc	Mon Nov 17 20:19:07 2003 +0000
@@ -57,32 +57,18 @@
 static int call_depth = 0;
 
 static ColumnVector
-dasrt_user_f (const ColumnVector& x, const ColumnVector& xprime,
+dasrt_user_f (const ColumnVector& x, const ColumnVector& xdot,
 	      double t, int& ires)
 {
   ColumnVector retval;
 
-  octave_value_list args;
+  assert (x.capacity () == xdot.capacity ());
 
-  int n = x.length ();
+  octave_value_list args;
 
   args(2) = t;
-
-  if (n > 1)
-    {
-      args(1) = xprime;
-      args(0) = x;
-    }
-  else if (n == 1)
-    {
-      args(1) = xprime(0);
-      args(0) = x(0);
-    }
-  else
-    {
-      args(1) = Matrix ();
-      args(0) = Matrix ();
-    }
+  args(1) = xdot;
+  args(0) = x;
 
   if (dasrt_f)
     {
@@ -121,16 +107,8 @@
 
   octave_value_list args;
 
-  int n = x.length ();
-
-  if (n > 1)
-    args(0) = x;
-  else if (n == 1)
-    args(0) = x(0);
-  else
-    args(0) = Matrix ();
-
   args(1) = t;
+  args(0) = x;
 
   if (dasrt_cf)
     {
@@ -168,38 +146,14 @@
 {
   Matrix retval;
 
-  int nstates = x.capacity ();
-
-  assert (nstates == xdot.capacity ());
+  assert (x.capacity () == xdot.capacity ());
 
   octave_value_list args;
 
   args(3) = cj;
   args(2) = t;
-
-  if (nstates > 1)
-    {
-      Matrix m1 (nstates, 1);
-      Matrix m2 (nstates, 1);
-      for (int i = 0; i < nstates; i++)
-	{
-	  m1 (i, 0) = x (i);
-	  m2 (i, 0) = xdot (i);
-	}
-      octave_value state (m1);
-      octave_value deriv (m2);
-      args(1) = deriv;
-      args(0) = state;
-    }
-  else
-    {
-      double d1 = x (0);
-      double d2 = xdot (0);
-      octave_value state (d1);
-      octave_value deriv (d2);
-      args(1) = deriv;
-      args(0) = state;
-    }
+  args(1) = xdot;
+  args(0) = x;
 
   if (dasrt_j)
     {
--- a/src/DLD-FUNCTIONS/dassl.cc	Mon Nov 17 03:48:04 2003 +0000
+++ b/src/DLD-FUNCTIONS/dassl.cc	Mon Nov 17 20:19:07 2003 +0000
@@ -62,36 +62,13 @@
 {
   ColumnVector retval;
 
-  int nstates = x.capacity ();
-
-  assert (nstates == xdot.capacity ());
+  assert (x.capacity () == xdot.capacity ());
 
   octave_value_list args;
+
   args(2) = t;
-
-  if (nstates > 1)
-    {
-      Matrix m1 (nstates, 1);
-      Matrix m2 (nstates, 1);
-      for (int i = 0; i < nstates; i++)
-	{
-	  m1 (i, 0) = x (i);
-	  m2 (i, 0) = xdot (i);
-	}
-      octave_value state (m1);
-      octave_value deriv (m2);
-      args(1) = deriv;
-      args(0) = state;
-    }
-  else
-    {
-      double d1 = x (0);
-      double d2 = xdot (0);
-      octave_value state (d1);
-      octave_value deriv (d2);
-      args(1) = deriv;
-      args(0) = state;
-    }
+  args(1) = xdot;
+  args(0) = x;
 
   if (dassl_fcn)
     {
@@ -133,38 +110,14 @@
 {
   Matrix retval;
 
-  int nstates = x.capacity ();
-
-  assert (nstates == xdot.capacity ());
+  assert (x.capacity () == xdot.capacity ());
 
   octave_value_list args;
 
   args(3) = cj;
   args(2) = t;
-
-  if (nstates > 1)
-    {
-      Matrix m1 (nstates, 1);
-      Matrix m2 (nstates, 1);
-      for (int i = 0; i < nstates; i++)
-	{
-	  m1 (i, 0) = x (i);
-	  m2 (i, 0) = xdot (i);
-	}
-      octave_value state (m1);
-      octave_value deriv (m2);
-      args(1) = deriv;
-      args(0) = state;
-    }
-  else
-    {
-      double d1 = x (0);
-      double d2 = xdot (0);
-      octave_value state (d1);
-      octave_value deriv (d2);
-      args(1) = deriv;
-      args(0) = state;
-    }
+  args(1) = xdot;
+  args(0) = x;
 
   if (dassl_jac)
     {
--- a/src/DLD-FUNCTIONS/find.cc	Mon Nov 17 03:48:04 2003 +0000
+++ b/src/DLD-FUNCTIONS/find.cc	Mon Nov 17 20:19:07 2003 +0000
@@ -37,7 +37,7 @@
       T tmp (count); \
  \
       for (int i = 0; i < count; i++) \
-	tmp (i) = nr * (j_idx (i) - 1.0) + i_idx (i); \
+	tmp (i) = nr * (j_idx(i) - 1.0) + i_idx(i); \
  \
       retval(0) = tmp; \
     } \
@@ -61,9 +61,9 @@
 	int count = i_idx.length ();
 
 	if (nr == 1)
-	  DO_FIND_OP(RowVector);
+	  DO_FIND_OP (RowVector);
 	else
-	  DO_FIND_OP(ColumnVector);
+	  DO_FIND_OP (ColumnVector);
       }
       break;
 
--- a/src/DLD-FUNCTIONS/fsolve.cc	Mon Nov 17 03:48:04 2003 +0000
+++ b/src/DLD-FUNCTIONS/fsolve.cc	Mon Nov 17 20:19:07 2003 +0000
@@ -153,13 +153,13 @@
     {
       Matrix m (n, 1);
       for (int i = 0; i < n; i++)
-	m (i, 0) = x (i);
+	m(i,0) = x(i);
       octave_value vars (m);
       args(0) = vars;
     }
   else
     {
-      double d = x (0);
+      double d = x(0);
       octave_value vars (d);
       args(0) = vars;
     }
--- a/src/DLD-FUNCTIONS/lsode.cc	Mon Nov 17 03:48:04 2003 +0000
+++ b/src/DLD-FUNCTIONS/lsode.cc	Mon Nov 17 20:19:07 2003 +0000
@@ -67,12 +67,7 @@
 
   octave_value_list args;
   args(1) = t;
-
-  Matrix m (nstates, 1);
-  for (int i = 0; i < nstates; i++)
-    m (i, 0) = x (i);
-  octave_value state (m);
-  args(0) = state;
+  args(0) = x;
 
   if (lsode_fcn)
     {
@@ -113,12 +108,7 @@
 
   octave_value_list args;
   args(1) = t;
-
-  Matrix m (nstates, 1);
-  for (int i = 0; i < nstates; i++)
-    m (i, 0) = x (i);
-  octave_value state (m);
-  args(0) = state;
+  args(0) = x;
 
   if (lsode_jac)
     {
--- a/src/DLD-FUNCTIONS/odessa.cc	Mon Nov 17 03:48:04 2003 +0000
+++ b/src/DLD-FUNCTIONS/odessa.cc	Mon Nov 17 20:19:07 2003 +0000
@@ -532,7 +532,7 @@
 
       bool crit_times_set = false;
 
-      if (nargin==6)
+      if (nargin == 6)
 	{
 	  crit_times = ColumnVector (args(5).vector_value ());
 
--- a/src/DLD-FUNCTIONS/sort.cc	Mon Nov 17 03:48:04 2003 +0000
+++ b/src/DLD-FUNCTIONS/sort.cc	Mon Nov 17 20:19:07 2003 +0000
@@ -378,7 +378,7 @@
 
   if (arg.is_real_type ())
     {
-      Matrix m = arg.matrix_value ();
+      const Matrix m = arg.matrix_value ();
 
       if (! error_state)
 	{
@@ -387,7 +387,7 @@
 	      int nc = m.columns ();
 	      RowVector v (nc);
 	      for (int i = 0; i < nc; i++)
-		v (i) = m (0, i);
+		v(i) = m(0,i);
 
 	      retval = mx_sort (v);
 	    }
@@ -397,7 +397,7 @@
     }
   else if (arg.is_complex_type ())
     {
-      ComplexMatrix cm = arg.complex_matrix_value ();
+      const ComplexMatrix cm = arg.complex_matrix_value ();
 
       if (! error_state)
 	{
@@ -406,7 +406,7 @@
 	      int nc = cm.columns ();
 	      ComplexRowVector cv (nc);
 	      for (int i = 0; i < nc; i++)
-		cv (i) = cm (0, i);
+		cv(i) = cm(0,i);
 
 	      retval = mx_sort (cv);
 	    }