Убрал параллельность и векторизацию из 14го Задания, начал писать немного иную версию
This commit is contained in:
parent
b66f83f2ee
commit
fb42c48f7d
15 changed files with 206 additions and 214 deletions
|
@ -1,7 +1,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <time.h>
|
||||
#include <omp.h>
|
||||
#include "array_io.h"
|
||||
#include "io_status.h"
|
||||
#include "matrix.h"
|
||||
|
@ -48,41 +48,28 @@ int main(int argc, char *argv[])
|
|||
return 2;
|
||||
}
|
||||
|
||||
if (name)
|
||||
{ /* из файла */
|
||||
io_status ret;
|
||||
ret = read_matrix(a, n, name);
|
||||
do {
|
||||
switch (ret)
|
||||
{
|
||||
case SUCCESS:
|
||||
continue;
|
||||
case ERROR_OPEN:
|
||||
printf("Cannot open %s\n", name);
|
||||
break;
|
||||
case ERROR_READ:
|
||||
printf("Cannot read %s\n", name);
|
||||
}
|
||||
free(a);
|
||||
free(x);
|
||||
free(c);
|
||||
return 3;
|
||||
} while (0);
|
||||
} else init_matrix(a, n, k);
|
||||
res = read_or_init_matrix(a, name, k, n, true);
|
||||
if (res)
|
||||
{
|
||||
free(a);
|
||||
free(x);
|
||||
free(c);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
init_identity_matrix(x, n);
|
||||
|
||||
#pragma omp simd
|
||||
for (int i = 0; i < n; ++i)
|
||||
c[i] = i;
|
||||
|
||||
printf("Initial matrix:\n");
|
||||
print_matrix(a, n, p);
|
||||
print_matrix(a, n, p, true);
|
||||
|
||||
t = omp_get_wtime();
|
||||
t = clock();
|
||||
res = t14_solve(n, a, x, c);
|
||||
t = omp_get_wtime() - t;
|
||||
|
||||
t = (clock() - t) / CLOCKS_PER_SEC;
|
||||
|
||||
if (res == SINGULAR)
|
||||
{
|
||||
free(a);
|
||||
|
@ -93,33 +80,21 @@ int main(int argc, char *argv[])
|
|||
return 4;
|
||||
}
|
||||
|
||||
if (name)
|
||||
{ /* из файла */
|
||||
io_status ret;
|
||||
ret = read_matrix(a, n, name);
|
||||
do {
|
||||
switch (ret)
|
||||
{
|
||||
case SUCCESS:
|
||||
continue;
|
||||
case ERROR_OPEN:
|
||||
printf("Cannot open %s\n", name);
|
||||
break;
|
||||
case ERROR_READ:
|
||||
printf("Cannot read %s\n", name);
|
||||
}
|
||||
free(a);
|
||||
free(x);
|
||||
free(c);
|
||||
return 3;
|
||||
} while (0);
|
||||
} else init_matrix(a, n, k);
|
||||
|
||||
res = read_or_init_matrix(a, name, k, n, false);
|
||||
if (res)
|
||||
{
|
||||
free(a);
|
||||
free(x);
|
||||
free(c);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
r1 = get_r1(n, a, x);
|
||||
r2 = get_r2(n, a, x);
|
||||
|
||||
printf("Inverse matrix:\n");
|
||||
print_matrix(x, n, p);
|
||||
print_matrix(x, n, p, false);
|
||||
printf("%s : Task = %d Res1 = %e Res2 = %e Elapsed = %.2f K = %d N = %d\n", argv[0], task, r1, r2, t, k, n);
|
||||
|
||||
free(a);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue