Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby core Matrix vs NArray';s N矩阵_Ruby_Arrays_Math_Vector_Matrix - Fatal编程技术网

Ruby core Matrix vs NArray';s N矩阵

Ruby core Matrix vs NArray';s N矩阵,ruby,arrays,math,vector,matrix,Ruby,Arrays,Math,Vector,Matrix,我发现Ruby中似乎有三个矩阵模块 :似乎是核心Ruby的一部分 :NMatrix是NArray库()的一部分 :红宝石的一部分 目前看来,NArray的NMatrix比Matrix更快,有一些更有用的方法,但需要更多的设置 有没有人有这两方面的经验,能大致概括一下为什么我应该使用其中一个而不是另一个呢?现在只是在这个问题上结结巴巴地问了一下。。。你已经7个月没问了,所以我相信你现在已经找到答案了 但是,请查找相关信息 基本上,core Matrix类的作者没有添加方法来在数组实例化后对其执

我发现Ruby中似乎有三个矩阵模块

  • :似乎是核心Ruby的一部分
  • :NMatrix是NArray库()的一部分
  • :红宝石的一部分
目前看来,
NArray
NMatrix
Matrix
更快,有一些更有用的方法,但需要更多的设置


有没有人有这两方面的经验,能大致概括一下为什么我应该使用其中一个而不是另一个呢?

现在只是在这个问题上结结巴巴地问了一下。。。你已经7个月没问了,所以我相信你现在已经找到答案了

但是,请查找相关信息

基本上,core Matrix类的作者没有添加方法来在数组实例化后对其执行运行时修改。类允许这样做


至于计算时间,我将把它留给其他人,因为我不知道。

球赛有点晚了,但是你看过新的NMatrix gem吗?它的灵感来自纳雷。它也是用C/C++编写的,而Ruby Matrix只用Ruby编写,所以NMatrix肯定更快

对于NArray也是如此,它是C-only

使用NMatrix而不是
NArray::NMatrix
的优点是,您可以在不同的存储类型(稀疏、密集等)之间进行选择。

对于JRuby,它与MRI不兼容,因为它使用Java编写的Colt库(不过,比较所有这些库可能会很有趣)。