Apache Spark 中 RowMatrix 和 Matrix 的区别?

Difference between RowMatrix and Matrix in Apache Spark?

我想知道 Apache Spark 中可用的 RowMatrix 和 Matrix class 之间的基本区别。

这将归结为您正在使用的语言/框架/学科的习语,但在计算机科学中,数组是可以引用的“事物”的一维“列表”根据他们在列表中的位置。可以在列表中的一个东西是另一个数组,它可以让你制作数组的数组(数组的数组......)给你一个任意大维度的数据集。

矩阵来自线性代数,是数据的二维表示(可以用数组的数组表示),它带有一组强大的数学运算,可让您以有趣的方式处理数据。虽然数组的大小可能会有所不同,但矩阵的宽度和高度通常是根据您要执行的特定操作类型知道的。

矩阵在 3d 图形和物理引擎中得到广泛使用,因为它们是表示对象在三维空间中的变换和加速数据的一种快速、方便的方式。

数组:同类元素的集合。

矩阵:一个简单的行和列。

两者是不同空间的不同事物。 但是在计算机编程中,一维数组的集合可以称为矩阵。 您可以以矩阵形式表示二维数组(即一维数组的集合)。

例子

A[2][3] : This means A is a collection of 2 single dimension arrays each of size 3.

A[1,1] A[1,2] A[1,3] //This is a single dimensional array

A[2,1] A[2,2] A[2,3] //This is another single dimensional array

//The collection is a multi-dimensional or 2d Array.

这里更精确一点的问题是 mllib.linalg.Matrixmllib.linalg.distributed.DistributedMatrix 之间的区别是什么。

  • Matrix 是一个特征,表示 局部矩阵 驻留在单个机器的内存中。目前有两个基本实现:DenseMatrixSparseMatrix.
  • DistributedMatrix is a trait which represents distributed matrices build on top of RDD. RowMatrix is a subclass of a DistributedMatrix which stores data in a row-wise manner without meaningful row ordering. There are other implementations of DistributedMatrix (like IndexedRowMatrix, CoordinateMatrix and BlockMatrix) each with its own storage strategy and specific set of methods. See for example