answersLogoWhite

0


Best Answer

/*This function will return the determinant of any two dimensional matrix. For this particular function a two dimensional double matrix needs to be passed as arguments - Avishek Ghosh*/

public double determinant(double[][] mat) {

double result = 0;

if(mat.length 2) {

result = mat[0][0] * mat[1][1] - mat[0][1] * mat[1][0];

return result;

}

for(int i = 0; i < mat[0].length; i++) {

double temp[][] = new double[mat.length - 1][mat[0].length - 1];

for(int j = 1; j < mat.length; j++) {

System.arraycopy(mat[j], 0, temp[j-1], 0, i);

System.arraycopy(mat[j], i+1, temp[j-1], i, mat[0].length-i-1);

}

result += mat[0][i] * Math.pow(-1, i) * determinant(temp);

}

return result;

}

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Determinant of matrix in java
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the determinant rank of the determinant of 123456 its a 2 x 3 matrix?

A determinant is defined only for square matrices, so a 2x3 matrix does not have a determinant.Determinants are defined only for square matrices, so a 2x3 matrix does not have a determinant.


What is the determinant of a 2x3 matrix?

The determinant function is only defined for an nxn (i.e. square) matrix. So by definition of the determinant it would not exist for a 2x3 matrix.


How to find x in a 2×2 matrix with a given determinant.?

For a matrix A, A is read as determinant of A and not, as modulus of A. ... sum of two or more elements, then the given determinant can be expressed as the sum


Determinant of test?

The determinant of test is usually a scalar quantity. The determinant of a matrix is used to test whether a given matrix has an inverse or not. It is used to test for the linear dependence of the vectors.


What is the determinant of matrix image?

1


If two rows of a matrix are interchanged what is true of the resulting determinant?

The determinant will change sign.


Determinant of four-by-three matrix?

undefined


How do you find the determinant of a square matrix?

233


What is the determinant of an idempotent matrix?

0 or 1


Does every square matrix have an inverse?

No. A square matrix has an inverse if and only if its determinant is nonzero.


What is the minor of determinant?

The minor is the determinant of the matrix constructed by removing the row and column of a particular element. Thus, the minor of a34 is the determinant of the matrix which has all the same rows and columns, except for the 3rd row and 4th column.


What is term for square matrix with zero determinant?

diagonal