Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫  π  -¹ ² ³ °

You are not logged in.

## #1 Re: Coder's Corner » Gram-Schmidt matrix factorization in C++ » 2013-01-09 04:32:12

bobbym wrote:

Hi;

What was the error message the compiler gave?

There aren't compiler's errors, but the application produces bad, meaningless results.
(completely different than non-parallel version)

## #2 Re: Coder's Corner » Gram-Schmidt matrix factorization in C++ » 2013-01-06 23:21:28

I found a solution:

``````    int k, i, j;
for (k=0; k<3; k++)
{
r[k][k]=0; // equivalent to sum = 0
for (i=0; i<3; i++)
r[k][k] = r[k][k] + a[i][k] * a[i][k]; // rkk = sqr(a0k) + sqr(a1k) + sqr(a2k)
r[k][k] = sqrt(r[k][k]);  // ||a||

for (i=0; i<3; i++)
q[i][k] = a[i][k]/r[k][k];

for(j=k+1; j<3; j++) {
r[k][j]=0;
for(i=0; i<3; i++) r[k][j] += q[i][k] * a[i][j];
for (i=0; i<3; i++) a[i][j] = a[i][j] - r[k][j]*q[i][k];

}``````

I have tested this and it's working good.
But now I must parallelize this code using OpenMP (it's the project for my college) and
I have a new problem. I try parallelize the main "for":

``````int k, i, j;
#pragma omp parallel for private (k, i, j) shared (a, q, r)
// ........``````

but it doesn't work correctly. I noticed that the problematic fragment is:

``````for (i=0; i<3; i++)
q[i][k] = a[i][k]/r[k][k];``````

but I don't know why it makes a problem...

Anybody help ?

## #3 Coder's Corner » Gram-Schmidt matrix factorization in C++ » 2012-12-25 05:49:02

Giewont
Replies: 5

Hello !

I'm very beginner in numerical methods... I have the pseudo-code
(look at image), but I don't know how intrepret this and how
I can implement this in C++...

Can You help me ?

## Board footer

Powered by FluxBB