I'm porting some MATLAB code to R and have come across this function:
pascal(4, 1)
which, according to the documentation, "returns the lower triangular Cholesky factor (up to the signs of the columns) of the Pascal matrix" and produces
1 | 0 | 0 | 0 |
---|---|---|---|
1 | -1 | 0 | 0 |
1 | -2 | 1 | 0 |
1 | -3 | 3 | -1 |
I think the equivalent R code is
t(chol(pascal(4)))
which produces the same numbers, up to the column signs as anticipated by the MATLAB documentation:
1 | 0 | 0 | 0 |
---|---|---|---|
1 | 1 | 0 | 0 |
1 | 2 | 1 | 0 |
1 | 3 | 3 | 1 |
What is the equivalent R code to produce the expected results with the correct column signs?
You can try pascal
from package pracma
> library(pracma)
> pascal(4, 1)
[,1] [,2] [,3] [,4]
[1,] 1 0 0 0
[2,] 1 -1 0 0
[3,] 1 -2 1 0
[4,] 1 -3 3 -1