class Spark::Mllib::SparseMatrix
Arguments:¶ ↑
- rows
-
Number of rows.
- cols
-
Number of columns.
col_pointers
-
The index corresponding to the start of a new column.
row_indices
-
The row index of the entry. They must be in strictly increasing order for each column.
- values
-
Nonzero matrix entries in column major.
Examples:¶ ↑
SparseMatrix.new(3, 3, [0, 2, 3, 6], [0, 2, 1, 0, 1, 2], [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]).values # => [ # [1.0, 0.0, 4.0], # [0.0, 3.0, 5.0], # [2.0, 0.0, 6.0] # ]
Attributes
col_pointers[R]
row_indices[R]
Public Class Methods
new(rows, cols, col_pointers, row_indices, values)
click to toggle source
Calls superclass method
# File lib/spark/mllib/matrix.rb, line 99 def initialize(rows, cols, col_pointers, row_indices, values) super(:sparse, rows, cols) @col_pointers = col_pointers @row_indices = row_indices @values = values j = 0 while j < cols idx = col_pointers[j] idx_end = col_pointers[j+1] while idx < idx_end self[row_indices[idx], j] = values[idx] idx += 1 end j += 1 end end