2

R中的复数定义为:

function (length.out = 0L, real = numeric(), imaginary = numeric(), modulus = 1, argument = 0)

我有一个程序,旨在处理真实案例和复杂案例中的多个精度值。R 不直接支持多精度。安装Rmpfr包后,我可以定义多个精度值并使用新的mpfr objects.

TestFunc <- function(a, b){
    seq(a, b, length.out = 3)
}

>TestFunc(mpfr(1, 120), mpfr(2, 120))
[1]                                       1
[2] 1.1666666666666666666666666666666666662
[3] 1.3333333333333333333333333333333333338
[4]                                     1.5
[5] 1.6666666666666666666666666666666666677
[6] 1.8333333333333333333333333333333333338
[7]                                       2

我有也处理复数的函数。

问题: 我不能打电话

complex(real=mpfr(1, 120), imaginary=mpfr(1,120))

因为,复杂的函数定义只要求这些是双精度的。

有没有一种方法可以在 R 中使用多精度进行复数算术?

4

0 回答 0