duckladydinh's blog

By duckladydinh, history, 9 years ago, In English

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?

  • Vote: I like it
  • +32
  • Vote: I do not like it

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

What if you use a 3D matrix? (Seems like it would do, but not sure)

»
9 years ago, # |
Rev. 4   Vote: I like it -25 Vote: I do not like it

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).

»
9 years ago, # |
  Vote: I like it +15 Vote: I do not like it

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".