public class SquareMatrix extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private int |
dimension
The dimension is the number of rows and
columns in this square matrix.
|
private double[][] |
elements
This matrix stores the floating point values of its
elements in a two dimensional array.
|
Constructor and Description |
---|
SquareMatrix(int dimension)
Create a square matrix that has a given number of
rows and columns, with all elements equal to zero.
|
Modifier and Type | Method and Description |
---|---|
SquareMatrix |
copy()
Create another matrix that is equal to this one.
|
int |
getDimension()
Retrieve the dimension of this matrix.
|
double |
getElement(int row,
int column)
Retrieve the value of the element of this
matrix that is at the specified position.
|
static void |
main(java.lang.String[] args) |
SquareMatrix |
multiply(SquareMatrix m)
Create a new matrix that is the product
of this matrix and another given matrix.
|
SquareMatrix |
power(int exponent)
Compute a matrix that is equal to this matrix
raised to a given integer power.
|
void |
setElement(int row,
int column,
double value)
Change the value of a specified element of this
matrix.
|
void |
setToIdentity()
Set the values of the elements of this matrix
to make an identity matrix.
|
void |
setToPDFs()
Set the values of the elements of this matrix
to make rows that represent PDFs.
|
SquareMatrix |
square()
Compute the product of this matrix with itself.
|
java.lang.String |
toString()
Create a printable representation of this matrix.
|
private final int dimension
private final double[][] elements
public SquareMatrix(int dimension)
dimension
- is the number of rows and columns.public final int getDimension()
public final double getElement(int row, int column)
row
- column
- public final void setElement(int row, int column, double value)
row
- column
- value
- is the new value to be assigned to the element
at (row, column).public java.lang.String toString()
toString
in class java.lang.Object
public SquareMatrix copy()
public void setToIdentity()
public void setToPDFs()
public SquareMatrix multiply(SquareMatrix m)
m
- is the other matrix.public SquareMatrix square()
public SquareMatrix power(int exponent)
exponent
- is the power to which the method
raises this matrix.public static void main(java.lang.String[] args)