org.spaceroots.mantissa.linalg
Class DiagonalMatrix
- java.lang.Object
-
- org.spaceroots.mantissa.linalg.Matrix
-
- org.spaceroots.mantissa.linalg.SquareMatrix
-
- org.spaceroots.mantissa.linalg.DiagonalMatrix
-
- All Implemented Interfaces:
- java.io.Serializable
public class DiagonalMatrix extends SquareMatrix
This class implements diagonal matrices of linear algebra.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description DiagonalMatrix(DiagonalMatrix d)Copy constructor.DiagonalMatrix(int order)Simple constructor.DiagonalMatrix(int order, double value)Simple constructor.DiagonalMatrix(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.SquareMatrixgetInverse(double epsilon)Invert the instance.org.spaceroots.mantissa.linalg.NonNullRangegetRangeForColumn(int j)Set a range to the non null part covered by a column.org.spaceroots.mantissa.linalg.NonNullRangegetRangeForRow(int i)Set a range to the non null part covered by a row.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
solve
-
Methods inherited from class org.spaceroots.mantissa.linalg.Matrix
add, getColumns, getElement, getRows, getTranspose, mul, mul, selfMul, sub, toString
-
-
-
-
Constructor Detail
-
DiagonalMatrix
public DiagonalMatrix(int order)
Simple constructor. This constructor builds a diagonal matrix of specified order, all elements on the diagonal being ones (so this is an identity matrix).- Parameters:
order- order of the matrix
-
DiagonalMatrix
public DiagonalMatrix(int order, double value)Simple constructor. This constructor builds a diagonal matrix of specified order and set all diagonal elements to the same value.- Parameters:
order- order of the matrixvalue- value for the diagonal elements
-
DiagonalMatrix
public DiagonalMatrix(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)
-
DiagonalMatrix
public DiagonalMatrix(DiagonalMatrix d)
Copy constructor.- Parameters:
d- diagonal 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)
-
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
-
getInverse
public SquareMatrix getInverse(double epsilon) throws SingularMatrixException
Description copied from class:SquareMatrixInvert the instance.- Overrides:
getInversein classSquareMatrix- Parameters:
epsilon- threshold on matrix elements below which the matrix is considered singular- Returns:
- the inverse matrix of the instance
- Throws:
SingularMatrixException- if the matrix is singular
-
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
-
getRangeForRow
public org.spaceroots.mantissa.linalg.NonNullRange getRangeForRow(int i)
Description copied from class:MatrixSet a range to the non null part covered by a row.- Parameters:
i- index of the row- Returns:
- range of non nul elements in the specified row
- See Also:
Matrix.getRangeForColumn(int)
-
getRangeForColumn
public org.spaceroots.mantissa.linalg.NonNullRange getRangeForColumn(int j)
Description copied from class:MatrixSet a range to the non null part covered by a column.- Parameters:
j- index of the column- Returns:
- range of non nul elements in the specified column
- See Also:
Matrix.getRangeForRow(int)
-
-
DataMelt 3.0 © DataMelt by jWork.ORG