org.spaceroots.mantissa.linalg
Class GeneralSquareMatrix
- java.lang.Object
-
- org.spaceroots.mantissa.linalg.Matrix
-
- org.spaceroots.mantissa.linalg.SquareMatrix
-
- org.spaceroots.mantissa.linalg.GeneralSquareMatrix
-
- All Implemented Interfaces:
- java.io.Serializable
- Direct Known Subclasses:
- SymetricalMatrix
public class GeneralSquareMatrix extends SquareMatrix
This class implements general square matrices of linear algebra.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description GeneralSquareMatrix(GeneralSquareMatrix s)Copy constructor.GeneralSquareMatrix(int order)Simple constructor.GeneralSquareMatrix(int order, double[] data)Simple constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description Matrixduplicate()Polymorphic copy operator.doublegetDeterminant(double epsilon)Get the determinant of the matrix.voidselfAdd(SquareMatrix s)Add a matrix to the instance.voidselfSub(SquareMatrix s)Substract a matrix from the instance.voidsetElement(int i, int j, double value)Set a matrix element.Matrixsolve(Matrix b, double epsilon)Solve the A.X = B equation.-
Methods inherited from class org.spaceroots.mantissa.linalg.SquareMatrix
getInverse, solve
-
Methods inherited from class org.spaceroots.mantissa.linalg.Matrix
add, getColumns, getElement, getRows, getTranspose, mul, mul, selfMul, sub, toString
-
-
-
-
Constructor Detail
-
GeneralSquareMatrix
public GeneralSquareMatrix(int order)
Simple constructor. This constructor builds a square matrix of specified order, all elements beeing zeros.- Parameters:
order- order of the matrix
-
GeneralSquareMatrix
public GeneralSquareMatrix(int order, double[] data)Simple constructor. Build a matrix with specified elements.- Parameters:
order- order of the matrixdata- table of the matrix elements (stored row after row)
-
GeneralSquareMatrix
public GeneralSquareMatrix(GeneralSquareMatrix s)
Copy constructor.- Parameters:
s- square matrix to copy
-
-
Method Detail
-
duplicate
public Matrix duplicate()
Description copied from class:MatrixPolymorphic copy operator. This method build a new object of the same type of the instance. It is somewhat similar to theObject.clone()method, except that it has public access, it doesn't throw any specific exception and it returns a Matrix.
-
setElement
public void setElement(int i, int j, double value)Description copied from class:MatrixSet a matrix element.- Overrides:
setElementin classMatrix- Parameters:
i- row index, from 0 to rows - 1j- column index, from 0 to cols - 1value- value of the element- See Also:
Matrix.getElement(int, int)
-
selfAdd
public void selfAdd(SquareMatrix s)
Add a matrix to the instance. This method adds a matrix to the instance. It does modify the instance.- Parameters:
s- square matrix to add- Throws:
java.lang.IllegalArgumentException- if there is a dimension mismatch
-
selfSub
public void selfSub(SquareMatrix s)
Substract a matrix from the instance. This method substracts a matrix from the instance. It does modify the instance.- Parameters:
s- square matrix to substract- Throws:
java.lang.IllegalArgumentException- if there is a dimension mismatch
-
getDeterminant
public double getDeterminant(double epsilon)
Description copied from class:SquareMatrixGet the determinant of the matrix.- Specified by:
getDeterminantin classSquareMatrix- Parameters:
epsilon- threshold on matrix elements below which the matrix is considered singular (this is used by the derived classes that use a factorization to compute the determinant)- Returns:
- the determinant of the matrix
-
solve
public Matrix solve(Matrix b, double epsilon) throws SingularMatrixException
Description copied from class:SquareMatrixSolve the A.X = B equation.- Specified by:
solvein classSquareMatrix- Parameters:
b- second term of the equationepsilon- threshold on matrix elements below which the matrix is considered singular- Returns:
- a matrix X such that A.X = B, where A is the instance
- Throws:
SingularMatrixException- if the matrix is singular
-
-
DataMelt 3.0 © DataMelt by jWork.ORG