Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static double[] backSubst(double[][] R, double[] b) {
- int n = b.length;
- double[] x = new double[n];
- n--;
- /*
- //Filter 0 Rows
- int counterColumn = 0;
- for(int counterAllColumns = 0; counterAllColumns < n; counterAllColumns++) {
- boolean hasZeroColumn = true;
- for(int counterRows = 0; counterRows < n; counterRows++) {
- if(R[counterRows][counterAllColumns] != 0.0) {
- hasZeroColumn = false;
- }
- }
- if(hasZeroColumn) {
- n--;
- double[][] newR = new double[n][n];
- for(int row = 0; row < n;row++) {
- newR[counterColumn][row] = R[counterAllColumns][row];
- }
- counterColumn++;
- R = newR;
- counterAllColumns--;
- }
- }*/
- // j ist spalte
- // i ist zeile
- for (int i = n; i >= 0; i--) {
- double sum = b[i];
- for (int j = i + 1; j <= n; j++) {
- sum -= x[j] * R[i][j];
- }
- x[i] = R[i][i] == 0.0 ? 0.0 : sum / R[i][i];
- }
- return x;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement