mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-26 22:14:08 +08:00
Format code with prettier (#3375)
This commit is contained in:
@ -3,12 +3,12 @@ package com.thealgorithms.misc;
|
||||
import java.util.Scanner;
|
||||
|
||||
/*
|
||||
* Wikipedia link : https://en.wikipedia.org/wiki/Invertible_matrix
|
||||
*
|
||||
* Here we use gauss elimination method to find the inverse of a given matrix.
|
||||
* To understand gauss elimination method to find inverse of a matrix: https://www.sangakoo.com/en/unit/inverse-matrix-method-of-gaussian-elimination
|
||||
*
|
||||
* We can also find the inverse of a matrix
|
||||
* Wikipedia link : https://en.wikipedia.org/wiki/Invertible_matrix
|
||||
*
|
||||
* Here we use gauss elimination method to find the inverse of a given matrix.
|
||||
* To understand gauss elimination method to find inverse of a matrix: https://www.sangakoo.com/en/unit/inverse-matrix-method-of-gaussian-elimination
|
||||
*
|
||||
* We can also find the inverse of a matrix
|
||||
*/
|
||||
public class InverseOfMatrix {
|
||||
|
||||
@ -52,8 +52,7 @@ public class InverseOfMatrix {
|
||||
for (int i = 0; i < n - 1; ++i) {
|
||||
for (int j = i + 1; j < n; ++j) {
|
||||
for (int k = 0; k < n; ++k) {
|
||||
b[index[j]][k]
|
||||
-= a[index[j]][i] * b[index[i]][k];
|
||||
b[index[j]][k] -= a[index[j]][i] * b[index[i]][k];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -72,8 +71,8 @@ public class InverseOfMatrix {
|
||||
return x;
|
||||
}
|
||||
|
||||
// Method to carry out the partial-pivoting Gaussian
|
||||
// elimination. Here index[] stores pivoting order.
|
||||
// Method to carry out the partial-pivoting Gaussian
|
||||
// elimination. Here index[] stores pivoting order.
|
||||
public static void gaussian(double a[][], int index[]) {
|
||||
int n = index.length;
|
||||
double c[] = new double[n];
|
||||
|
Reference in New Issue
Block a user