changeset 5341:4bea82210dcd

[project @ 2005-05-06 17:11:47 by jwe]
author jwe
date Fri, 06 May 2005 17:11:47 +0000
parents 15843d76156d
children f9ab8e67ce7a
files src/ChangeLog src/DLD-FUNCTIONS/__qp__.cc src/ov-struct.cc
diffstat 3 files changed, 16 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Fri May 06 16:26:59 2005 +0000
+++ b/src/ChangeLog	Fri May 06 17:11:47 2005 +0000
@@ -1,5 +1,13 @@
 2005-05-06  John W. Eaton  <jwe@octave.org>
 
+	* ov-struct.cc (octave_struct::save_ascii,
+	octave_struct::save_binary, octave_sruct::save_hdf5):
+	Always save cell array.
+
+	* DLD-FUNCTIONS/__qp__.cc (qp): Use chol2inv to compute inverse
+	from Cholesky factors.
+	(cholinv): Delete.
+
 	* DLD-FUNCTIONS/chol.cc (Fcholinv): New function.
 	(Fchol2inv): New function.
 
--- a/src/DLD-FUNCTIONS/__qp__.cc	Fri May 06 16:26:59 2005 +0000
+++ b/src/DLD-FUNCTIONS/__qp__.cc	Fri May 06 17:11:47 2005 +0000
@@ -86,26 +86,6 @@
   return retval;
 }
 
-static Matrix
-cholinv (const Matrix& R)
-{
-  // R should be the result of calling chol on a symmetric positive
-  // definite matrix.
-  octave_idx_type n = R.rows ();
-  Matrix L = R.transpose ();
-  ColumnVector d = L.diag ();
-  ColumnVector tmp (n);
-  for (octave_idx_type k = 0; k < n; k++)
-    {
-      for (octave_idx_type j = 0; j < n; j++)
-	L(j,k) = L(j,k) / d(k);
-      tmp(k) = 1.0/(d(k)*d(k));
-    }
-  DiagMatrix Dinv (tmp);
-  Matrix invL = L.inverse ();
-  return invL.transpose () * Dinv * invL;
-}
-
 static int
 qp (const Matrix& H, const ColumnVector& q,
     const Matrix& Aeq, const ColumnVector& beq,
@@ -208,7 +188,7 @@
 
 	      R = cholH.chol_matrix ();
 
-	      Matrix Hinv = cholinv (R);
+	      Matrix Hinv = chol2inv (R);
 
 	      // Computing the unconstrained step.
 	      // p = -Hinv * g;
@@ -278,7 +258,7 @@
 		{
 		  // Using the Cholesky factorization to invert rH
 
-		  Matrix rHinv = cholinv (R);
+		  Matrix rHinv = chol2inv (R);
 
 		  ColumnVector pz = -rHinv * Zt * g;
 
--- a/src/ov-struct.cc	Fri May 06 16:26:59 2005 +0000
+++ b/src/ov-struct.cc	Fri May 06 17:11:47 2005 +0000
@@ -987,10 +987,9 @@
   Octave_map::iterator i = m.begin ();
   while (i != m.end ())
     {
-      Cell val = map.contents (i);
-      octave_value tmp = (map.numel () == 1) ? val(0) : octave_value (val);
+      octave_value val = map.contents (i);
 
-      bool b = save_ascii_data (os, tmp, m.key (i), infnan_warned, 
+      bool b = save_ascii_data (os, val, m.key (i), infnan_warned, 
 				strip_nan_and_inf, 0, 0);
       
       if (! b)
@@ -1069,10 +1068,9 @@
   Octave_map::iterator i = m.begin ();
   while (i != m.end ())
     {
-      Cell val = map.contents (i);
-      octave_value tmp = (map.numel () == 1) ? val(0) : octave_value (val);
+      octave_value val = map.contents (i);
 
-      bool b = save_binary_data (os, tmp, m.key (i), "", 0, save_as_floats);
+      bool b = save_binary_data (os, val, m.key (i), "", 0, save_as_floats);
       
       if (! b)
 	return os;
@@ -1153,10 +1151,9 @@
   Octave_map::iterator i = m.begin ();
   while (i != m.end ())
     {
-      Cell val = map.contents (i);
-      octave_value tmp = (map.numel () == 1) ? val(0) : octave_value (val);
+      octave_value val = map.contents (i);
 
-      bool retval2 = add_hdf5_data (data_hid, tmp, m.key (i), "", false, 
+      bool retval2 = add_hdf5_data (data_hid, val, m.key (i), "", false, 
 				    save_as_floats);
 
       if (! retval2)