Task 4 is done

This commit is contained in:
AZEN-SGG 2025-03-26 16:38:15 +03:00
parent 335d164b10
commit e51e905322
15 changed files with 444 additions and 0 deletions

31
2025.03.28/04Ex/matrix.c Normal file
View file

@ -0,0 +1,31 @@
#include "matrix.h"
#include <math.h>
void init_vec_b(const double * restrict a, double * restrict b, int n)
{
#pragma omp parallel for
for (int i = 0; i < n; ++i)
{
double sum = 0;
#pragma omp simd reduction(+:sum)
for (int k = 1; k < n; k+=2)
sum += a[i * n + k];
b[i] = sum;
}
}
void matvec_mul(int n, const double * restrict A, const double * restrict x, double * restrict x_k)
{
#pragma omp parallel for
for (int i = 0; i < n; i++)
{
double sum = 0;
#pragma omp simd reduction(+:sum)
for (int j = 0; j < n; j++)
sum += A[i * n + j] * x[j];
x_k[i] = sum;
}
}