00001
00002
00003
00004
00005
00006
00007 #include "nl.h"
00008
00009 int main()
00010 {
00011 double **A, *b, cond;
00012 size_t *p;
00013 int sgn;
00014 size_t n = 3;
00015
00016 A = nl_dmatrix_create(n, n);
00017 b = nl_dvector_create(n);
00018 p = nl_xvector_create(n);
00019
00020 A[0][0] = .1; A[0][1] = .5; A[0][2] = .6; b[0] = 1.2;
00021 A[1][0] = .2; A[1][1] = .7; A[1][2] = .9; b[1] = 1.8;
00022 A[2][0] = .3; A[2][1] = 1.1; A[2][2] = 1.3; b[2] = 2.7;
00023
00024 printf("Матрица А:\n");
00025 nl_dmatrix_print(A, n, n, NULL);
00026
00027 cond = lu_decomp(A, n, p, &sgn);
00028
00029 printf("\nЧисло обусловленности >= %e\n", cond);
00030
00031 printf("\nLU-разложение:\n");
00032 nl_dmatrix_print(A, n, n, NULL);
00033
00034 printf("\nВектор p:\n");
00035 nl_xvector_print(p, n, NULL);
00036
00037 printf("\nSgn = %d\n", sgn);
00038
00039 printf("\nВектор b:\n");
00040 nl_dvector_print(b, n, NULL);
00041
00042 lu_solve(A, n, p, b);
00043
00044 printf("\nРешение системы Ax = b:\n");
00045 nl_dvector_print(b, n, NULL);
00046
00047 nl_dmatrix_free(A, n);
00048 nl_dvector_free(b);
00049 nl_xvector_free(p);
00050
00051 return 0;
00052 }