Start optimisation
This commit is contained in:
parent
f22449e1e1
commit
4096c5f1dc
3 changed files with 20 additions and 8 deletions
6
2025.04.04/dist/Krivoruchenko_SK/Makefile
vendored
6
2025.04.04/dist/Krivoruchenko_SK/Makefile
vendored
|
@ -10,17 +10,17 @@ WFLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused \
|
|||
|
||||
CFLAGS = -mfpmath=sse -std=gnu99 -O3
|
||||
|
||||
TARGET = a.exe
|
||||
TARGET = a.out
|
||||
OBJ = main.o solve.o array_io.o init_f.o matrix.o
|
||||
|
||||
%.o: %.c
|
||||
gcc $(CFLAGS) $(WFLAGS) -c $< -o $@
|
||||
|
||||
$(TARGET): $(OBJ)
|
||||
gcc $^ -o $@ -lm -lssp
|
||||
gcc $^ -o $@ -lm
|
||||
|
||||
gdb: CFLAGS = -mfpmath=sse -std=gnu99 -g
|
||||
gdb: clean $(TARGET)
|
||||
|
||||
clean:
|
||||
del *.o *.exe
|
||||
del *.o *.out
|
||||
|
|
20
2025.04.04/dist/Krivoruchenko_SK/solve.c
vendored
20
2025.04.04/dist/Krivoruchenko_SK/solve.c
vendored
|
@ -36,7 +36,7 @@ int t14_solve(int n, double * restrict A, double * restrict X, int * restrict c)
|
|||
// printf("Maximum = %lf i = %d j = %d\n", maximum, max_i, max_j);
|
||||
|
||||
// Если максимальный по модулю элемент равен нулю, значит матрица вырождена
|
||||
if (fabs(maximum) < eps)
|
||||
if (maximum < eps)
|
||||
return SINGULAR;
|
||||
|
||||
// Меняем строки местами, если максимум находится не в k строке
|
||||
|
@ -138,19 +138,31 @@ int t14_solve(int n, double * restrict A, double * restrict X, int * restrict c)
|
|||
}
|
||||
|
||||
// Прямой ход Го ----- йда
|
||||
void gauss_inverse(const int n, const int k, double * restrict A, double * restrict X)
|
||||
void gauss_inverse(const int n, const int k, double * restrict A, double * restrict X, double eps)
|
||||
{
|
||||
const int kn = k*n;
|
||||
const int kk = kn + k;
|
||||
const double inv_akk = 1./A[kk];
|
||||
A[kk] = 1.;
|
||||
A[kk] = 1.;
|
||||
|
||||
if (eps > DBL_EPSILON)
|
||||
eps = DBL_EPSILON;
|
||||
|
||||
for (int ij = kk+1; ij < kn+n; ij++)
|
||||
A[ij] *= inv_akk;
|
||||
|
||||
for (int ij = kn; ij < kn + n; ij++)
|
||||
X[ij] *= inv_akk;
|
||||
|
||||
|
||||
for (int j = 0; j < k; ++j)
|
||||
{
|
||||
const double xkj = X[kn + j];
|
||||
if (fabs(xkj) <= eps)
|
||||
continue;
|
||||
|
||||
|
||||
}
|
||||
|
||||
for (int i = k+1; i < n; ++i)
|
||||
{
|
||||
const int in = i*n;
|
||||
|
|
2
2025.04.04/dist/Krivoruchenko_SK/solve.h
vendored
2
2025.04.04/dist/Krivoruchenko_SK/solve.h
vendored
|
@ -2,7 +2,7 @@
|
|||
#define SOLVE_H
|
||||
|
||||
int t14_solve(int n, double * restrict A, double * restrict X, int * restrict c);
|
||||
void gauss_inverse(const int n, const int k, double * restrict A, double * restrict X);
|
||||
void gauss_inverse(const int n, const int k, double * restrict A, double * restrict X, double eps);
|
||||
void gauss_back_substitution(const int n, double * restrict A, double * restrict X);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue