Is there a way to implement recurrence in numpy without for-loops?

后端 未结 1 448
野性不改
野性不改 2021-01-07 11:11

I have the following problem. There is a matrix X and I need to generate a matrix H such that values of i_th row in matrix H

相关标签:
1条回答
  • 2021-01-07 12:18

    There is no other way (in general) except for an explicit for loop. This is because there is no way to parallelize this task across the rows (since every row depends on some other row).

    What makes this even harder is that you can easily generate chaotic behavior, for example with the seemingly innocent looking logistic map: x_{n+1} = r * x_n * (1 - x_{n-1}).

    You can only find a way around this if you manage to find a closed form, essentially eliminating the recurrence relation. But this has to be done for each recurrence relation and I am pretty sure you are not even guaranteed that a closed form exists...

    0 讨论(0)
提交回复
热议问题