00001
00002
00003
00004
00005
00006
00007
00008 #include "nl.h"
00009
00010 int main()
00011 {
00012 double **A, *b, *t;
00013 size_t n = 3;
00014
00015 A = nl_dmatrix_create(n, n);
00016 b = nl_dvector_create(n);
00017 t = nl_dvector_create(n);
00018
00019 A[0][0] = .1; A[0][1] = .5; A[0][2] = .6; b[0] = 1.2;
00020 A[1][0] = .2; A[1][1] = .7; A[1][2] = .9; b[1] = 1.8;
00021 A[2][0] = .3; A[2][1] = 1.1; A[2][2] = 1.3; b[2] = 2.7;
00022
00023 printf("Матрица A:\n");
00024 nl_dmatrix_print(A, n, n, NULL);
00025
00026 qr_decomp(A, n, n, t);
00027
00028 printf("\nQR-разложение:\n");
00029 nl_dmatrix_print(A, n, n, NULL);
00030
00031 printf("\nВектор t:\n");
00032 nl_dvector_print(t, n, NULL);
00033
00034 printf("\nВектор b:\n");
00035 nl_dvector_print(b, n, NULL);
00036
00037 qr_solve (A, n, t, b);
00038
00039 printf("\nРешение системы Ax = b:\n");
00040 nl_dvector_print(b, n, NULL);
00041
00042 nl_dmatrix_free(A, n);
00043 nl_dvector_free(b);
00044 nl_dvector_free(t);
00045
00046 return 0;
00047 }