Task 1 is donemake cleanmake cleanmake clean

This commit is contained in:
AZEN-SGG 2025-04-10 18:16:45 +03:00
parent cb3f70cbd6
commit de2b2eb48d
3 changed files with 19 additions and 52 deletions

View file

@ -10,7 +10,7 @@ WFLAGS = -W -Wall -Wextra -Wunused -Wempty-body -Wlogical-op \
-pedantic-errors -Wfloat-equal -Wwrite-strings -Wno-long-long \
-Wstrict-prototypes -Wmissing-field-initializers -Wpointer-sign
TARGET = a14.out
TARGET = a.out
OBJ = main.o solve.o array_io.o init_f.o matrix.o
%.o: %.c

View file

@ -6,14 +6,15 @@
#include <math.h>
#include <stdio.h>
#define EPS 1.2e-16
// c - changes in rows
int t14_solve(int n, double * restrict A, double * restrict X, int * restrict c)
{
double norm = get_matrix_norm(n, A);
double eps = DBL_EPSILON*norm;
double eps = EPS*norm;
if (norm < DBL_EPSILON)
return SINGULAR;
// printf("NORM = %lf EPS = %lf\n", norm, eps);
// Проходимся по главным минорам
for (int k = 0; k < n; ++k) {
@ -31,12 +32,12 @@ int t14_solve(int n, double * restrict A, double * restrict X, int * restrict c)
max_j = j;
}
}
// printf("\n------- K = %d -------\n", k);
// printf("Maximum = %lf i = %d j = %d\n", maximum, max_i, max_j);
// Если максимальный по модулю элемент равен нулю, значит матрица вырождена
if (fabs(maximum) < eps)
if (fabs(maximum) <= eps)
return SINGULAR;
// Меняем строки местами, если максимум находится не в k строке