Mercurial > hg > octave-lojdl
changeset 13894:d4404589498c
pascal.m: permutation compatibility with Matlab for n=2; fixed n=0 case (Bug #34365)
* pascal.m: permutation compatibility with Matlab for n=2; fixed n=0 case (Bug #34365)
author | Vanya Sergeev <vsergeev@gmail.com> |
---|---|
date | Fri, 23 Sep 2011 05:13:01 -0400 |
parents | 5b1ddcf5ede1 |
children | 2f73cbd951fb |
files | scripts/special-matrix/pascal.m |
diffstat | 1 files changed, 5 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/special-matrix/pascal.m +++ b/scripts/special-matrix/pascal.m @@ -55,7 +55,9 @@ endif retval = zeros (n); - retval(:,1) = 1; + if (n > 0) + retval(:,1) = 1; + endif if (t == -1) for j = 2:n @@ -71,9 +73,7 @@ retval = retval*retval'; elseif (t == 2) retval = retval'; - retval = retval(n:-1:1,:); - retval(:,n) = -retval(:,n); - retval(n,:) = -retval(n,:); + retval = retval (:,n:-1:1); if (rem(n,2) != 1) retval = -retval; endif @@ -85,7 +85,7 @@ %!assert (pascal(3,0), [1,1,1;1,2,3;1,3,6]) %!assert (pascal(3,0), pascal(3)) %!assert (pascal(3,1), [1,0,0;1,-1,0;1,-2,1]) -%!assert (pascal(3,2), [0,0,-1;0,-1,2;-1,-1,1]) +%!assert (pascal(3,2), [1,1,1;-2,-1,0;1,0,0]) %!error (pascal(3,4)) %!error (pascal(3,-2)) %!error (pascal())