Hi everyone!
For one-parameter function such as f(n) = f(n-1) + f(n-2), we all know that it can be solved with matrix multiplication, but what if there are two parameters such as f(n, m) = f(n, m-1) + f(n-1, m)? Is there similar way to solve it?
Can someone help me?
What if you use a 3D matrix? (Seems like it would do, but not sure)
I think Yes ... Because If you make 2D array and f and the result of f[i][j] = f(i, j). You can calculate this function in this way :
for(int i : 1 to n)
for(int j : 1 to m)
f[i][j] = f[i-1][j] + f[i][j-1]
and I know Just for this function if f[0][i] = 1 and f[i][0] = 1 It's c(i + j, i).
You can, if either of n or m is small enough. Let matrix store "last row of f values" instead of just "several last values".