From owner-bug-octave at bevo dot che dot wisc dot edu Wed Jan 22 11:24:28 1997 Subject: Re: erfinv.m From: Andreas Weingessel To: "John W. Eaton" Cc: bug-octave at bevo dot che dot wisc dot edu Date: Wed, 22 Jan 1997 18:26:00 +0100 >>>>> On Wed, 22 Jan 1997 11:04:11 -0600, >>>>> John W Eaton wrote: > On 22-Jan-1997, Andreas Weingessel wrote: > : The function "erfinv" yields an error of the form > : error: A([]) = X: X must also be an empty matrix > : error: evaluating assignment expression near line 40, column 22 > : error: called from `erfinv' in file `/usr/local/lib/octave/2.0.1/m/specfun/erfinv.m' > : > : This is caused by the fact that an assignment of a 0x1-matrix to a > : 0x0-matrix worked in octave-1.1.1, but does not work now. > : > : Repeat-By: > : --------- > : > : octave:1> erfinv(0.3) > : error: A([]) = X: X must also be an empty matrix > : error: evaluating assignment expression near line 40, column 22 > : error: called from `erfinv' in file `/usr/local/lib/octave/2.0.1/m/specfun/erfinv.m' > : > : > : Fix: > : --- > : > : Replace the lines > : > : y (find (x == -1)) = (-Inf) * ones (sum (x == -1), 1); > : y (find (x == 1)) = Inf * ones (sum (x == 1), 1); > : > : by > : > : y (find (x == -1)) = (-Inf) * ones (sum (x == -1)); > : y (find (x == 1)) = Inf * ones (sum (x == 1)); > I don't think this fix is right though. If > sum (x == 1) > is nonzero, then > ones (sum (x == 1)) > will produce a matrix instead of a vector, and you will get another > error. > Perhaps it should be: > t = (x == -1); > n = sum (t); > if (n > 0) > y (find (t)) = -Inf * ones (n, 1); > endif > instead? > I realize that this is not quite as concise... > Another possibility would be to write > t = find (x == -1); > y (t) = -Inf * ones (size (t)); > What do you think? I think the 2nd possibility looks fine. If one prefers the original form one could write y (find (x == -1)) = (-Inf) * ones (sum (x == -1), (sum(x == -1)>0)); y (find (x == 1)) = Inf * ones (sum (x == 1), (sum(x == 1)>0)); -aw