public class SquareMatrix
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Class and Description |
---|---|
static class |
SquareMatrix.Calculation
Enumeration of the possible ways of calculating the matrix exponential
|
class |
SquareMatrix.SquareMatrixException
Exception thrown when there is a problem with a SquareMatrix operation
|
Constructor and Description |
---|
SquareMatrix(double[][] m)
Default constructor
|
Modifier and Type | Method and Description |
---|---|
SquareMatrix |
add(SquareMatrix o)
Adds a matrix to this one and returns a new matrix as the result
|
SquareMatrix |
divide(SquareMatrix B)
Divides this matrix by another (this / B) and returns a new matrix as the
result
|
double[] |
eigValues()
Calculates the Eigenvalues.
|
SquareMatrix |
eigValuesDiag()
Calculates the Eigenvalues.
|
SquareMatrix |
eigVectors()
Calculates the Eigenvectors.
|
boolean |
equals(java.lang.Object ob) |
SquareMatrix |
exp()
Calculates e^A where A is the current matrix and returns a new matrix as
the result
|
SquareMatrix |
expMult(double x)
Calculates e^Ax where A is this matrix and returns a new matrix as the result.
|
double[][] |
getArray()
Gets the matrix as an array of doubles
|
double |
getPosition(int i,
int j)
Returns the value in position (i,j) of the matrix
|
int |
hashCode() |
SquareMatrix |
inverse()
Calculates the inverse of this matrix and returns a new matrix as the result.
|
SquareMatrix |
multiply(SquareMatrix o)
Multiplies this matrix by another (this × o) and returns a new
matrix as a result
|
double |
norm()
Calculates the maximum absolute column sum norm
|
SquareMatrix |
scalarDivide(double n)
Divides the matrix by a scalar and returns a new matrix as the result
|
SquareMatrix |
scalarMultiply(double n)
Multiplies the matrix by a scalar and returns a new matrix as the result
|
static void |
setExpMethod(SquareMatrix.Calculation i)
Sets the method to be used for Exponentiation
|
static void |
setForce(int f)
Sets the minimum number of repeating squaring that will be performed
when using the Taylor method
|
static void |
setNoThreads(int number)
Sets the number of threads to be used when doing matrix multiplication
|
int |
size()
Gets the size of the matrix.
|
SquareMatrix |
square()
Sqaures the matrix and returns a new Matrix that is the result
|
java.lang.String |
toString() |
SquareMatrix |
transpose()
Transposes the matrix and returns a new matrix as the result
|
public SquareMatrix(double[][] m) throws SquareMatrix.SquareMatrixException
m
- Array representing the matrixSquareMatrix.SquareMatrixException
- Thrown if the input array isn't squarepublic SquareMatrix square()
public SquareMatrix scalarMultiply(double n)
n
- The scalar to multiply bypublic SquareMatrix scalarDivide(double n)
n
- The scalar to divide bypublic SquareMatrix add(SquareMatrix o) throws SquareMatrix.SquareMatrixException
o
- The matrix to addSquareMatrix.SquareMatrixException
- Thrown if the matrices are not the same sizepublic SquareMatrix multiply(SquareMatrix o) throws SquareMatrix.SquareMatrixException
o
- The matrix to multiply bySquareMatrix.SquareMatrixException
- Thrown if the matrices are not the same sizepublic SquareMatrix expMult(double x) throws SquareMatrix.SquareMatrixException
setExpMethod(Maths.SquareMatrix.Calculation)
.x
- x in the above equationSquareMatrix.SquareMatrixException
- Thrown if the calculation can't be performed
as the Eigenvalues can't be computedpublic SquareMatrix exp() throws SquareMatrix.SquareMatrixException
SquareMatrix.SquareMatrixException
- Thrown if the calculation can't be performed
as the Eigenvalues can't be computedpublic double norm()
public SquareMatrix inverse()
public double getPosition(int i, int j)
i
- The row positionj
- The column positionpublic int size()
public double[][] getArray()
public static void setExpMethod(SquareMatrix.Calculation i)
i
- The method to be usedpublic static void setForce(int f)
f
- public static void setNoThreads(int number)
number
- public boolean equals(java.lang.Object ob)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public SquareMatrix eigVectors() throws EigenvalueDecomposition.ConvergenceException
EigenvalueDecomposition.ConvergenceException
- Thrown if the eigendeompisition does not convergepublic double[] eigValues() throws EigenvalueDecomposition.ConvergenceException
EigenvalueDecomposition.ConvergenceException
- Thrown if the eigendeompisition does not convergepublic SquareMatrix eigValuesDiag() throws EigenvalueDecomposition.ConvergenceException
EigenvalueDecomposition.ConvergenceException
public SquareMatrix transpose()
public SquareMatrix divide(SquareMatrix B)
B
- The matrix to divide bypublic java.lang.String toString()
toString
in class java.lang.Object