Advertisement
Guest User

Untitled

a guest
Nov 17th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. namespace ConsoleApplication
  2. {
  3. public class Discrepancies
  4. {
  5. public double[] discrepancies(double[,] smatrix, double[]res, int dimension)
  6. {
  7. double[] B = new double[dimension];
  8. double[,] A = new double[dimension,dimension];
  9. double[] discrep = new double[dimension];
  10. double[] AX = new double[dimension];
  11. double sum;
  12. int yCount;
  13. int xCount;
  14.  
  15. for (yCount = 0; yCount < dimension; yCount++) //вытаскиваем из матрицы свободные элементы
  16. {
  17. B[yCount] = smatrix[yCount,dimension];
  18. }
  19.  
  20. for ( yCount = 0; yCount< dimension; yCount++) //вытаскиваем из матрицы коэффиценты перед "х"
  21. {
  22. for ( xCount = 0; xCount < dimension; xCount++)
  23. {
  24. A[yCount, xCount] = smatrix[yCount, xCount];
  25. }
  26.  
  27. }
  28.  
  29. for (yCount = 0; yCount < dimension; yCount++) //перемножаем матрицы с результатом и коэффицентами
  30. {
  31. sum = 0;
  32. for (xCount = 0; xCount < dimension; xCount++)
  33. {
  34. sum += A[yCount, xCount] * res[xCount];
  35.  
  36. }
  37. AX[yCount] = sum;
  38. }
  39.  
  40. for (yCount = 0; yCount < dimension; yCount++) //значение погрешности
  41. {
  42. discrep[yCount] = B[yCount] - AX[yCount];
  43. }
  44.  
  45. return discrep;
  46. }
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement