changeset 15042:4328e28414aa

maint: periodic merge of stable to default
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Sat, 28 Jul 2012 11:59:10 -0400
parents bc61fba0e9fd (current diff) 1316bfc6e260 (diff)
children fabc0e37ead1 d7124baf5f86
files liboctave/sparse-dmsolve.cc scripts/help/unimplemented.m
diffstat 2 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/sparse-dmsolve.cc
+++ b/liboctave/sparse-dmsolve.cc
@@ -33,6 +33,7 @@
 #include "MatrixType.h"
 #include "oct-sort.h"
 #include "oct-locbuf.h"
+#include "oct-inttypes.h"
 
 template <class T>
 static MSparse<T>
@@ -42,9 +43,17 @@
                 octave_idx_type cend, octave_idx_type maxnz = -1,
                 bool lazy = false)
 {
-  octave_idx_type nz = (rend - rst) * (cend - cst);
+  octave_idx_type nr = rend - rst, nc = cend - cst;
   maxnz = (maxnz < 0 ? A.nnz () : maxnz);
-  MSparse<T> B (rend - rst, cend - cst, (nz < maxnz ? nz : maxnz));
+  octave_idx_type nz;
+
+  // Cast to uint64 to handle overflow in this multiplication
+  if (octave_uint64 (nr)*octave_uint64 (nc) < octave_uint64 (maxnz))
+    nz = nr*nc;
+  else
+    nz = maxnz;
+
+  MSparse<T> B (nr, nc, (nz < maxnz ? nz : maxnz));
   // Some sparse functions can support lazy indexing (where elements
   // in the row are in no particular order), even though octave in
   // general can't. For those functions that can using it is a big
--- a/scripts/help/unimplemented.m
+++ b/scripts/help/unimplemented.m
@@ -38,7 +38,7 @@
     txt = ["quad2d is not implemented.  Consider using dblquad."];
 
   case "gsvd"
-    txt = ["gsvd is not currently part of core Octave.  See the ",
+    txt = ["gsvd is not currently part of core Octave.  See the ",...
     "linear-algebra package at @url{http://octave.sf.net/linear-algebra/}."];
 
   case "linprog"