开源地址:https://github.com/JakeEBrooks/mojocmath
- 扩展
ComplexSIMD类型以包括与其他的复杂运算ComplexSIMDs以及与其他的实际运算SIMDs。
- 还添加了用于计算绝对值、参数以及极坐标形式转换的基本函数
- 添加对 进行操作的数学函数库
ComplexSIMDs,其中包括:
- 三角函数:
csin,,,,等ccoscasin``cacosh
- 指数函数:
cexp,,,等csquare``cpow
- 对数函数:
clog,,,等clog10``clogb
- 常规函数,例如
csqrt
例子
from cmath import ComplexSIMD, ComplexScalar, csqrt
fn main():
var c = ComplexSIMD[DType.float64, 2].i()
print("i: ", c)
c[0] = ComplexScalar(-4, -0.)
c[1] = ComplexScalar(-4, 0.)
print("Branch Cuts are handled: ", csqrt(c))
i: [0.0, 0.0] [1.0, 1.0]i
Branch Cuts are handled: [0.0, 0.0] [-2.0, 2.0]i