Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///////////////////////////////////////////////////////////////
- // Zadanie 6 //
- // Autor: Wojciech Kopeć //
- ///////////////////////////////////////////////////////////////
- #include <iostream>
- #include <math.h>
- #include <tnt/jama_svd.h>
- using namespace std;
- using namespace JAMA;
- using namespace TNT;
- const int size=5; //wieklosc macierzy
- const int p=8; //dokladnosc wynikow
- int main()
- {
- double matrix[5][5]={{-116.66654, 583.33346, -333.33308, 100.00012, 100.00012},
- {583.33346, -116.66654, -333.33308, 100.00012, 100.00012},
- {-333.33308, -333.33308, 133.33383, 200.00025, 200.00025},
- {100.00012, 100.00012, 200.00025, 50.000125, -649.99988,},
- {100.00012, 100.00012, 200.00025, -649.99988, 50.000125}};
- double b1[5]={-0.33388066, 1.08033290, -0.98559856, 1.31947922, -0.09473435};
- double b2[5]={-0.33388066, 1.08033290, -0.98559855, 1.32655028, -0.10180541};
- double b3[5]={0.72677951, 0.72677951, -0.27849178, 0.96592583, 0.96592583};
- double b4[5]={0.73031505, 0.73031505, -0.27142071, 0.96946136, 0.96946136};
- 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};
- Array2D<double> Z1(5), Z2(5), Z3(5), Z4(5), B1(5), B2(5), B3(5), B4(5);
- Array2D<double> L, U, X;
- Array2D<double> A(size,size);
- for(int i=0; i<size; i++)
- {
- for(int j=0; j<size; j++)
- {
- A[i][j]=matrix[i][j];
- }
- B1[i]=b1[i];
- B2[i]=b2[i];
- B3[i]=b3[i];
- B4[i]=b4[i];
- }
- LU<double> lu(A);
- L = lu.getL();
- U = lu.getU();
- cout.precision(p);
- z1=lu.solve(b1);
- return 0;
- }
- for ( int i = 0; i < sizeMatrix; i++ )
- {
- for ( int j = i-1; j <= i; j++ )
- {
- Sum = 0.0;
- for ( int k = 0; k < j; k++ ) Sum = Sum + Lower[i][k] * Lower[j][k];
- if ( i == j ) Lower[i][i] = Math.sqrt( matrix[i][i] - Sum );
- else Lower[i][j] ( matrix[i][j] - Sum ) )/ Lower[j][j];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment