有效的代码可以使用BigZ级值进行设置操作?
程序包的当前版本GMP
不支持设置操作,例如Intersect
,setDiff
等。 (请参阅 oeis 以获取示例),并且需要处理大型整数集合。我目前坚持使用各种循环来生成所需的差异或交叉点;虽然我可能可以生成编译(RCCP等)代码,但我希望在现有r
功能和软件包中找到一种方法。
The current release of the package gmp
does not support set operations such as intersect
, setdiff
, etc. I'm doing some work with number sequences (see OEIS for examples) and need to handle large collections of large integers. I'm currently stuck with using various loops to generate the desired differences or intersections; while I could probably generate compiled (Rccp, etc) code, I'm hoping to find a way within existing R
functions and packages.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
bignum
而不是GMP
使用InterSect后,什么返回targine
。并重新分配需要时间。将
bigz
存储在list
中,而不是vector
。不幸的是,这比将其转换为角色要慢得多。
对于Intersect
重复
可以使用。但这也比转换为角色要慢。彼此比较每个元素也较慢:
在这种情况下,边缘更快的是:
一个简单的RCPP版本。
基准
结果
在这里看起来像是转换为
targue
,后背是当前最快的方法。甚至子集bigz
也比子集cartare
慢慢地将其转换为bigz
。RCPP中的版本比最快的其他方法快6-7倍。
Use
bignum
instead ofgmp
what returns acharacter
after using intersect. And reconverting needs time.Store the
bigz
in alist
instead as avector
.Unfortunately this is much slower than converting it to character.
For intersect
duplicated
could be used. But this is also slower than converting to character.And comparing each element with each other is also slower:
Marginal faster in this case is:
And a simple Rcpp versions.
Benchmark
Result
Here it looks like that converting to
character
and back is currently the fastest way. Even subsettingbigz
is slower than subsetting thecharacter
and converting it tobigz
.The Version in Rcpp is about 6-7 times faster than the fastest other method.
我可能弄错了,但是使用
mprf
对象提供了对基础rIntersect
,Union
,setDiff
的访问权限。 ,而排序(...
需要包装在mprf(sort(...),'bits')
:因此,对于这些操作是不需要的,并且假设您的工作流程适合
rmprf
基于的对象。 决定(尽管我在这里寻找一个)。
Demotes将
其最高/最低的“ Prec”设置为有意参与该 设置操作是需要处理的,尽管如果MPFR创建时,可以避免使用此类周期,默认值将使用相同的精度来渲染输入
。并不是说您的序列是在OEI中,而是检查与“野外”序列中的序列相似,这并不能反映您的工作流程。
至于使用列表:
因此,这些清单周期已经在MPFR创建中花费了。
以及一些相关的,光读数原始集合来自最近的新闻。
I've likely got this wrong, but using
mprf
objects provides access to base Rintersect
,union
,setdiff
, while asort(...
needs to be wrapped inside amprf(sort(...), 'bits')
:so for these operations
sets
is not necessary, and assuming your workflow is amenable toRmprf
based objects.As the problem is presented in the context of 'precision', one likely wouldn't want a function that promotes or demotes sets to their highest/lowest 'prec', but be intentionally involved in the decision (though, admittedly, I looked for one).
Here, renaming your f3 & f4 below to f7 & f8:
So it appears that 'precision handling' is required as to set operations, though such additional cycles may be avoided if it is plausible that upon mpfr creation, defaults would render the inputs the same precision. Using OEIS as inputs:
Ah, so little in common. And it is probably not that your sequences are in OEIS, rather checking for similarity to those from your sequences 'from the wild', and this doesn't reflect your workflow.
As to using lists:
So those as.list cycles have already been expended in mpfr creation.
And some related, light reading primitive sets from recent news.