|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectMathMatrix
public class MathMatrix
A class that models systems of linear equations (Math Matrices) as used in linear algebra.
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
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 initialValMethod Detail |
---|
public 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)
equals
in class Object
public String toString()
toString
in class Object
public boolean isUpperTriangular()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |