Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. public class KwadraturaGaussa {
  2.  
  3. static double[] x = {0, 5, 5, 0};
  4. static double[] y = {0, 0, 5, 5};
  5. static double[] waga = {1, 1};
  6. static double[] punkt = {-0.5773502692, 0.5773502692};
  7. static double[][][] fksztalt = new double[2][2][4];
  8. static double[][] poch_ksi = new double[2][4];
  9. static double[][] poch_ni = new double[2][4];
  10. static double[][] fun_detj = new double[2][2];
  11. static double dxdksi ;
  12. static double dydksi ;
  13. static double dxdni ;
  14. static double dydni;
  15.  
  16. static void funk() {
  17.  
  18. for (int i = 0; i < punkt.length; i++) {
  19.  
  20. for (int j = 0; j < punkt.length; j++) {
  21. fksztalt[j][i][0] = 0.25 * (1.0 - punkt[j]) * (1.0 - punkt[i]);
  22. fksztalt[j][i][1] = 0.25 * (1.0 + punkt[j]) * (1.0 - punkt[i]);
  23. fksztalt[j][i][2] = 0.25 * (1.0 + punkt[j]) * (1.0 + punkt[i]);
  24. fksztalt[j][i][3] = 0.25 * (1.0 - punkt[j]) * (1.0 + punkt[i]);
  25.  
  26. poch_ksi[i][0] = -0.25 * (1.0 - punkt[i]);
  27. poch_ksi[i][1] = 0.25 * (1.0 - punkt[i]);
  28. poch_ksi[i][2] = 0.25 * (1.0 + punkt[i]);
  29. poch_ksi[i][3] = -0.25 * (1.0 + punkt[i]);
  30.  
  31. poch_ni[j][0] = -0.25 * (1.0 - punkt[j]);
  32. poch_ni[j][1] = -0.25 * (1.0 + punkt[j]);
  33. poch_ni[j][2] = 0.25 * (1.0 + punkt[j]);
  34. poch_ni[j][3] = 0.25 * (1.0 - punkt[j]);
  35. }
  36. }
  37.  
  38. for (int i = 0; i < 2; i++) {
  39. for (int j = 0; j < 2; j++) {
  40. dxdksi = poch_ksi[i][0] * (x[0]) + poch_ksi[i][1] * (x[1]) +
  41. poch_ksi[i][2] * (x[2]) + poch_ksi[i][3] * (x[3]);
  42.  
  43. dydksi = poch_ksi[i][0] * y[0] + poch_ksi[i][1] * y[1] +
  44. poch_ksi[i][2] * y[2] + poch_ksi[i][3] * y[3];
  45.  
  46. dxdni = poch_ni[j][0] * (y[0]) + poch_ni[j][1] * (y[1]) +
  47. poch_ni[j][2] * (y[2]) + poch_ni[j][3] * (y[3]);
  48.  
  49.  
  50. dydni = poch_ni[j][0] * y[0] + poch_ni[j][1] * y[1] +
  51. poch_ni[j][2] * y[2] + poch_ni[j][3] * y[3];
  52.  
  53. fun_detj[i][j] = dxdksi*dydni - dxdni*dydksi;
  54.  
  55.  
  56. }
  57. }
  58. double powierzchnia = 0.0;
  59. for (int i = 0; i < punkt.length; i++) {
  60.  
  61. for (int j = 0; j < punkt.length; j++) {
  62.  
  63. powierzchnia += Math.abs(fun_detj[i][j]);
  64. }
  65.  
  66.  
  67. }
  68. System.out.println(powierzchnia);
  69.  
  70.  
  71.  
  72.  
  73. }
  74. public static void main(String[] args)
  75. {
  76. KwadraturaGaussa kg = new KwadraturaGaussa();
  77. funk();
  78. // Initial Values ---- TO BYLO W INNYM PROJEKCIE
  79. float x0 = 0;
  80. float y0 = 1;
  81. float h = (float) 0.5;
  82.  
  83.  
  84. float x = (float) 3;
  85.  
  86.  
  87. }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement