public class MathMatrix extends Object
| Constructor and Description |
|---|
MathMatrix(int[][] mat)
create a MathMatrix with cells equal to the values in mat.
|
MathMatrix(int numRows,
int numCols,
int initialVal)
create a MathMatrix of the specified size with all cells set to the intialValue.
|
| Modifier and Type | Method and Description |
|---|---|
MathMatrix |
add(MathMatrix rightHandSide)
implements MathMatrix addition, (this MathMatrix) + rightHandSide.
|
void |
changeElement(int row,
int col,
int newValue)
change the value of one of the cells in this MathMatrix.
|
boolean |
equals(Object rightHandSide)
override equals.
|
MathMatrix |
getTranspose()
accessor: get a transpose of this MathMatrix.
|
int |
getVal(int row,
int col)
get the value of a cell in this MathMatrix.
|
boolean |
isUpperTriangular()
Return true if this MathMatrix is upper triangular.
|
MathMatrix |
multiply(MathMatrix rightHandSide)
implements matrix multiplication, (this MathMatrix) * rightHandSide.
|
int |
numCols()
Get the number of columns.
|
int |
numRows()
Get the number of rows.
|
void |
scale(int factor)
Multiply all elements of this MathMatrix by factor.
|
MathMatrix |
subtract(MathMatrix rightHandSide)
implements MathMatrix subtraction, (this MathMatrix) - rightHandSide.
|
String |
toString()
override toString.
|
public MathMatrix(int[][] mat)
mat - mat !=null, mat.length > 0, mat[0].length > 0,
mat is a rectangular matrixpublic MathMatrix(int numRows,
int numCols,
int initialVal)
numRows - numRows > 0numCols - numCols > 0initialVal - all cells of this Matrix are set to initialValpublic void changeElement(int row,
int col,
int newValue)
row - 0 <= row < numRows()col - 0 <= col < numCols()public int numRows()
public int numCols()
public int getVal(int row,
int col)
row - 0 <= row < numRows()col - 0 <= col < numCols()public MathMatrix add(MathMatrix rightHandSide)
rightHandSide - rightHandSide.numRows() = numRows(), rightHandSide.numCols() = numCols()public MathMatrix subtract(MathMatrix rightHandSide)
rightHandSide - rightHandSide.numRows() = numRows(), rightHandSide.numCols() = numCols()public MathMatrix multiply(MathMatrix rightHandSide)
rightHandSide - rightHandSide.numRows() = numCols()public void scale(int factor)
factor - the value to multipy every cell in this Matrix by.public MathMatrix getTranspose()
public boolean equals(Object rightHandSide)
public String toString()
public boolean isUpperTriangular()