我应该学习Fortran或C ++来扩展R? [英] Should I learn Fortran or C++ to extend R?

查看:156
本文介绍了我应该学习Fortran或C ++来扩展R?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用机器学习与相当大的数据集(他们仍然适合内存),我已经写了一些计算在R,我发现太慢。因此,我想用从R调用的编译代码替换程序的关键部分。我手中的一个示例问题是实现前向后向算法

I work with machine learning with fairly large datasets (they still fit in memory) and I have written some calculations in R which I find to be too slow. Thus I would like to replace the "critical parts" of the program with compiled code that I would call from R. An example problem that I have in hand is implementing the forward-backward algorithm.

我的问题是我应该学习Fortran还是C ++来做这个?我只需要使用数字向量或矩阵。我主要感兴趣的是哪种语言更容易学习和界面从R和我不真的关心哪一个看起来更好的我的简历。

My question is whether I should learn Fortran or C++ to do this? I only need to work with numeric vectors or matrices. I'm mainly interested in which language is easier to learn and interface from R and I don't really care which one looks better on my CV.

我已经阅读了R扩展手册,并通过一些简单的Fortran和C ++代码与内联包播放了一些。我目前的印象是,Fortran95会更容易学习,虽然Rcpp包也看起来很有趣。我目前知道R,Python和Matlab。

I have read the R extensions manual and played a bit with the inline package with some simple Fortran and C++ code. My current impression is that Fortran95 would be simpler to learn, although the Rcpp package also looks very interesting. I currently know R, Python and Matlab.

推荐答案

如果你将自己编写所有代码,语言你喜欢更好,或可以学习更好/更快。虽然 Rcpp 可能会让您在获得R对象到C ++和更容易回到边缘。另外,在0.8.3中最近添加的内容在编译代码中给出了类似于R的矢量表达式。

If you will be writing all the code yourself, then it may depend on which language you like better, or can learn better / faster. Though Rcpp may give you in edge in getting R objects to C++ and back more easily. Also, the most recent additions in 0.8.3 give you R-alike vector expressions in compiled code.

另一方面,如果你计划使用/重用/适应现在的图书馆,那么我会好好看看例如 mloss.org ,看看什么语言为您提供最有用的机器学习库,并指导您的决定。

On the other hand if you plan use / re-use / adapt existing libraries, then I would take a good look at e.g. mloss.org and see what language provides you with the most useful machine learning libraries and have that guide your decision too.

对我来说,C ++提供了非常有用的抽象加上访问一个高质量的代码库。但其他人都满足Fortran。这真的取决于你,并在某种程度上给你周围的人谁能给予支持。

To me, C++ provides rather useful abstractions plus access to an enormous code base of general good quality. But others are content with Fortran. It really depends on you, and to some extend the people around you who can give support.

这篇关于我应该学习Fortran或C ++来扩展R?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆