Answer the question
In order to leave comments, you need to log in
Parallel programming, what operations should be divided into?
Good afternoon, I need to write the last. and parallel versions of a program that solves slough by square roots.
Wrote last. and I have been sitting for a long time thinking how to parallelize it. After all, in order to proceed to the next step of the solution, you need to wait for the results of the previous step.
code fragment where the solution is calculated.
// A = U(t)*U, далее находим U and U(t)
double temp;
double[,] U = new double[n, n];
for(int i=0;i<n;i++)
for (int j=0;j<n;j++)
{
U[i, j] = 0;
}
for (int i = 0; i < n; i++)
{
temp = 0;
for (int k=0;k<i;k++)
temp = temp + Math.Pow(U[k, i], 2);
U[i, i] =Math.Sqrt(A[i, i] - temp);
for (int j = i; j < n; j++)
{
temp = 0;
for (int k = 0; k < i; k++)
temp = temp + U[k, i] * U[k, j];
U[i, j] = (A[i, j] - temp) / U[i, i];
}
}
for (int i = 0; i<n;i++)
{
for (int j=0; j < n; j++)
{
Console.Write("{0} ", U[i, j]);
}
Console.WriteLine();
}
double[] x = new double[n];
double[] y = new double[n];
for (int i=0;i<n;i++)
{
temp = 0;
for(int k=0;k<i;k++)
temp = temp + U[k, i] * y[k];
y[i] = (b[i] - temp) / U[i, i];
}
for(int i=n-1;i>=0;i--)
{
temp = 0;
for (int k = i + 1; k < n; k++)
temp = temp + U[i, k] * x[k];
x[i] = (y[i] - temp) / U[i, i];
}
for (int i = 0; i < n; i++)
Console.Write("{0} ", x[i]);
Console.WriteLine();
Answer the question
In order to leave comments, you need to log in
The first parallel is:
for (int k = 0; k < i; k++)
temp = temp + U[k, i] * U[k, j];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question