0

我的问题有两个部分。一:我要在网格上做双重积分

answer = integrate (  f(x,y) times besselfunction(x,y))

现在,我读到贝塞尔函数可以预先计算并保存到磁盘以便快速访问。我该怎么做呢?现在,我正在根据需要评估来自 scipy.special 的 besselfunction。

第二个问题:我已经对一个微分方程进行了数值积分,并使用样条解来求解其他微分方程。然而,花键解决方案很慢。有没有办法让它更快?

4

1 回答 1

0

You seem to be looking for an on-disk memoization solution.
You could probably make a memoization decorator that uses berkeleydb to store the results of all function calls computed so far onto disk (if you can carry the resulting berkeleydb file around to every machine you run your program on and don't mind it becoming really huge, you would need to compute the function for a given set of args only once ... I don't know if this is such a good idea in context of what you are doing here though)
Googling for "memoize decorator disk" seems to bring up some interesting solutions to your problem.
This one in particular looks kinda promising - http://www.stanford.edu/~pgbovine/incpy.html

于 2011-08-28T03:39:21.887 回答