MATL, 22 20 19 bytes
Ti:"2Y6Y+FT_Y)]!i_)
Both inputs are 0-based.
Try it online!
Explanation
Let r
and c
denote the two inputs, specifying 0-based row and column respectively.
Each new row in Pascal's rhombus can be built from the matrix containing the previous two rows by convolving with the kernel [1 1 1; 0 1 0]
and keeping the last two rows of the result swapped. This is done r
times, starting from matrix 1
.
It turns out to be shorter to use the kernel [0 1 0; 1 1 1; 0 1 0]
, which is a predefined literal. This produces an extra row, which will be discarded.
Consider for example r = 3
, so there are 3
iterations.
Starting from
1
convolution with [0 1 0; 1 1 1; 0 1 0]
gives
0 1 0
1 1 1
0 1 0
Keeping the last two rows (the whole matrix, in this case) and swapping them gives
0 1 0
1 1 1
Convolution of the above with [0 1 0; 1 1 1; 0 1 0]
gives
0 0 1 0 0
0 1 1 1 0
1 2 4 2 1
0 1 1 1 0
The matrix formed by the last two rows swapped is
0 1 1 1 0
1 2 4 2 1
This contains the new row at the bottom, and the preceding one extended with zeros.
Convolving again yields
0 0 1 1 1 0 0
0 1 2 3 2 1 0
1 3 8 9 8 3 1
0 1 2 4 2 1 0
Taking the last two rows swapped gives
0 1 2 4 2 1 0
1 3 8 9 8 3 1
After the r
iterations have been done, the output is contained in the last row of the final matrix. For example, for c = 2
(0-based) the result would be 8
. Instead of indexing the last row and the desired column, a trick can be used which exploits the symmetry of each row: the final matrix is transposed
0 1
1 3
2 8
4 9
2 8
1 3
0 1
and its -c
-th element is taken. This uses linear indexing, that is, the matrix is indexed by a single index in column-major order. Since indexing is modular, the 0
-entry is the lower-right corner (value 1
) and the -2
-th entry is two steps above (value 8
).
T % Push true
i % Input row number
:" % Do the following that many times
2Y6 % Push predefined literal [0 1 0; 1 1 1; 0 1 0]
Y+ % 2D convolution, increasing size
FT_ % Push [0 -1]
Y) % Matrix with rows 0 (last) and -1 (second-last), in that order
] % End
! % Transpose
i % Input: colun number
_ % Negate
) % Entry with that index. Implicitly display