public abstract class RandomMatrix extends GenericMatrix
getMatrixOfSameType(int, int)
. For this reason, it will return a
DenseMatrix
so that use cases of the given method do not break, and
can return new - altered - matrices.NB2
Constructor and Description |
---|
RandomMatrix(int rows,
int cols)
Creates a new random matrix object
|
RandomMatrix(int rows,
int cols,
long seedMult)
Creates a new random matrix object
|
RandomMatrix(RandomMatrix toCopy)
Copy constructor
|
Modifier and Type | Method and Description |
---|---|
boolean |
canBeMutated()
Indicates whether or not this matrix can be mutated.
|
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.
|
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
|
protected abstract double |
getVal(Random rand)
Computes the value of an index given the already initialized
Random object. |
boolean |
isSparce()
Returns
true if the matrix is sparse, false otherwise |
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
|
clone, lup, lup, multiply, multiply, multiply, multiplyTranspose, multiplyTranspose, mutableAdd, mutableAdd, mutableAdd, mutableAdd, mutableMultiply, mutableMultiply, mutableTranspose, qr, qr, swapRows, transpose, transposeMultiply, transposeMultiply, transposeMultiply, zeroOut
add, add, add, add, canMultiply, copyTo, diag, diagMult, diagMult, equals, equals, eye, getColumn, getColumnView, getRow, getRowView, 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, transpose, transposeMultiply, transposeMultiply, transposeMultiply, updateRow
public RandomMatrix(int rows, int cols)
rows
- the number of rows for the random matrixcols
- the number of columns for the random matrixpublic RandomMatrix(int rows, int cols, long seedMult)
rows
- the number of rows for the random matrixcols
- the number of columns for the random matrixseedMult
- a value to multiply with the seed used for each
individual index. It should be a large valuepublic RandomMatrix(RandomMatrix toCopy)
toCopy
- the object 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 haveprotected abstract double getVal(Random rand)
Random
object. This is called by the get(int, int)
method, and will make sure that the correct seed is set before calling
this method.rand
- the PRNG to generate the index value frompublic 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 boolean canBeMutated()
Matrix
false
, any method that contains "mutate" will not work.
true
canBeMutated
in class Matrix
true
if the matrix supports being altered, false
other wise.public 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.Copyright © 2017. All rights reserved.