我可能弄错了,但是使用 mprf 对象可以访问基础 R intersect、union、setdiff,而 sort(... 需要包裹在 mprf(sort(...), 'bits') 中:
library(Rmprf)
f3 <- mpfr(5:9, 53)
f4 <- mpfr(8:12, 53)
intersect(f3,f4)
2 'mpfr' numbers of precision 53 bits
[1] 8 9
setdiff(f3,f4)
3 'mpfr' numbers of precision 53 bits
[1] 5 6 7
f3 %in% f4
[1] FALSE FALSE FALSE TRUE TRUE
# large integers from vignette
ns <- mpfr(1:24, 120)
fact_ns <- factorial(ns)
fact_ns[20:24]
5 'mpfr' numbers of precision 120 bits
[1] 2432902008176640000 51090942171709440000 1124000727777607680000
[4] 25852016738884976640000 620448401733239439360000
pasc80 <- chooseMpfr.all(n = 80, 77)[40:49]
pasc80
10 'mpfr' numbers of precision 77 bits
[1] 107507208733336176461620 104885081691059684352800 97393290141698278327600
[4] 86068488962431036661600 72375774809317008101800 57900619847453606481440
[7] 44054819449149483192400 31869443856831541032800 21910242651571684460050
[10] 14308729894903957198400
mpfr(sort(union(fact_ns[20:24], pasc80)), 77)
15 'mpfr' numbers of precision 77 bits
[1] 2432902008176640000 51090942171709440000 1124000727777607680000
[4] 14308729894903957198400 21910242651571684460050 25852016738884976640000
[7] 31869443856831541032800 44054819449149483192400 57900619847453606481440
[10] 72375774809317008101800 86068488962431036661600 97393290141698278327600
[13] 104885081691059684352800 107507208733336176461620 6204484017332394393600
所以对于这些操作sets 是不必要的,并且假设您的工作流程适合基于Rmprf 的对象。
由于问题是在“精确度”的上下文中提出的,因此人们可能不希望将集合提升或降级为最高/最低“prec”的功能,而是有意参与决策(尽管,诚然,我找了一个)。
在这里,将下面的 f3 和 f4 重命名为 f7 和 f8:
getPrec(f7)[1]
[1] 10
getPrec(f8)[1]
[1] 20
intersect(roundMpfr(f7, 20), f8)
2 'mpfr' numbers of precision 20 bits
[1] 9 6
intersect(f7, roundMpfr(f8, 10))
2 'mpfr' numbers of precision 10 bits
[1] 9 6
因此,设置操作似乎需要“精度处理”,但如果在创建 mpfr 时,默认值将使输入呈现相同的精度是合理的,则可以避免这种额外的循环。使用 OEIS 作为输入:
library(OEIS.R) # git clone of EnriquePH/OEIS.R --no-build-vignettes
A011784 <- OEIS_bfile('A011784')
max(nchar(A011784$data$A011784))
[1] 221
max(nchar(A078140$data$A078140))
[1] 228
# so we see precision handling here, perhaps
A011784_228 <- mpfr(A011784$data$A011784, 228)
A078140_228 <- mpfr(A078140$data$A078140, 228)
intersect(A011784_228,A078140_228)
2 'mpfr' numbers of precision 228 bits
[1] 1 3
啊,这么少的共同点。而且可能不是您的序列在 OEIS 中,而是检查与您的“来自野外”的序列的相似性,这并不能反映您的工作流程。
还有一些相关的,从最近的新闻中轻松阅读primitive sets。