public class DenseMatrix extends GenericMatrix
NB2
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 zeros
|
DenseMatrix(Matrix toCopy)
Creates a new dense matrix that has a copy of all the same values as the
given one
|
DenseMatrix(Vec a,
Vec b)
Creates a new matrix based off the given vectors.
|
Modifier and Type | Method and Description |
---|---|
void |
changeSize(int newRows,
int newCols)
This method alters the size of a matrix, either adding or subtracting
rows from the internal structure of the matrix.
|
DenseMatrix |
clone() |
int |
cols()
Returns the number of columns stored in this matrix
|
double |
get(int i,
int j)
Returns the value stored at at the matrix position Ai,j
|
protected Matrix |
getMatrixOfSameType(int rows,
int cols)
Creates a new matrix of the same type
|
Vec |
getRowView(int r)
Obtains a vector that is backed by this, at very little memory
cost.
|
boolean |
isSparce()
Returns
true if the matrix is sparse, false otherwise |
Matrix[] |
lup() |
Matrix[] |
lup(ExecutorService threadPool) |
void |
multiply(Matrix b,
Matrix C)
Alters the matrix C to be equal to C = C+A*B
|
void |
multiply(Matrix b,
Matrix C,
ExecutorService threadPool)
Alters the matrix C to be equal to C = C+A*B
|
void |
multiply(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*z
|
void |
mutableAdd(double c,
Matrix b)
Alters the current matrix to store the value A+c*B
|
void |
mutableMultiply(double c)
Alters the current matrix to be equal to A*c
|
void |
mutableTranspose()
Transposes the current matrix in place, altering its value.
|
Matrix[] |
qr() |
Matrix[] |
qr(ExecutorService threadPool) |
int |
rows()
Returns the number of rows stored in this matrix
|
void |
set(int i,
int j,
double value)
Sets the value stored at at the matrix position Ai,j
|
void |
swapRows(int r1,
int r2)
Alters the current matrix by swapping the values stored in two different
rows.
|
DenseMatrix |
transpose()
Returns a new matrix that is the transpose of this matrix.
|
void |
transpose(Matrix C)
Overwrites the values stored in matrix C to store the value of
A'
|
void |
transposeMultiply(double c,
Vec b,
Vec x)
Alters the vector x to be equal to x = x + A'*b*c
|
void |
transposeMultiply(Matrix b,
Matrix C)
Alters the matrix C so that C = C + A'*B
|
void |
transposeMultiply(Matrix b,
Matrix C,
ExecutorService threadPool)
Alters the matrix C so that C = C + A'*B
|
void |
zeroOut()
Alters the current matrix so that all values are equal to zero.
|
multiplyTranspose, multiplyTranspose, mutableAdd, mutableAdd, mutableAdd, mutableMultiply
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
public DenseMatrix(Vec a, Vec b)
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 vectorpublic DenseMatrix(int rows, int cols)
rows
- the number of rowscols
- the number of columnspublic DenseMatrix(double[][] matrix)
matrix
- the matrix to clone the values ofpublic DenseMatrix(Matrix toCopy)
toCopy
- the matrix to copyprotected Matrix getMatrixOfSameType(int rows, int cols)
GenericMatrix
getMatrixOfSameType
in class GenericMatrix
rows
- the number of rows for the matrix to havecols
- the number of columns for the matrix to havepublic void mutableAdd(double c, Matrix b)
Matrix
mutableAdd
in class GenericMatrix
c
- the scalar constant to multiple B byb
- the matrix to add to thispublic void multiply(Vec b, double z, Vec c)
Matrix
multiply
in class GenericMatrix
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 additionpublic void transposeMultiply(double c, Vec b, Vec x)
Matrix
transposeMultiply
in class GenericMatrix
c
- the scalar constant to multiply byb
- the vector to multiply byx
- the vector the add the result topublic void changeSize(int newRows, int newCols)
Matrix
changeSize
in class Matrix
newRows
- the new number of rows, must be positivenewCols
- the new number of columns, must be positive.public void transposeMultiply(Matrix b, Matrix C)
Matrix
transposeMultiply
in class GenericMatrix
b
- the matrix to multiply byC
- the matrix to add the result topublic void transposeMultiply(Matrix b, Matrix C, ExecutorService threadPool)
Matrix
transposeMultiply
in class GenericMatrix
b
- the matrix to multiply byC
- the matrix to place the results inthreadPool
- the source of threads to do computation in parallelpublic void multiply(Matrix b, Matrix C)
Matrix
multiply
in class GenericMatrix
b
- the matrix to multiply this withC
- the matrix to add the result topublic void multiply(Matrix b, Matrix C, ExecutorService threadPool)
Matrix
multiply
in class GenericMatrix
b
- the matrix to multiply this withC
- the matrix to add the result tothreadPool
- the source of threads to do computation in parallelpublic void mutableMultiply(double c)
Matrix
mutableMultiply
in class GenericMatrix
c
- the scalar constant to multiply bypublic void mutableTranspose()
Matrix
mutableTranspose
in class GenericMatrix
public DenseMatrix transpose()
Matrix
public void transpose(Matrix C)
Matrix
transpose
in class GenericMatrix
C
- the matrix to store the transpose of the current matrixpublic double get(int i, int j)
Matrix
public void set(int i, int j, double value)
Matrix
public int rows()
Matrix
public int cols()
Matrix
public boolean isSparce()
Matrix
true
if the matrix is sparse, false
otherwisepublic void swapRows(int r1, int r2)
Matrix
swapRows
in class GenericMatrix
r1
- the first row to swapr2
- the second row to swappublic void zeroOut()
Matrix
zeroOut
in class GenericMatrix
public Vec getRowView(int r)
Matrix
getRowView
in class Matrix
r
- the row to obtain a view ofpublic Matrix[] lup()
lup
in class GenericMatrix
public Matrix[] lup(ExecutorService threadPool)
lup
in class GenericMatrix
public Matrix[] qr()
qr
in class GenericMatrix
public Matrix[] qr(ExecutorService threadPool)
qr
in class GenericMatrix
public DenseMatrix clone()
clone
in class GenericMatrix
Copyright © 2017. All rights reserved.