约()设计用于复数吗?

时间:2013-04-17 12:16:57

标签: r complex-numbers

我做了以下实验,因为approx帮助页面上没有提及复杂数据:

Rgames> zfoo
[1] 1+ 6i 2+ 7i 3+ 8i 4+ 9i 5+10i
Rgames> approx(zfoo,n=10)
$x
 [1] 1.000000 1.444444 1.888889 2.333333 2.777778 3.222222 3.666667 4.111111
 [9] 4.555556 5.000000

$y
 [1]  6.000000  6.444444  6.888889  7.333333  7.777778  8.222222  8.666667
 [8]  9.111111  9.555556 10.000000

深入研究approx的代码,我发现xy.coords(对于复杂数据显然没有文档)将复杂数据的Real和Imag部分视为x和{{1坐标数据的一部分。所以我的问题是:这是预期的行为吗?依赖于未明确记录的功能,我总是有点偏执。

1 个答案:

答案 0 :(得分:6)

对我来说看起来是有意和可靠的,approx()调用regularize.values(),调用xy.coords(),其中包含此代码块:

else if (is.complex(x)) {
    y <- Im(x)
    x <- Re(x)
    xlab <- paste0("Re(", ylab, ")")
    ylab <- paste0("Im(", ylab, ")")
}

其后approx()继续传递数字(真实/理性)向量xy