Решил, вроде как, задачку... Работает всё правильно. Вот код:
#include <stdio.h>
#include <math.h>
#include <omp.h>
#define N 4
#define eps 0.0001
void jacobi(double a[N][N], double b[N], double x[N])
{
int i, j;
double vectorNorm;
double currentX[N];
do {
vectorNorm = 0.0;
#pragma omp parallel for private(i, j)
for(i = 0; i < N; i++) {
currentX[i] = -b[i];
for(j = 0; j < N; j++) {
if(i != j)
currentX[i] += a[i][j] * x[j];
}
currentX[i] /= -a[i][i];
}
#pragma omp parallel for
for(i = 0; i < N; i++) {
if(fabs(x[i] - currentX[i]) > vectorNorm)
vectorNorm = fabs(x[i] - currentX[i]);
x[i] = currentX[i];
}
}
while(vectorNorm > eps);
}
int main() {
int i, j;
double matrixA[N][N] = {
{2,0,0,0},
{1,2,0,0},
{3,1,2,0},
{3,2,1,3}
};
double vectorB[N] = {1,1,1,1}, vectorX[N];
jacobi(matrixA, vectorB, vectorX);
printf("Vector X:\n");
for (i = 0; i < N; i++) {
printf("%.3f ", vectorX[i]);
}
printf("\n");
return 0;
}