public class MatrixOfVecs extends GenericMatrix
Vec
objects. The vector objects will be used to back the rows of the
matrix, so changes to one are shown in the other. If the matirx is altered
using changeSize(int, int)
, this may no longer be true. NB2
Constructor and Description |
---|
MatrixOfVecs(int rows,
int cols,
boolean sparse)
Creates a new Matrix of Vecs of the desired size.
|
MatrixOfVecs(List<Vec> rows)
Creates a new Matrix of Vecs from the given list of Vec objects.
|
MatrixOfVecs(Vec... rows)
Creates a new Matrix of Vecs from the given array of Vec objects.
|
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.
|
MatrixOfVecs |
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.
|
void |
increment(int i,
int j,
double value)
Alters the current matrix at index (i,j) to be equal to
Ai,j = Ai,j + value
|
boolean |
isSparce()
Returns
true if the matrix is sparse, false otherwise |
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)
Alters the current matrix to store the value A+c
|
void |
mutableMultiply(double c)
Alters the current matrix to be equal to A*c
|
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 |
updateRow(int i,
double c,
Vec b)
Alters row i of this matrix, such that
A[i,:] = A[i,:] + c*b
|
void |
zeroOut()
Alters the current matrix so that all values are equal to zero.
|
lup, lup, multiply, multiply, multiplyTranspose, multiplyTranspose, mutableAdd, mutableAdd, mutableAdd, mutableMultiply, mutableTranspose, qr, qr, swapRows, transpose, transposeMultiply, transposeMultiply, transposeMultiply
add, add, add, add, canBeMutated, canMultiply, copyTo, diag, diagMult, diagMult, equals, equals, eye, getColumn, getColumnView, getRow, 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, transpose, transposeMultiply, transposeMultiply, transposeMultiply
public MatrixOfVecs(Vec... rows)
rows
- the rows of vecs to make this matrix.public MatrixOfVecs(List<Vec> rows)
rows
- the rows of vecs to make this matrix.public MatrixOfVecs(int rows, int cols, boolean sparse)
rows
- the number of rows in the matrixcols
- the number of columns in the matrixsparse
- if true
SparseVector
objects will be used
for the rows. Else DenseVector
will be used.protected 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 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 double get(int i, int j)
Matrix
public void set(int i, int j, double value)
Matrix
public void increment(int i, int j, double value)
Matrix
public int rows()
Matrix
public int cols()
Matrix
public Vec getRowView(int r)
Matrix
getRowView
in class Matrix
r
- the row to obtain a view ofpublic void updateRow(int i, double c, Vec b)
Matrix
public 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 mutableMultiply(double c)
Matrix
mutableMultiply
in class GenericMatrix
c
- the scalar constant to multiply bypublic void mutableAdd(double c)
Matrix
mutableAdd
in class GenericMatrix
c
- the scalar constant to add to thispublic void zeroOut()
Matrix
zeroOut
in class GenericMatrix
public MatrixOfVecs clone()
clone
in class GenericMatrix
Copyright © 2017. All rights reserved.