Element-wise operations in mpmath

核能气质少年 提交于 2019-12-01 18:20:52

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, so you can use map to apply a function on each element:

import mpmath
x = mpmath.arange(0,4)
y = map(mpmath.sin, x)
nasir

The apply method simply should work

A = mpmath.arange(0,4)

A.apply(sin)
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!