#pragma omp parallel private(i, j)
{
#pragma omp for
for (i = 0; i < N; i++)
{
for (j = RowIndex[i]; j < RowIndex[i + 1]; j++)
result[i] += val[j] * vector[col[j]];
}
}
#pragma omp parallel private(i, j)
{
#pragma omp for
for (i = 0; i < N; i++)
{
if (i != col[j])
{
result[col[j]] += val[j] * vector[i];
}
}
}
#pragma omp parallel for private (i, j)
for (i = 0; i < N; i++)
{
for ( j=RowIndex[i]; j<RowIndex[i + 1]; j++)
{
if (i == col[j])
result[i] += val[j] * vector[col[j]];
else
{
result[i] += val[j] * vector[col[j]];
#pragma omp atomic
result[col[j]] += val[j] * vector[i];
}
}