Package org.apache.spark.mllib.linalg
Class Matrices
Object
org.apache.spark.mllib.linalg.Matrices
Factory methods for 
Matrix.- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic Matrixdense(int numRows, int numCols, double[] values) Creates a column-major dense matrix.static MatrixGenerate a diagonal matrix inMatrixformat from the supplied values.static Matrixeye(int n) Generate a dense Identity Matrix inMatrixformat.static MatrixConvert new linalg type to spark.mllib type.static MatrixHorizontally concatenate a sequence of matrices.static Matrixones(int numRows, int numCols) Generate aDenseMatrixconsisting of ones.static MatrixGenerate aDenseMatrixconsisting ofi.i.d.uniform random numbers.static MatrixGenerate aDenseMatrixconsisting ofi.i.d.gaussian random numbers.static Matrixsparse(int numRows, int numCols, int[] colPtrs, int[] rowIndices, double[] values) Creates a column-major sparse matrix in Compressed Sparse Column (CSC) format.static Matrixspeye(int n) Generate a sparse Identity Matrix inMatrixformat.static MatrixGenerate aSparseMatrixconsisting ofi.i.d.uniform random numbers.static MatrixGenerate aSparseMatrixconsisting ofi.i.d.gaussian random numbers.static MatrixVertically concatenate a sequence of matrices.static Matrixzeros(int numRows, int numCols) Generate aMatrixconsisting of zeros.
- 
Constructor Details- 
Matricespublic Matrices()
 
- 
- 
Method Details- 
denseCreates a column-major dense matrix.- Parameters:
- numRows- number of rows
- numCols- number of columns
- values- matrix entries in column major
- Returns:
- (undocumented)
 
- 
sparsepublic static Matrix sparse(int numRows, int numCols, int[] colPtrs, int[] rowIndices, double[] values) Creates a column-major sparse matrix in Compressed Sparse Column (CSC) format.- Parameters:
- numRows- number of rows
- numCols- number of columns
- colPtrs- the index corresponding to the start of a new column
- rowIndices- the row index of the entry
- values- non-zero matrix entries in column major
- Returns:
- (undocumented)
 
- 
zerosGenerate aMatrixconsisting of zeros.- Parameters:
- numRows- number of rows of the matrix
- numCols- number of columns of the matrix
- Returns:
- Matrixwith size- numRowsx- numColsand values of zeros
 
- 
onesGenerate aDenseMatrixconsisting of ones.- Parameters:
- numRows- number of rows of the matrix
- numCols- number of columns of the matrix
- Returns:
- Matrixwith size- numRowsx- numColsand values of ones
 
- 
eyeGenerate a dense Identity Matrix inMatrixformat.- Parameters:
- n- number of rows and columns of the matrix
- Returns:
- Matrixwith size- nx- nand values of ones on the diagonal
 
- 
speyeGenerate a sparse Identity Matrix inMatrixformat.- Parameters:
- n- number of rows and columns of the matrix
- Returns:
- Matrixwith size- nx- nand values of ones on the diagonal
 
- 
randGenerate aDenseMatrixconsisting ofi.i.d.uniform random numbers.- Parameters:
- numRows- number of rows of the matrix
- numCols- number of columns of the matrix
- rng- a random number generator
- Returns:
- Matrixwith size- numRowsx- numColsand values in U(0, 1)
 
- 
sprandGenerate aSparseMatrixconsisting ofi.i.d.uniform random numbers.- Parameters:
- numRows- number of rows of the matrix
- numCols- number of columns of the matrix
- density- the desired density for the matrix
- rng- a random number generator
- Returns:
- Matrixwith size- numRowsx- numColsand values in U(0, 1)
 
- 
randnGenerate aDenseMatrixconsisting ofi.i.d.gaussian random numbers.- Parameters:
- numRows- number of rows of the matrix
- numCols- number of columns of the matrix
- rng- a random number generator
- Returns:
- Matrixwith size- numRowsx- numColsand values in N(0, 1)
 
- 
sprandnGenerate aSparseMatrixconsisting ofi.i.d.gaussian random numbers.- Parameters:
- numRows- number of rows of the matrix
- numCols- number of columns of the matrix
- density- the desired density for the matrix
- rng- a random number generator
- Returns:
- Matrixwith size- numRowsx- numColsand values in N(0, 1)
 
- 
diagGenerate a diagonal matrix inMatrixformat from the supplied values.- Parameters:
- vector- a- Vectorthat will form the values on the diagonal of the matrix
- Returns:
- Square Matrixwith sizevalues.lengthxvalues.lengthandvalueson the diagonal
 
- 
horzcatHorizontally concatenate a sequence of matrices. The returned matrix will be in the format the matrices are supplied in. Supplying a mix of dense and sparse matrices will result in a sparse matrix. If the Array is empty, an emptyDenseMatrixwill be returned.- Parameters:
- matrices- array of matrices
- Returns:
- a single Matrixcomposed of the matrices that were horizontally concatenated
 
- 
vertcatVertically concatenate a sequence of matrices. The returned matrix will be in the format the matrices are supplied in. Supplying a mix of dense and sparse matrices will result in a sparse matrix. If the Array is empty, an emptyDenseMatrixwill be returned.- Parameters:
- matrices- array of matrices
- Returns:
- a single Matrixcomposed of the matrices that were vertically concatenated
 
- 
fromMLConvert new linalg type to spark.mllib type. Light copy; only copies references- Parameters:
- m- (undocumented)
- Returns:
- (undocumented)
 
 
-