11#include " mapdata.h"
2+ #ifdef _OPENMP
3+ #include < omp.h>
4+ #endif
25
36template <typename T>
47typename SparseMapData<T>::const_iterator
@@ -46,6 +49,9 @@ DenseMapData *
4649SparseMapData<T>::to_dense() const
4750{
4851 DenseMapData *rv = new DenseMapData (xlen_, ylen_);
52+ #ifdef _OPENMP
53+ #pragma omp parallel for
54+ #endif
4955 for (size_t ix = 0 ; ix < data_.size (); ix++) {
5056 size_t x = offset_ + ix;
5157 const data_element &column = data_[ix];
@@ -190,6 +196,9 @@ SparseMapData<double>::operator*=(const SparseMapData<double> &r)
190196 assert (xlen_ == r.xlen_ );
191197 assert (ylen_ == r.ylen_ );
192198
199+ #ifdef _OPENMP
200+ #pragma omp parallel for
201+ #endif
193202 for (size_t ix = 0 ; ix < data_.size (); ix++) {
194203 size_t x = offset_ + ix;
195204 data_element &column = data_[ix];
@@ -209,6 +218,9 @@ SparseMapData<double>::operator*=(const DenseMapData &r)
209218 assert (xlen_ == r.xdim ());
210219 assert (ylen_ == r.ydim ());
211220
221+ #ifdef _OPENMP
222+ #pragma omp parallel for
223+ #endif
212224 for (size_t ix = 0 ; ix < data_.size (); ix++) {
213225 size_t x = offset_ + ix;
214226 data_element &column = data_[ix];
@@ -225,6 +237,9 @@ template <>
225237SparseMapData<double > &
226238SparseMapData<double >::operator *=(double r)
227239{
240+ #ifdef _OPENMP
241+ #pragma omp parallel for
242+ #endif
228243 for (size_t ix = 0 ; ix < data_.size (); ix++) {
229244 data_element &column = data_[ix];
230245 for (size_t iy = 0 ; iy < column.second .size (); iy++) {
@@ -283,6 +298,9 @@ SparseMapData<double>::operator/=(double r)
283298{
284299 assert (r != 0 );
285300
301+ #ifdef _OPENMP
302+ #pragma omp parallel for
303+ #endif
286304 for (size_t ix = 0 ; ix < data_.size (); ix++) {
287305 data_element &column = data_[ix];
288306 for (size_t iy = 0 ; iy < column.second .size (); iy++) {
@@ -299,6 +317,9 @@ DenseMapData::operator+=(const DenseMapData &r)
299317 assert (xlen_ == r.xlen_ );
300318 assert (ylen_ == r.ylen_ );
301319
320+ #ifdef _OPENMP
321+ #pragma omp parallel for
322+ #endif
302323 for (size_t x = 0 ; x < xlen_; x++) {
303324 for (size_t y = 0 ; y < ylen_; y++) {
304325 (*this )(x, y) += r.at (x, y);
@@ -314,6 +335,9 @@ DenseMapData::operator+=(const SparseMapData<double> &r)
314335 assert (xlen_ == r.xdim ());
315336 assert (ylen_ == r.ydim ());
316337
338+ #ifdef _OPENMP
339+ #pragma omp parallel for
340+ #endif
317341 for (size_t x = 0 ; x < xlen_; x++) {
318342 for (size_t y = 0 ; y < ylen_; y++) {
319343 (*this )(x, y) += r.at (x, y);
@@ -329,6 +353,9 @@ DenseMapData::operator+=(double r)
329353 if (r == 0 )
330354 return *this ;
331355
356+ #ifdef _OPENMP
357+ #pragma omp parallel for
358+ #endif
332359 for (size_t x = 0 ; x < xlen_; x++) {
333360 for (size_t y = 0 ; y < ylen_; y++) {
334361 (*this )(x, y) += r;
@@ -344,6 +371,9 @@ DenseMapData::operator-=(const DenseMapData &r)
344371 assert (xlen_ == r.xlen_ );
345372 assert (ylen_ == r.ylen_ );
346373
374+ #ifdef _OPENMP
375+ #pragma omp parallel for
376+ #endif
347377 for (size_t x = 0 ; x < xlen_; x++) {
348378 for (size_t y = 0 ; y < ylen_; y++) {
349379 (*this )(x, y) -= r.at (x, y);
@@ -359,6 +389,9 @@ DenseMapData::operator-=(const SparseMapData<double> &r)
359389 assert (xlen_ == r.xdim ());
360390 assert (ylen_ == r.ydim ());
361391
392+ #ifdef _OPENMP
393+ #pragma omp parallel for
394+ #endif
362395 for (size_t x = 0 ; x < xlen_; x++) {
363396 for (size_t y = 0 ; y < ylen_; y++) {
364397 (*this )(x, y) -= r.at (x, y);
@@ -374,6 +407,9 @@ DenseMapData::operator-=(double r)
374407 if (r == 0 )
375408 return *this ;
376409
410+ #ifdef _OPENMP
411+ #pragma omp parallel for
412+ #endif
377413 for (size_t x = 0 ; x < xlen_; x++) {
378414 for (size_t y = 0 ; y < ylen_; y++) {
379415 (*this )(x, y) -= r;
@@ -389,6 +425,9 @@ DenseMapData::operator*=(const DenseMapData &r)
389425 assert (xlen_ == r.xlen_ );
390426 assert (ylen_ == r.ylen_ );
391427
428+ #ifdef _OPENMP
429+ #pragma omp parallel for
430+ #endif
392431 for (size_t x = 0 ; x < xlen_; x++) {
393432 for (size_t y = 0 ; y < ylen_; y++) {
394433 (*this )(x, y) *= r.at (x, y);
@@ -404,6 +443,9 @@ DenseMapData::operator*=(const SparseMapData<double> &r)
404443 assert (xlen_ == r.xdim ());
405444 assert (ylen_ == r.ydim ());
406445
446+ #ifdef _OPENMP
447+ #pragma omp parallel for
448+ #endif
407449 for (size_t x = 0 ; x < xlen_; x++) {
408450 for (size_t y = 0 ; y < ylen_; y++) {
409451 (*this )(x, y) *= r.at (x, y);
@@ -416,6 +458,9 @@ DenseMapData::operator*=(const SparseMapData<double> &r)
416458DenseMapData &
417459DenseMapData::operator *=(double r)
418460{
461+ #ifdef _OPENMP
462+ #pragma omp parallel for
463+ #endif
419464 for (size_t x = 0 ; x < xlen_; x++) {
420465 for (size_t y = 0 ; y < ylen_; y++) {
421466 (*this )(x, y) *= r;
@@ -431,6 +476,9 @@ DenseMapData::operator/=(const DenseMapData &r)
431476 assert (xlen_ == r.xlen_ );
432477 assert (ylen_ == r.ylen_ );
433478
479+ #ifdef _OPENMP
480+ #pragma omp parallel for
481+ #endif
434482 for (size_t x = 0 ; x < xlen_; x++) {
435483 for (size_t y = 0 ; y < ylen_; y++) {
436484 (*this )(x, y) /= r.at (x, y);
@@ -446,6 +494,9 @@ DenseMapData::operator/=(const SparseMapData<double> &r)
446494 assert (xlen_ == r.xdim ());
447495 assert (ylen_ == r.ydim ());
448496
497+ #ifdef _OPENMP
498+ #pragma omp parallel for
499+ #endif
449500 for (size_t x = 0 ; x < xlen_; x++) {
450501 for (size_t y = 0 ; y < ylen_; y++) {
451502 (*this )(x, y) /= r.at (x, y);
@@ -458,6 +509,9 @@ DenseMapData::operator/=(const SparseMapData<double> &r)
458509DenseMapData &
459510DenseMapData::operator /=(double r)
460511{
512+ #ifdef _OPENMP
513+ #pragma omp parallel for
514+ #endif
461515 for (size_t x = 0 ; x < xlen_; x++) {
462516 for (size_t y = 0 ; y < ylen_; y++) {
463517 (*this )(x, y) /= r;
0 commit comments