Class MatrixOld
java.lang.Object
com.github.gbenroscience.math.matrix.expressParser.MatrixOld
- Author:
- GBEMIRO
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadjoint()voidcolumnDeleteFromEnd(int column) Deletes all the specified number of columns from the MatrixOld object starting from the end of the MatrixOld objectvoidcolumnDeleteFromStart(int column) Deletes all the specified number of columns from the MatrixOld object from the beginning of the MatrixOld objectstatic MatrixOldcolumnJoin(MatrixOld mat1, MatrixOld mat2) Place the first MatrixOld object side by side with the second one passed as argument to this method.doubledeterm()Row reduction technique used to compute the determinant of this matrix.doublevoidfill()Fills this matrix object with valuesstatic final Stringdouble[][]getArray()final StringintgetCols()getColumnMatrixOld(int column) doublegetElem(int row, int col) getName()getRowMatrixOld(int row) intgetRows()inverse()Row reduction technique used to compute the inverse of the matrix.static booleanisMatrixOldValue(String matrixValue) booleanbooleanstatic void(2-x)(3-x)(1-x)=(6-5x+x^2)(1-x)=6-11x+6x^2-x^3 {1, 2, 3, 4, 5} {6, 7, 8, 9, 0} {1, 2, 3, 4, 5} {6, 7, 8, 9, 0} {1, 2, 3, 4, 5}minor(int i, int j) voidstatic MatrixOldThe operation of matrix multiplication.Computes the inverse of this MatrixOld object.static MatrixOldstatic MatrixOldvoidprint()static voidprintTextMatrixOld(String[][] mat) voidFills the matrix with randomly generated values between 1 and 101.voidrandomFill(int n) Fills the matrix with randomly generated values between 1 and nvoidrowDeleteFromEnd(int numOfRows) Deletes the specified number of row from the end of the MatrixOld objectvoidrowDeleteFromStart(int numOfRows) Deletes the specified number of row from the beginning of the MatrixOld objectstatic MatrixOldPlace the first MatrixOld object side by side with the second one passed as argument to this method.scalarDivide(double scalar) scalarMultiply(double scalar) final voidsetArray(double[][] array) voidUsed to solve a system of simultaneous equations placed in this MatrixOld object.static MatrixOldsolveEquation(MatrixOld matrix) Used to solve a system of simultaneous equations placed in the MatrixOld object.voidswapColumn(int col1, int col2) voidswapRow(int row1, int row2) toString()static MatrixOldunitMatrixOld(int rowSize, int colSize) static MatrixOldunitMatrixOld(MatrixOld mat) booleanupdate(double value, int row, int column)
-
Field Details
-
lambda
- See Also:
-
-
Constructor Details
-
MatrixOld
public MatrixOld(int rows, int cols) - Parameters:
rows- The number of row in the MatrixOld.cols- The number of columns in the MatrixOld.
-
MatrixOld
- Parameters:
name- the simple name used to identify used by the user to label this MatrixOld object. Assigns name unknown to the MatrixOld object and a 2D array that has just a row and a column
-
MatrixOld
public MatrixOld(double[][] array) - Parameters:
array- the data array used to create this MatrixOld object
-
MatrixOld
- Parameters:
matrix- constructs a new MatrixOld object having similar properties to the one passed as argument, but holding no reference to its data.
-
-
Method Details
-
getRows
public int getRows()- Returns:
- the number of row in this matrix object
-
getCols
public int getCols()- Returns:
- the number of columns in this matrix object
-
setArray
public final void setArray(double[][] array) - Parameters:
array- sets the data of this matrix
-
getArray
public double[][] getArray()- Returns:
- the data of this matrix
-
getElem
public double getElem(int row, int col) -
setName
- Parameters:
name- set's the simple name used to identify used by the user to label this MatrixOld object.
-
getName
- Returns:
- the simple name used to identify used by the user to label this MatrixOld object.
-
swapRow
public void swapRow(int row1, int row2) - Parameters:
row1- The first row.row2- The second row. BE CAREFUL!!!!
THIS METHOD ACTS ON THE MATRIX OBJECT ON WHICH IT IS CALLED AND MODIFIES IT!
-
swapColumn
public void swapColumn(int col1, int col2) - Parameters:
col1- The first row.col2- The second row. BE CAREFUL!!!!
THIS METHOD ACTS ON THE MATRIX OBJECT ON WHICH IT IS CALLED AND MODIFIES IT!
-
fill
public void fill()Fills this matrix object with values -
add
-
subtract
-
scalarMultiply
- Parameters:
scalar- the constant to be multiplied with this matrix The operation is ( scalar X matrice )- Returns:
- an array containing the product matrix.
-
scalarDivide
- Parameters:
scalar- the constant to be multiplied with this matrix The operation is ( matrice/scalar )- Returns:
- an array containing the scaled matrix.
-
multiply
The operation of matrix multiplication. For this method to run, The pre-multiplying matrix must have its number of columns equal to the number of row in the pre-multiplying one. The product matrix is one that has its number of columns equal to the number of columns in the pre-multiplying matrix, and its row equal to that in the post-multiplying matrix. So if the operation is A X B = C, and A is an m X n matrix while B is an r X p matrix, then r = n is a necessary condition for the operation to occur. Also, C is an m X p matrix.- Parameters:
matrice1- the matrix to be pre-multiplying the other one. The operation is ( matrice1 X matrice2 )matrice2- the post-multiplying matrix- Returns:
- a new MatrixOld object containing the product matrix of the operation matrice1 X matrice2
-
multiply
- Parameters:
matrice- the matrix to be multiplied by this one. This operation modifies this matrix and changes its data array into that of the product matrix The operation is ( this X matrice )
-
pow
-
power
-
unitMatrixOld
- Returns:
- a unit matrix of the same dimension as this matrix object
-
unitMatrixOld
- Parameters:
rowSize- the number of row that the unit matrix will havecolSize- the number of columns that the unit matrix will have- Returns:
- a unit matrix having number of row = rowSize and number of columns=colSize.
-
unitMatrixOld
-
columnJoin
Place the first MatrixOld object side by side with the second one passed as argument to this method. The result is a new matrix where: if 3 4 5 7 5 9 mat1 = 2 3 1 and mat2 = 4 2 6 1 6 7 5 7 3 in a new matrix object (mat). e.g 3 4 5 7 5 9 2 3 1 4 2 6 1 6 7 5 7 3 A necessary condition for this method to run is that the 2 objects must have an equal number of row. IF THIS CONDITION IS NOT MET, THE METHOD RETURNS A ZERO MATRIX.- Parameters:
mat1- the first MatrixOld objectmat2- the second MatrixOld object that we column join with this one- Returns:
- a new MatrixOld object that contains this MatrixOld object placed side by side with the MatrixOld object passed as argument.
-
update
public boolean update(double value, int row, int column) - Parameters:
value- The value to insertrow- The row where the value is to be inserted.column- The column where the value is to be inserted.
-
rowJoin
Place the first MatrixOld object side by side with the second one passed as argument to this method. The result is a new matrix where: if 3 4 5 7 5 9 mat1 = 2 3 1 and mat2 = 4 2 6 1 6 7 5 7 3 in a new matrix object (mat). e.g 3 4 5 2 3 1 1 6 7 7 5 9 4 2 6 5 7 3 A necessary condition for this method to run is that the 2 objects must have an equal number of columns. IF THIS CONDITION IS NOT MET, THE METHOD RETURNS A ZERO MATRIX.- Parameters:
mat1- the first MatrixOld objectmat2- the second MatrixOld object that we row join with this one- Returns:
- a new MatrixOld object that contains the first MatrixOld object argument placed top to bottom with the second MatrixOld object argument.
-
columnDeleteFromEnd
public void columnDeleteFromEnd(int column) Deletes all the specified number of columns from the MatrixOld object starting from the end of the MatrixOld object- Parameters:
column- the number of columns to remove from the MatrixOld object. This method will take the object that calls it and perform this operation on it. So it modifies the MatrixOld object that calls it. Be careful, as data will be lost. e.g if 3 4 5 6 7 8 9 2 1 8 1 4 7 0 A = 3 3 2 1 5 7 1 then the call: A.columnDeleteFromEnd(3) will delete the last three columns in this object leaving: 3 4 5 6 A = 2 1 8 1 3 3 2 1
-
columnDeleteFromStart
public void columnDeleteFromStart(int column) Deletes all the specified number of columns from the MatrixOld object from the beginning of the MatrixOld object- Parameters:
column- the number of columns to remove from the MatrixOld object's beginning. This method will take the object that calls it and perform this operation on it. So it modifies the MatrixOld object that calls it. Be careful, as data will be lost. e.g if 3 4 5 6 7 8 9 2 1 8 1 4 7 0 A = 3 3 2 1 5 7 1 then the call: A.columnDeleteFromStart(3) will delete the last three columns in this object leaving: 6 7 8 9 A= 1 4 7 0 1 5 7 1
-
rowDeleteFromEnd
public void rowDeleteFromEnd(int numOfRows) Deletes the specified number of row from the end of the MatrixOld object- Parameters:
numOfRows- the number of row to remove from the MatrixOld object's beginning. This method will take the object that calls it and perform this operation on it. So it modifies the MatrixOld object that calls it. Be careful, as data will be lost. e.g if 3 4 5 6 2 1 8 1 A = 3 3 2 1 7 8 9 2 4 7 0 5 5 7 1 8 then the call: A.rowDeleteFromEnd(3) will delete the last three row in this object leaving: 3 4 5 6 2 1 8 1 A = 3 3 2 1
-
rowDeleteFromStart
public void rowDeleteFromStart(int numOfRows) Deletes the specified number of row from the beginning of the MatrixOld object- Parameters:
numOfRows- the number of row to remove from the MatrixOld object's beginning. This method will take the object that calls it and perform this operation on it. So it modifies the MatrixOld object that calls it. Be careful, as data will be lost. e.g if 3 4 5 6 2 1 8 1 A = 3 3 2 1 7 8 9 2 4 7 0 5 5 7 1 8 then the call: A.rowDeleteFromStart(3) will delete the last three row in this object leaving: A = 7 8 9 2 4 7 0 5 5 7 1 8
-
reduceToTriangularMatrixOld
- Returns:
- an upper triangular matrix obtained by row reduction.
-
reduceToRowEchelonMatrixOld
- Returns:
- an upper triangular matrix obtained by row reduction.
-
solveEquation
Used to solve a system of simultaneous equations placed in this MatrixOld object.- Returns:
- a MatrixOld object containing the solution matrix.
-
solveEquation
-
transpose
- Returns:
- the transpose of this MatrixOld object. Does not modify this matrix object but generates the transpose of this MatrixOld object as another MatrixOld object.
-
adjoint
-
getCofactorMatrixOld
- Returns:
- a matrix that contains the cofactors of the elements of this MatrixOld.
-
minor
- Parameters:
i- the row on which the element whose minor is needed lies.j- the column on which the element whose minor is needed lies.- Returns:
- the minor of this matrix relative to this element.
-
isSquareMatrixOld
public boolean isSquareMatrixOld()- Returns:
- true if this MatrixOld object is a square matrix.
-
isSystemOfEquations
public boolean isSystemOfEquations()- Returns:
- true if this MatrixOld object can represent a system of equations solvable by reduction to triangular form and subsequent evaluation.
-
determinant
public double determinant()- Returns:
- the determinant of this matrix using a row reduction technique.
-
randomFill
public void randomFill()Fills the matrix with randomly generated values between 1 and 101. -
randomFill
public void randomFill(int n) Fills the matrix with randomly generated values between 1 and n- Parameters:
n- the maximum possible size of the integer numbers generated.
-
isMatrixOldValue
- Parameters:
matrixValue- A string that is to be checked if it conforms to valid syntax for representing a matrix in this software.- Returns:
- true if the command string is a valid matrix.e.g [2,1,4:5,3,-2:4,4,5] value.
-
toString
-
printTextMatrixOld
- Parameters:
mat- The string matrix
-
getRowMatrixOld
- Parameters:
row- The row in this MatrixOld object to be converted into a new MatrixOld object. This operation generates a new MatrixOld object which is a row matrix.
-
getColumnMatrixOld
- Parameters:
column- The column to be converted into a new MatrixOld object. This operation generates a new MatrixOld object which is a column matrix.
-
oldInverse
Computes the inverse of this MatrixOld object. This technique should never be used in practise as it is a mere proof of concept. It computes the inverse by computing the roots of the equations and then reverse engineering the form A.x = B to get the inverse matrix.- Returns:
- the inverse of the MatrixOld as another MatrixOld object.
-
inverse
Row reduction technique used to compute the inverse of the matrix. Always use this technique.- Returns:
- the inverse of the MatrixOld as another MatrixOld object.
-
determ
public double determ()Row reduction technique used to compute the determinant of this matrix. The other method using recursion is not worth it above n = 10; The memory consumed by the process and the time used to compute it is incomparable to this method's performance.- Returns:
- the inverse of the MatrixOld as another MatrixOld object.
-
getCharacteristicPolynomialForEigenVector
-
findCharacteristicPolynomialForEigenValues
-
print
public void print() -
main
(2-x)(3-x)(1-x)=(6-5x+x^2)(1-x)=6-11x+6x^2-x^3 {1, 2, 3, 4, 5} {6, 7, 8, 9, 0} {1, 2, 3, 4, 5} {6, 7, 8, 9, 0} {1, 2, 3, 4, 5}- Parameters:
args- The command line args
-