Browse Source

optymalizacja 5x

master
Piotr Dergun 8 years ago
parent
commit
7f2ae606f8
1 changed files with 6 additions and 3 deletions
  1. +6
    -3
      DergunPiotr-WaskoDominik/zad2/macierz_mpi.cpp

+ 6
- 3
DergunPiotr-WaskoDominik/zad2/macierz_mpi.cpp View File

@ -66,9 +66,9 @@ int main(int argc, char *argv[])
exit(1); exit(1);
} }
if (rozmiar <= 0 || rozmiar > 2000)
if (rozmiar <= 0)
{ {
cerr << "The number of matrix dimension must be in range [1,2000]" << endl;
cerr << "The number of matrix dimension must be positive" << endl;
exit(1); exit(1);
} }
@ -150,9 +150,12 @@ int main(int argc, char *argv[])
for (i=0; i<porcja_new; ++i) for (i=0; i<porcja_new; ++i)
{ {
vect_c[i] = 0; vect_c[i] = 0;
long a_row = i%rozmiar;
long vect_col = (i/rozmiar)*rozmiar;
for (long k=0; k<rozmiar; ++k) for (long k=0; k<rozmiar; ++k)
{ {
vect_c[i] += A[i%rozmiar][k]*vect[(i/rozmiar)*rozmiar+k];
vect_c[i] += A[a_row][k]*vect[vect_col];
++vect_col;
} }
} }

Loading…
Cancel
Save