什么是过度阵列使用Ruby NArray的优势是什么? [英] What are the advantages of using Ruby NArray over Array?

查看:139
本文介绍了什么是过度阵列使用Ruby NArray的优势是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对面的NArray库红宝石来到 - 请在问这个问题时,请原谅我的无知:)

I just came across the NArray library for Ruby -- please excuse my ignorance when asking this question :)

什么是使用的NArray库比标准的Ruby数组实现的优势是什么?

What are the advantages of using the NArray library over the standard Ruby Array implementation?

我见过NArray是面向数字计算,而是看API,它看起来像有对数值面向阵列上只有少数几个扩展 - 什么是你不能用数组做..

I've seen that NArray is geared towards numerical computing, but looking at the API, it looks like there are only a few extensions over Array geared towards numerical values -- nothing that you couldn't do with Array..


  1. 为什么不直接使用数组?

  2. 有一个巨大的速度优势?

  3. 有一个巨大的内存优势?

  4. 在使用普通的Ruby Array类?任何其他优点

谷歌并没有真正想出这个问题的一个有用的解释。

Google didn't really come up with a useful explanation of this question.

参考我发现:

<一个href=\"http://rubydoc.info/gems/narray-ruby19/0.5.9.7/NArray\">http://rubydoc.info/gems/narray-ruby19/0.5.9.7/NArray

http://narray.rubyforge.org/index.html.en

http://raa.ruby-lang.org/project/narray/

推荐答案

另请参阅有关NArray幻灯片:
<一href=\"http://www.slideshare.net/masa16tanaka/narray-and-scientific-computing-with-ruby\">http://www.slideshare.net/masa16tanaka/narray-and-scientific-computing-with-ruby

See also the slide about NArray: http://www.slideshare.net/masa16tanaka/narray-and-scientific-computing-with-ruby

它看起来像有只对数组了一些扩展

it looks like there are only a few extensions over Array

没有,这是一个从阵列完全不同。
NArray有许多数值函数和多维特征。
另一方面,NArray是静态的;它不具有压入/弹出方法等
NArray的方法列表是 http://narray.rubyforge.org/SPEC.en

No, it's completely different from Array. NArray has many numerical functions and multi-dimensional features. On the other hand, NArray is static; it does not have push/pop methods, etc. NArray's method list is http://narray.rubyforge.org/SPEC.en

_1。为什么不直接使用数组?

_1. Why not just use Array?

数组保存Ruby对象。这是一种低效持有数值。

Array holds Ruby Objects. It is inefficient to hold numerical values.

_2。是否有一个巨大的速度优势?

_2. Is there a huge speed advantage?

是的。以上幻灯片显示第36页是NArray快达50倍。

Yes. p.36 of the above slide shows NArray is up to 50 times faster.

注意数组比NArray更快,如果循环用Ruby编写的。

Note that Array is faster than NArray if the loop is written in Ruby.

_3。是否有一个巨大的内存优势在哪里?

_3. Is there a huge memory advantage?

是的。对于浮点值,阵列消耗约4倍NArray更多的内存,64位我的Linux机器上。

Yes. As for Float values, Array consumes about 4 times more memory than NArray on my 64bit Linux machine.

_4。在使用普通的Ruby Array类的任何其他好处?

_4. Any other advantages over using the regular Ruby Array class?


  • 多维数组的支持

  • 数值功能支持

  • 无需对数组项垃圾收集。 GC花费大量时间用于大型阵列。


这篇关于什么是过度阵列使用Ruby NArray的优势是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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