Advertisement
krs_

Untitled

Dec 9th, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ///////////////////////////////////////////////////////////////
  2. // Zadanie 6                                                 //
  3. // Autor: Wojciech Kopeć                                    //
  4. ///////////////////////////////////////////////////////////////
  5.  
  6. #include <iostream>
  7. #include <math.h>
  8. //#include "tnt/jama_lu.h" // <tnt/jama_svd.h> - > "tnt/jama_lu.h"
  9. #include "jama_lu.h"
  10.  
  11. using namespace std;
  12. using namespace JAMA;
  13. using namespace TNT;
  14. const int size=5;       //wieklosc macierzy
  15. const int p=8;          //dokladnosc wynikow
  16.  
  17. int main()
  18. {
  19.  
  20.     double matrix[5][5]={{-116.66654, 583.33346, -333.33308, 100.00012, 100.00012},
  21.                         {583.33346, -116.66654, -333.33308, 100.00012, 100.00012},
  22.                         {-333.33308, -333.33308, 133.33383, 200.00025, 200.00025},
  23.                         {100.00012, 100.00012, 200.00025, 50.000125, -649.99988,},
  24.                         {100.00012, 100.00012, 200.00025, -649.99988, 50.000125}}; 
  25.     double b1[5]={-0.33388066, 1.08033290, -0.98559856, 1.31947922, -0.09473435};
  26.     double b2[5]={-0.33388066, 1.08033290, -0.98559855, 1.32655028, -0.10180541};
  27.     double b3[5]={0.72677951, 0.72677951, -0.27849178, 0.96592583, 0.96592583};
  28.     double b4[5]={0.73031505, 0.73031505, -0.27142071, 0.96946136, 0.96946136};
  29.     double z1[5], z2[5], z3[5], z4[5], b1_b2[5], b3_b4[5], z1_z2[5], z3_z4[5]={0, 0, 0, 0, 0}; // to mozesz wywalić.
  30.     Array1D<double> Z1(5), Z2(5), Z3(5), Z4(5), B1(5), B2(5), B3(5), B4(5); // Array2D na Array1D bo to wektory
  31.     Array2D<double> L, U, X; // to nie jest potrzebne możesz wywalić.
  32.     Array2D<double> A(size,size);
  33.    
  34.     for(int i=0; i<size; i++)
  35.     {
  36.         for(int j=0; j<size; j++)
  37.         {
  38.             A[i][j]=matrix[i][j];
  39.         }
  40.         B1[i]=b1[i];
  41.         B2[i]=b2[i];
  42.         B3[i]=b3[i];
  43.         B4[i]=b4[i];
  44.     }
  45.    
  46.     LU<double> lu(A);
  47.    
  48.     L = lu.getL(); // to nie jest potrzebne mozesz wywalic
  49.     U = lu.getU();
  50.    
  51.     cout.precision(p);
  52.     Z1=lu.solve(B1); // z1 na Z1 i b1 na B1
  53.    
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement