changeset 12409:af840cd6f813 octave-forge

general: report invalid input for unvech.
author jpicarbajal
date Fri, 28 Mar 2014 11:16:41 +0000
parents b169673b4d96
children b3f18daf312a
files main/general/inst/unvech.m
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/main/general/inst/unvech.m	Tue Mar 18 22:36:09 2014 +0000
+++ b/main/general/inst/unvech.m	Fri Mar 28 11:16:41 2014 +0000
@@ -45,6 +45,9 @@
 
   N      = length (v);
   dim    = (sqrt ( 1 + 8*N ) - 1)/2;
+  if fix(dim) != dim
+    error ("Octave:invalid-input-arg", "the length of the vector cannot form a square matrix.\n");
+  endif
   [r, c] = ind2sub_tril (dim, 1:N);   # replace with core ind2sub after octave 3.6
   M      = accumarray ([r; c].', v);
   M     += scale * tril (M, -1).';