diff liboctave/dMatrix.cc @ 7544:f9983d2761df

more xGELSD workspace fixes
author Jaroslav Hajek <highegg@gmail.com>
date Mon, 03 Mar 2008 02:18:12 -0500
parents 493bb0de3199
children 36594d5bbe13
line wrap: on
line diff
--- a/liboctave/dMatrix.cc
+++ b/liboctave/dMatrix.cc
@@ -2053,7 +2053,7 @@
 #else
       double tmp = log (dminmn / dsmlsizp1) / log (2.0);
 #endif
-      octave_idx_type nlvl = static_cast<int> (tmp) + 1;
+      octave_idx_type nlvl = static_cast<octave_idx_type> (tmp) + 1;
       if (nlvl < 0)
 	nlvl = 0;
 
@@ -2231,19 +2231,23 @@
 
       Array<double> work (1);
 
-      // FIXME: Can SMLSIZ be other than 25?
-      octave_idx_type smlsiz = 25;
+      octave_idx_type smlsiz;
+      F77_FUNC (xilaenv, XILAENV) (9, F77_CONST_CHAR_ARG2 ("DGELSD", 6),
+				   F77_CONST_CHAR_ARG2 (" ", 1),
+				   0, 0, 0, 0, smlsiz
+				   F77_CHAR_ARG_LEN (6)
+				   F77_CHAR_ARG_LEN (1));
 
       // We compute the size of iwork because DGELSD in older versions
       // of LAPACK does not return it on a query call.
       double dminmn = static_cast<double> (minmn);
       double dsmlsizp1 = static_cast<double> (smlsiz+1);
 #if defined (HAVE_LOG2)
-      double tmp = log2 (dminmn) / dsmlsizp1 + 1;
+      double tmp = log2 (dminmn / dsmlsizp1);
 #else
-      double tmp = log (dminmn) / dsmlsizp1 / log (2.0) + 1;
+      double tmp = log (dminmn / dsmlsizp1) / log (2.0);
 #endif
-      octave_idx_type nlvl = static_cast<int> (tmp);
+      octave_idx_type nlvl = static_cast<octave_idx_type> (tmp) + 1;
       if (nlvl < 0)
 	nlvl = 0;