|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmatrix.Matrix
public class Matrix
An instance of this class represents a matrix of numbers as double values.
Constructor Summary | |
---|---|
Matrix(int rows,
int columns)
Creates a matrix with the indicated numbers of rows and columns. |
Method Summary | |
---|---|
Matrix |
add(Matrix other)
Adds this matrix to another. |
boolean |
equals(java.lang.Object other)
Tests for equality of this matrix with another. |
double |
get(int row,
int column)
Gets the element at the indicated row and column in this matrix. |
int |
getColumns()
Getter for the number of columns in this matrix. |
int |
getRows()
Getter for the number of rows in this matrix. |
Matrix |
multiply(Matrix other)
Multiples this matrix with another. |
void |
set(int row,
int column,
double element)
Sets the element at the indicated row and column in this matrix. |
static Matrix |
toMatrix(java.lang.String string,
int rows,
int columns)
Creates a matrix from a data string. |
java.lang.String |
toString()
Creates a visual representation of this matrix as a string. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Matrix(int rows, int columns)
rows
- the number of rows in the matrixcolumns
- the number of columns in the matrixMethod Detail |
---|
public int getRows()
public int getColumns()
public double get(int row, int column)
row
- the row position for the element.
It must be the case that 0 ≤ row < getRows().column
- the column position for the element.
It must be the case that 0 ≤ column < getColumns().
MatrixException
- if row or column is out of boundspublic void set(int row, int column, double element)
row
- the row position for the element.
It must be the case that 0 ≤ row < getRows().column
- the column position for the element.
It must be the case that 0 ≤ column < getColumns().element
- the value to set in the matrix
MatrixException
- if row or column is out of boundspublic boolean equals(java.lang.Object other)
equals
in class java.lang.Object
other
- the other matrix to be tested for equality with this matrix
public Matrix add(Matrix other)
other
- the other matrix to add
MatrixException
- if this matrix and the other matrix do not
have the same dimensionspublic Matrix multiply(Matrix other)
other
- the other matrix to multiply
MatrixException
- if the number of columns in this matrix does not match
the number of rows in the otherpublic static Matrix toMatrix(java.lang.String string, int rows, int columns) throws java.io.IOException
string
- A string containing blank-separated matrix data
which must parse as double values, or a NumberFormatException will be thrown.
Each row must be terminated by end-of-line character '\n'.rows
- The number of rows in the matrix. If the number of
rows in the data string is not the same, a MatrixException will be thrown.columns
- The number of columns in the matrix. If the number of
columns in the data string is not the same, a MatrixException will be thrown.
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |