Advertisement
Guest User

Untitled

a guest
May 26th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. public static double[] backSubst(double[][] R, double[] b) {
  2. int n = b.length;
  3. double[] x = new double[n];
  4. n--;
  5.  
  6. /*
  7. //Filter 0 Rows
  8. int counterColumn = 0;
  9.  
  10. for(int counterAllColumns = 0; counterAllColumns < n; counterAllColumns++) {
  11. boolean hasZeroColumn = true;
  12. for(int counterRows = 0; counterRows < n; counterRows++) {
  13. if(R[counterRows][counterAllColumns] != 0.0) {
  14. hasZeroColumn = false;
  15. }
  16. }
  17. if(hasZeroColumn) {
  18. n--;
  19. double[][] newR = new double[n][n];
  20. for(int row = 0; row < n;row++) {
  21. newR[counterColumn][row] = R[counterAllColumns][row];
  22. }
  23. counterColumn++;
  24. R = newR;
  25.  
  26. counterAllColumns--;
  27. }
  28. }*/
  29.  
  30.  
  31.  
  32. // j ist spalte
  33. // i ist zeile
  34. for (int i = n; i >= 0; i--) {
  35. double sum = b[i];
  36. for (int j = i + 1; j <= n; j++) {
  37. sum -= x[j] * R[i][j];
  38. }
  39. x[i] = R[i][i] == 0.0 ? 0.0 : sum / R[i][i];
  40. }
  41.  
  42. return x;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement