|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object org.apache.spark.mllib.linalg.DenseMatrix
public class DenseMatrix
Column-major dense matrix. The entry values are stored in a single array of doubles with columns listed in sequence. For example, the following matrix
1.0 2.0
3.0 4.0
5.0 6.0
is stored as [1.0, 3.0, 5.0, 2.0, 4.0, 6.0]
.
param: numRows number of rows
param: numCols number of columns
param: values matrix entries in column major if not transposed or in row major otherwise
param: isTransposed whether the matrix is transposed. If true, values
stores the matrix in
row major.
Constructor Summary | |
---|---|
DenseMatrix(int numRows,
int numCols,
double[] values)
Column-major dense matrix. |
|
DenseMatrix(int numRows,
int numCols,
double[] values,
boolean isTransposed)
|
Method Summary | |
---|---|
double |
apply(int i,
int j)
Gets the (i, j)-th element. |
DenseMatrix |
copy()
Get a deep copy of the matrix. |
static DenseMatrix |
diag(Vector vector)
Generate a diagonal matrix in DenseMatrix format from the supplied values. |
boolean |
equals(Object o)
|
static DenseMatrix |
eye(int n)
Generate an Identity Matrix in DenseMatrix format. |
int |
hashCode()
|
boolean |
isTransposed()
Flag that keeps track whether the matrix is transposed or not. |
int |
numCols()
Number of columns. |
int |
numRows()
Number of rows. |
static DenseMatrix |
ones(int numRows,
int numCols)
Generate a DenseMatrix consisting of ones. |
static DenseMatrix |
rand(int numRows,
int numCols,
java.util.Random rng)
Generate a DenseMatrix consisting of i.i.d. uniform random numbers. |
static DenseMatrix |
randn(int numRows,
int numCols,
java.util.Random rng)
Generate a DenseMatrix consisting of i.i.d. gaussian random numbers. |
SparseMatrix |
toSparse()
Generate a SparseMatrix from the given DenseMatrix . |
DenseMatrix |
transpose()
Transpose the Matrix. |
double[] |
values()
|
static DenseMatrix |
zeros(int numRows,
int numCols)
Generate a DenseMatrix consisting of zeros. |
Methods inherited from class Object |
---|
getClass, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.apache.spark.mllib.linalg.Matrix |
---|
multiply, multiply, multiply, toArray, toString, toString |
Constructor Detail |
---|
public DenseMatrix(int numRows, int numCols, double[] values, boolean isTransposed)
public DenseMatrix(int numRows, int numCols, double[] values)
1.0 2.0
3.0 4.0
5.0 6.0
is stored as [1.0, 3.0, 5.0, 2.0, 4.0, 6.0]
.
numRows
- number of rowsnumCols
- number of columnsvalues
- matrix entries in column majorMethod Detail |
---|
public static DenseMatrix zeros(int numRows, int numCols)
DenseMatrix
consisting of zeros.
numRows
- number of rows of the matrixnumCols
- number of columns of the matrix
DenseMatrix
with size numRows
x numCols
and values of zerospublic static DenseMatrix ones(int numRows, int numCols)
DenseMatrix
consisting of ones.
numRows
- number of rows of the matrixnumCols
- number of columns of the matrix
DenseMatrix
with size numRows
x numCols
and values of onespublic static DenseMatrix eye(int n)
DenseMatrix
format.
n
- number of rows and columns of the matrix
DenseMatrix
with size n
x n
and values of ones on the diagonalpublic static DenseMatrix rand(int numRows, int numCols, java.util.Random rng)
DenseMatrix
consisting of i.i.d.
uniform random numbers.
numRows
- number of rows of the matrixnumCols
- number of columns of the matrixrng
- a random number generator
DenseMatrix
with size numRows
x numCols
and values in U(0, 1)public static DenseMatrix randn(int numRows, int numCols, java.util.Random rng)
DenseMatrix
consisting of i.i.d.
gaussian random numbers.
numRows
- number of rows of the matrixnumCols
- number of columns of the matrixrng
- a random number generator
DenseMatrix
with size numRows
x numCols
and values in N(0, 1)public static DenseMatrix diag(Vector vector)
DenseMatrix
format from the supplied values.
vector
- a Vector
that will form the values on the diagonal of the matrix
DenseMatrix
with size values.length
x values.length
and values
on the diagonalpublic int numRows()
Matrix
numRows
in interface Matrix
public int numCols()
Matrix
numCols
in interface Matrix
public double[] values()
public boolean isTransposed()
Matrix
isTransposed
in interface Matrix
public boolean equals(Object o)
equals
in class Object
public int hashCode()
hashCode
in class Object
public double apply(int i, int j)
Matrix
apply
in interface Matrix
public DenseMatrix copy()
Matrix
copy
in interface Matrix
public DenseMatrix transpose()
Matrix
transpose
in interface Matrix
public SparseMatrix toSparse()
SparseMatrix
from the given DenseMatrix
. The new matrix will have isTransposed
set to false.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |