jsat.linear
Class DenseMatrix
- java.lang.Object
-
- jsat.linear.Matrix
-
- jsat.linear.GenericMatrix
-
- jsat.linear.DenseMatrix
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable
public class DenseMatrix extends GenericMatrix
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description DenseMatrix(double[][] matrix)Creates a new matrix that is a clone of the given matrix.DenseMatrix(int rows, int cols)Creates a new matrix of zerosDenseMatrix(Matrix toCopy)Creates a new dense matrix that has a copy of all the same values as the given oneDenseMatrix(Vec a, Vec b)Creates a new matrix based off the given vectors.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidchangeSize(int newRows, int newCols)This method alters the size of a matrix, either adding or subtracting rows from the internal structure of the matrix.DenseMatrixclone()intcols()Returns the number of columns stored in this matrixdoubleget(int i, int j)Returns the value stored at at the matrix position Ai,jVecgetRowView(int r)Obtains a vector that is backed by this, at very little memory cost.booleanisSparce()Returnstrueif the matrix is sparse,falseotherwiseMatrix[]lup()Matrix[]lup(java.util.concurrent.ExecutorService threadPool)voidmultiply(Matrix b, Matrix C)Alters the matrix C to be equal to C = C+A*Bvoidmultiply(Matrix b, Matrix C, java.util.concurrent.ExecutorService threadPool)Alters the matrix C to be equal to C = C+A*Bvoidmultiply(Vec b, double z, Vec c)If this matrix is Am x n, and b has a length of n, and c has a length of m, then this will mutate c to store c = c + A*b*zvoidmutableAdd(double c, Matrix b)Alters the current matrix to store the value A+c*BvoidmutableMultiply(double c)Alters the current matrix to be equal to A*cvoidmutableTranspose()Transposes the current matrix in place, altering its value.Matrix[]qr()Matrix[]qr(java.util.concurrent.ExecutorService threadPool)introws()Returns the number of rows stored in this matrixvoidset(int i, int j, double value)Sets the value stored at at the matrix position Ai,jvoidswapRows(int r1, int r2)Alters the current matrix by swapping the values stored in two different rows.DenseMatrixtranspose()Returns a new matrix that is the transpose of this matrix.voidtranspose(Matrix C)Overwrites the values stored in matrix C to store the value of A'voidtransposeMultiply(double c, Vec b, Vec x)Alters the vector x to be equal to x = x + A'*b*cvoidtransposeMultiply(Matrix b, Matrix C)Alters the matrix C so that C = C + A'*BvoidtransposeMultiply(Matrix b, Matrix C, java.util.concurrent.ExecutorService threadPool)Alters the matrix C so that C = C + A'*BvoidzeroOut()Alters the current matrix so that all values are equal to zero.-
Methods inherited from class jsat.linear.GenericMatrix
multiplyTranspose, multiplyTranspose, mutableAdd, mutableAdd, mutableAdd, mutableMultiply
-
Methods inherited from class jsat.linear.Matrix
add, add, add, add, canBeMutated, canMultiply, copyTo, diag, diagMult, diagMult, equals, equals, eye, getColumn, getColumnView, getRow, increment, isSquare, isSymmetric, isSymmetric, multiply, multiply, multiply, multiply, multiply, multiplyTranspose, multiplyTranspose, mutableAdd, mutableAdd, mutableSubtract, mutableSubtract, mutableSubtract, mutableSubtract, mutableSubtract, mutableSubtract, nnz, OuterProductUpdate, OuterProductUpdate, pascal, random, sameDimensions, subtract, subtract, subtract, subtract, toString, transposeMultiply, transposeMultiply, transposeMultiply, updateRow
-
-
-
-
Constructor Detail
-
DenseMatrix
public DenseMatrix(Vec a, Vec b)
Creates a new matrix based off the given vectors.- Parameters:
a- the first Vector, this new Matrix will have as many rows as the length of this vectorb- the second Vector, this new Matrix will have as many columns as this length of this vector
-
DenseMatrix
public DenseMatrix(int rows, int cols)Creates a new matrix of zeros- Parameters:
rows- the number of rowscols- the number of columns
-
DenseMatrix
public DenseMatrix(double[][] matrix)
Creates a new matrix that is a clone of the given matrix. An error will be throw if the rows of the given matrix are not all the same size- Parameters:
matrix- the matrix to clone the values of
-
DenseMatrix
public DenseMatrix(Matrix toCopy)
Creates a new dense matrix that has a copy of all the same values as the given one- Parameters:
toCopy- the matrix to copy
-
-
Method Detail
-
mutableAdd
public void mutableAdd(double c, Matrix b)Description copied from class:MatrixAlters the current matrix to store the value A+c*B- Overrides:
mutableAddin classGenericMatrix- Parameters:
c- the scalar constant to multiple B byb- the matrix to add to this
-
multiply
public void multiply(Vec b, double z, Vec c)
Description copied from class:MatrixIf this matrix is Am x n, and b has a length of n, and c has a length of m, then this will mutate c to store c = c + A*b*z- Overrides:
multiplyin classGenericMatrix- Parameters:
b- the vector to be treated as a colum vectorz- the constant to multiply the A*b value by.c- where to place the result by addition
-
transposeMultiply
public void transposeMultiply(double c, Vec b, Vec x)Description copied from class:MatrixAlters the vector x to be equal to x = x + A'*b*c- Overrides:
transposeMultiplyin classGenericMatrix- Parameters:
c- the scalar constant to multiply byb- the vector to multiply byx- the vector the add the result to
-
changeSize
public void changeSize(int newRows, int newCols)Description copied from class:MatrixThis method alters the size of a matrix, either adding or subtracting rows from the internal structure of the matrix. Every resize call may cause a new allocation internally, and should not be called for excessive changing of a matrix. All added rows/ columns will have values of zero. If a row / column is removed, it is always the bottom/right most row / column removed. Values of the removed rows / columns will be lost.- Specified by:
changeSizein classMatrix- Parameters:
newRows- the new number of rows, must be positivenewCols- the new number of columns, must be positive.
-
transposeMultiply
public void transposeMultiply(Matrix b, Matrix C)
Description copied from class:MatrixAlters the matrix C so that C = C + A'*B- Overrides:
transposeMultiplyin classGenericMatrix- Parameters:
b- the matrix to multiply byC- the matrix to add the result to
-
transposeMultiply
public void transposeMultiply(Matrix b, Matrix C, java.util.concurrent.ExecutorService threadPool)
Description copied from class:MatrixAlters the matrix C so that C = C + A'*B- Overrides:
transposeMultiplyin classGenericMatrix- Parameters:
b- the matrix to multiply byC- the matrix to place the results inthreadPool- the source of threads to do computation in parallel
-
multiply
public void multiply(Matrix b, Matrix C)
Description copied from class:MatrixAlters the matrix C to be equal to C = C+A*B- Overrides:
multiplyin classGenericMatrix- Parameters:
b- the matrix to multiply this withC- the matrix to add the result to
-
multiply
public void multiply(Matrix b, Matrix C, java.util.concurrent.ExecutorService threadPool)
Description copied from class:MatrixAlters the matrix C to be equal to C = C+A*B- Overrides:
multiplyin classGenericMatrix- Parameters:
b- the matrix to multiply this withC- the matrix to add the result tothreadPool- the source of threads to do computation in parallel
-
mutableMultiply
public void mutableMultiply(double c)
Description copied from class:MatrixAlters the current matrix to be equal to A*c- Overrides:
mutableMultiplyin classGenericMatrix- Parameters:
c- the scalar constant to multiply by
-
mutableTranspose
public void mutableTranspose()
Description copied from class:MatrixTransposes the current matrix in place, altering its value. Only valid for square matrices- Overrides:
mutableTransposein classGenericMatrix
-
transpose
public DenseMatrix transpose()
Description copied from class:MatrixReturns a new matrix that is the transpose of this matrix.
-
transpose
public void transpose(Matrix C)
Description copied from class:MatrixOverwrites the values stored in matrix C to store the value of A'- Overrides:
transposein classGenericMatrix- Parameters:
C- the matrix to store the transpose of the current matrix
-
get
public double get(int i, int j)Description copied from class:MatrixReturns the value stored at at the matrix position Ai,j
-
set
public void set(int i, int j, double value)Description copied from class:MatrixSets the value stored at at the matrix position Ai,j
-
rows
public int rows()
Description copied from class:MatrixReturns the number of rows stored in this matrix
-
cols
public int cols()
Description copied from class:MatrixReturns the number of columns stored in this matrix
-
isSparce
public boolean isSparce()
Description copied from class:MatrixReturnstrueif the matrix is sparse,falseotherwise
-
swapRows
public void swapRows(int r1, int r2)Description copied from class:MatrixAlters the current matrix by swapping the values stored in two different rows.- Overrides:
swapRowsin classGenericMatrix- Parameters:
r1- the first row to swapr2- the second row to swap
-
zeroOut
public void zeroOut()
Description copied from class:MatrixAlters the current matrix so that all values are equal to zero.- Overrides:
zeroOutin classGenericMatrix
-
getRowView
public Vec getRowView(int r)
Description copied from class:MatrixObtains a vector that is backed by this, at very little memory cost. Mutations to this vector will alter the values stored in the matrix, and vice versa.- Overrides:
getRowViewin classMatrix- Parameters:
r- the row to obtain a view of- Returns:
- a vector backed by the specified row of the matrix
-
lup
public Matrix[] lup()
- Overrides:
lupin classGenericMatrix
-
lup
public Matrix[] lup(java.util.concurrent.ExecutorService threadPool)
- Overrides:
lupin classGenericMatrix
-
qr
public Matrix[] qr()
- Overrides:
qrin classGenericMatrix
-
qr
public Matrix[] qr(java.util.concurrent.ExecutorService threadPool)
- Overrides:
qrin classGenericMatrix
-
clone
public DenseMatrix clone()
- Overrides:
clonein classGenericMatrix
-
-
DataMelt 3.0 © DataMelt by jWork.ORG