mpmath

Element-wise operations in mpmath

强颜欢笑 提交于 2019-12-01 18:21:36
问题 I am looking to perform element-wise mpmath operations on Python arrays. For example, import mpmath as mpm x = mpm.arange(0,4) y = mpm.sin(x) # error Alternatively, using mpmath matrices x = mpm.matrix([0,1,2,3]) y = mpm.sin(x) # error Does mpmath have any capibilities in this area, or is it necessary to loop through the entries? 回答1: mpmath does not appear to handle elemnt-wise operation, but you can use numpy to get this functionality: import numpy as np import mpmath as mpm x = np.array

Element-wise operations in mpmath

核能气质少年 提交于 2019-12-01 18:20:52
I am looking to perform element-wise mpmath operations on Python arrays. For example, import mpmath as mpm x = mpm.arange(0,4) y = mpm.sin(x) # error Alternatively, using mpmath matrices x = mpm.matrix([0,1,2,3]) y = mpm.sin(x) # error Does mpmath have any capibilities in this area, or is it necessary to loop through the entries? mpmath does not appear to handle elemnt-wise operation, but you can use numpy to get this functionality: import numpy as np import mpmath as mpm x = np.array(mpm.arange(0,4)) sin = np.vectorize(mpm.sin) y = sin(x) mpmath.arange apparently returns regular Python lists,

Is there a scaled complementary error function in python available?

我是研究僧i 提交于 2019-12-01 16:54:21
In matlab there is a special function which is not available in any of the collections for the Python I know (numpy, scipy, mpmath, ...). Probably there are other places where functions like this one may be found? UPD For all who think that the question is trivial, please try to compute this function for argument ~30 first. UPD2 Arbitrary precision is a nice workaround, but if possible I would prefer to avoid it. I need a "standard" machine precision (no more no less) and maximum speed possible. UPD3 It turns out, mpmath gives surprisingly inaccurate result. Even where standard python math

How to mpf an array?

廉价感情. 提交于 2019-11-28 23:49:45
I have: import numpy as np from mpmath import * mpf(np.array(range(0,600))) But it won't let me do it: TypeError: cannot create mpf from array So what should I be doing? Essentially I'm going to have use this array and multiply element-wise with an incredibly large or incredible small number depending on circumstance (eg 1.35626567e1084 or 6.2345252e-2732 ) hence the need for mpf. More specifically I'll be using the besseli and besselk function which create the incredible large and incredible small values. How do I get an mpf array to hold these numbers? Multiplying an array by a mpf number