Fri 23 Sep 2011 09:20:59 AM UTC, original submission:
ML's pascal(n,2) returns the horizontal permutation of pascal(n,1)', whereas Octave's pascal(n,2) returns the vertical permutation of pascal(n,1)'. They're both valid permutations of pascal(n,1)' in that pascal(n,2)^3 = eye(n), but using the same permutation as ML might be warranted for compatibility purposes.
Octave also does not handle the n=0 case correctly, it returns a 1x1 matrix [1] for pascal(0) and pascal(0,1), and errors out for pascal(0,2). ML returns the 0x0 empty matrix for pascal(n), 0x1 empty matrix for pascal(n,1), and 1x0 empty matrix for pascal(n,2).
MATLAB's pascal():
Octave's pascal():
Attached is hg patch to scripts/special-matrix/pascal.m for improved ML compatibility with pascal(), as well as a fix for the n=0 case.
The patched pascal() octave output:
For simplicity, I didn't make the modifications to reflect ML's dimensions of the empty matrix with pascal(0,1) and pascal(0,2), but this can probably be easily added if it's necessary.
~vsergeev
|