## Pthreads. Solve system by Gauss-Jordan method. Problem of Optim. -O3

Hi! I need in help! I have a problem: solve the system of equations by the Gauss-Jordan methods with pthreads.
I have a big matrix A (for example 2000x2000), so i must solve Ax = b.
Before I devide matrix to number of threads and each thread must work only with his peace of matrix.
Code:
```#include <iostream>
#include "synchronize.h"

using namespace std;

typedef struct _ARGS
{

double * a;
double * b;
int n;

int rs;
int re;
} ARGS;

double getfulltime();

void *work (void *ptr)
{
ARGS * arg = (ARGS*) ptr;

int n = arg->n;

double tmp;

int i, k, j;

for (i = 0; i < n; i++)
{
if (i <= arg->re && i >= arg->rs)
{
tmp = arg->a[i*n + i];

for (k = i; k < n; k++)
arg->a[i*n + k] /= tmp;
arg->b[i] /= tmp;
}

if (i > arg->re || i < arg->rs)
{
for (j = arg->rs; j <= arg->re; j++)
{
tmp = arg->a[j * n + i];
for (k = i; k < n; k++)
arg->a[j*n + k] -= arg->a[i*n + k]*tmp;

arg->b[j] -= arg->b[i] * tmp;
}

}
else
{
for (j = arg->rs; j < i; j++)
{
tmp = arg->a[j * n + i];

for (k = i; k < n; k++)
arg->a[j*n + k] -= arg->a[i*n + k] * tmp;
arg->b[j] -= arg->b[i] * tmp;
}
for (j = i + 1; j <= arg->re; j++)
{
tmp = arg->a[j * n + i];
for (k = i; k < n; k++)
arg->a[j*n + k] -= arg->a[i*n + k] * tmp;
arg->b[j] -= arg->b[i] * tmp;
}
}
}

return NULL;
}

double solve_system(int n, double* A, double* b, double**x, int fullthr)
{

ARGS *args;

int rowPerthr = n/fullthr;

{
return 1;
}

if (!(args = (ARGS*) malloc (fullthr * sizeof(ARGS))))
{
cout<<"ARGS allocation error";
return 1;
}

for (int i = 0; i < fullthr; i++)
{
args[i].n = n;
args[i].a = A;
args[i].b = b;
if(i == fullthr - 1)
{
args[i].rs = i*rowPerthr;
args[i].re = n - 1;
}
else
{
args[i].rs = i*rowPerthr;
args[i].re = (i + 1)*rowPerthr - 1;

}
}

int i;

double t = getfulltime();

for (i = 0; i < fullthr; i++)