Skip to content

Commit 30cf8b3

Browse files
committed
Clang-Tidy: Clean-Up include cpp for src/basic_op.cpp
1 parent 26db5e8 commit 30cf8b3

17 files changed

+114
-118
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
Data_* right = static_cast<Data_*> (r);
1+
auto right = dynamic_cast<Data_*> (r);
22

3-
ULong nEl = N_Elements();
3+
const auto nEl = static_cast<OMPInt>(N_Elements());
44
assert(nEl);
55
if (nEl == 1) {
66
if ((*right)[0] == zero) (*this)[0] = zero;
@@ -11,7 +11,7 @@
1111
for (OMPInt i = 0; i < nEl; ++i) if ((*right)[i] == zero) (*this)[i] = zero;
1212
} else {
1313
TRACEOMP(__FILE__, __LINE__)
14-
#pragma omp parallel for num_threads(GDL_NTHREADS)
15-
for (OMPInt i = 0; i < nEl; ++i) if ((*right)[i] == zero) (*this)[i] = zero;
14+
#pragma omp parallel for num_threads(GDL_NTHREADS) default(none) shared(nEl, right)
15+
for (OMPInt i = 0; i < nEl; ++i) if ((*right)[i] == zero) (*this)[i] = zero;
1616
}
17-
return this;
17+
return this;
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
TRACE_ROUTINE(__FUNCTION__, __FILE__, __LINE__)
2-
Data_* right = static_cast<Data_*> (r);
1+
TRACE_ROUTINE(__FUNCTION__, __FILE__, __LINE__)
2+
auto right = dynamic_cast<Data_*> (r);
33

4-
ULong nEl = N_Elements();
4+
const auto nEl = static_cast<OMPInt>(N_Elements());
55
assert(nEl);
66
if (nEl == 1) {
7-
if ((*this)[0] != zero) (*this)[0] = (*right)[0];
8-
return this;
7+
if ((*this)[0] != zero) (*this)[0] = (*right)[0];
8+
return this;
99
}
1010

1111
if ((GDL_NTHREADS = parallelize(nEl)) == 1) {
12-
for (OMPInt i = 0; i < nEl; ++i) if ((*this)[i] != zero) (*this)[i] = (*right)[i];
12+
for (OMPInt i = 0; i < nEl; ++i) if ((*this)[i] != zero) (*this)[i] = (*right)[i];
1313
} else {
14-
TRACEOMP(__FILE__, __LINE__)
15-
#pragma omp parallel for num_threads(GDL_NTHREADS)
16-
for (OMPInt i = 0; i < nEl; ++i) if ((*this)[i] != zero) (*this)[i] = (*right)[i];
14+
TRACEOMP(__FILE__, __LINE__)
15+
#pragma omp parallel for num_threads(GDL_NTHREADS) default(none) shared(nEl, right)
16+
for (OMPInt i = 0; i < nEl; ++i) if ((*this)[i] != zero) (*this)[i] = (*right)[i];
1717
}
18-
return this;
18+
return this;
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
TRACE_ROUTINE(__FUNCTION__,__FILE__,__LINE__)
2-
Data_* right = static_cast<Data_*> (r);
2+
auto right = dynamic_cast<Data_*> (r);
33

4-
ULong nEl = N_Elements();
4+
const auto nEl = static_cast<OMPInt>(N_Elements());
55

66
assert(nEl);
77
Ty s = (*right)[0];
88
if (s == zero) {
99
{
10-
for (SizeT i = 0; i < nEl; ++i)
10+
for (OMPInt i = 0; i < nEl; ++i)
1111
(*this)[i] = zero;
1212
}
1313
} else {
@@ -20,8 +20,8 @@ TRACE_ROUTINE(__FUNCTION__,__FILE__,__LINE__)
2020
for (OMPInt i = 0; i < nEl; ++i) if ((*this)[i] != zero) (*this)[i] = s;
2121
} else {
2222
TRACEOMP(__FILE__, __LINE__)
23-
#pragma omp parallel for num_threads(GDL_NTHREADS)
24-
for (OMPInt i = 0; i < nEl; ++i) if ((*this)[i] != zero) (*this)[i] = s;
23+
#pragma omp parallel for num_threads(GDL_NTHREADS) default(none) shared(nEl, s)
24+
for (OMPInt i = 0; i < nEl; ++i) if ((*this)[i] != zero) (*this)[i] = s;
2525
}
2626
}
27-
return this;
27+
return this;

src/snippets/basic_op_GeOpCplx.incpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
Data_* right = static_cast<Data_*> (r);
1+
auto right = dynamic_cast<Data_*> (r);
22

3-
ULong rEl = right->N_Elements();
4-
ULong nEl = N_Elements();
3+
const auto rEl = static_cast<OMPInt>(right->N_Elements());
4+
const auto nEl = static_cast<OMPInt>(N_Elements());
55
assert(rEl);
66
assert(nEl);
77

@@ -19,8 +19,8 @@
1919
for (OMPInt i = 0; i < nEl; ++i) (*res)[i] = (std::norm((*this)[i]) >= std::norm(s));
2020
} else {
2121
TRACEOMP(__FILE__, __LINE__)
22-
#pragma omp parallel for num_threads(GDL_NTHREADS)
23-
for (OMPInt i = 0; i < nEl; ++i) (*res)[i] = (std::norm((*this)[i]) >= std::norm(s));
22+
#pragma omp parallel for num_threads(GDL_NTHREADS) default(none) shared(nEl, res, s)
23+
for (OMPInt i = 0; i < nEl; ++i) (*res)[i] = (std::norm((*this)[i]) >= std::norm(s));
2424
}
2525
} else if (StrictScalar(s)) {
2626
res = new Data_<SpDByte>(right->dim, BaseGDL::NOZERO);
@@ -33,8 +33,8 @@
3333
for (OMPInt i = 0; i < rEl; ++i) (*res)[i] = (std::norm((*right)[i]) <= std::norm(s));
3434
} else {
3535
TRACEOMP(__FILE__, __LINE__)
36-
#pragma omp parallel for num_threads(GDL_NTHREADS)
37-
for (OMPInt i = 0; i < rEl; ++i) (*res)[i] = (std::norm((*right)[i]) <= std::norm(s));
36+
#pragma omp parallel for num_threads(GDL_NTHREADS) default(none) shared(rEl, res, right, s)
37+
for (OMPInt i = 0; i < rEl; ++i) (*res)[i] = (std::norm((*right)[i]) <= std::norm(s));
3838
}
3939
} else if (rEl < nEl) {
4040
res = new Data_<SpDByte>(right->dim, BaseGDL::NOZERO);
@@ -43,8 +43,8 @@
4343
for (OMPInt i = 0; i < rEl; ++i) (*res)[i] = (std::norm((*right)[i]) <= std::norm((*this)[i]));
4444
} else {
4545
TRACEOMP(__FILE__, __LINE__)
46-
#pragma omp parallel for num_threads(GDL_NTHREADS)
47-
for (OMPInt i = 0; i < rEl; ++i) (*res)[i] = (std::norm((*right)[i]) <= std::norm((*this)[i]));
46+
#pragma omp parallel for num_threads(GDL_NTHREADS) default(none) shared(rEl, res, right)
47+
for (OMPInt i = 0; i < rEl; ++i) (*res)[i] = (std::norm((*right)[i]) <= std::norm((*this)[i]));
4848
}
4949
} else // ( rEl >= nEl)
5050
{
@@ -58,9 +58,8 @@
5858
for (OMPInt i = 0; i < nEl; ++i) (*res)[i] = (std::norm((*right)[i]) <= std::norm((*this)[i]));
5959
} else {
6060
TRACEOMP(__FILE__, __LINE__)
61-
#pragma omp parallel for num_threads(GDL_NTHREADS)
62-
for (OMPInt i = 0; i < nEl; ++i) (*res)[i] = (std::norm((*right)[i]) <= std::norm((*this)[i]));
61+
#pragma omp parallel for num_threads(GDL_NTHREADS) default(none) shared(nEl, res, right)
62+
for (OMPInt i = 0; i < nEl; ++i) (*res)[i] = (std::norm((*right)[i]) <= std::norm((*this)[i]));
6363
}
6464
}
65-
return res;
66-
65+
return res;
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
Data_* right = static_cast<Data_*> (r);
1+
auto right = dynamic_cast<Data_*> (r);
22

3-
ULong nEl = N_Elements();
3+
const auto nEl = static_cast<OMPInt>(N_Elements());
44
assert(nEl);
55
if (nEl == 1) {
66
if (std::norm((*this)[0]) < std::norm((*right)[0])) (*this)[0] = (*right)[0];
@@ -11,7 +11,7 @@
1111
for (OMPInt i = 0; i < nEl; ++i) if (std::norm((*this)[i]) < std::norm((*right)[i])) (*this)[i] = (*right)[i];
1212
} else {
1313
TRACEOMP(__FILE__, __LINE__)
14-
#pragma omp parallel for num_threads(GDL_NTHREADS)
14+
#pragma omp parallel for num_threads(GDL_NTHREADS) default(none) shared(nEl, right)
1515
for (OMPInt i = 0; i < nEl; ++i) if (std::norm((*this)[i]) < std::norm((*right)[i])) (*this)[i] = (*right)[i];
1616
}
17-
return this;
17+
return this;

src/snippets/basic_op_GtMarkSCplx.incpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
Data_* right = static_cast<Data_*> (r);
1+
auto right = dynamic_cast<Data_*> (r);
22

3-
ULong nEl = N_Elements();
3+
const auto nEl = static_cast<OMPInt>(N_Elements());
44
assert(nEl);
55
if (nEl == 1) {
66
if (std::norm((*this)[0]) < std::norm((*right)[0])) (*this)[0] = (*right)[0];
@@ -13,7 +13,7 @@
1313
for (OMPInt i = 0; i < nEl; ++i) if (std::norm((*this)[i]) < snorm) (*this)[i] = s;
1414
} else {
1515
TRACEOMP(__FILE__, __LINE__)
16-
#pragma omp parallel for num_threads(GDL_NTHREADS)
16+
#pragma omp parallel for num_threads(GDL_NTHREADS) default(none) shared(nEl, s, snorm)
1717
for (OMPInt i = 0; i < nEl; ++i) if (std::norm((*this)[i]) < snorm) (*this)[i] = s;
1818
}
1919
return this;

src/snippets/basic_op_GtOpCplx.incpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
Data_* right = static_cast<Data_*> (r);
1+
auto right = dynamic_cast<Data_*> (r);
22

3-
ULong rEl = right->N_Elements();
4-
ULong nEl = N_Elements();
3+
const auto rEl = static_cast<OMPInt>(right->N_Elements());
4+
const auto nEl = static_cast<OMPInt>(N_Elements());
55
assert(rEl);
66
assert(nEl);
77

@@ -19,8 +19,8 @@
1919
for (OMPInt i = 0; i < nEl; ++i) (*res)[i] = (std::norm((*this)[i]) > std::norm(s));
2020
} else {
2121
TRACEOMP(__FILE__, __LINE__)
22-
#pragma omp parallel for num_threads(GDL_NTHREADS)
23-
for (OMPInt i = 0; i < nEl; ++i) (*res)[i] = (std::norm((*this)[i]) > std::norm(s));
22+
#pragma omp parallel for num_threads(GDL_NTHREADS) default(none) shared(nEl, res, s)
23+
for (OMPInt i = 0; i < nEl; ++i) (*res)[i] = (std::norm((*this)[i]) > std::norm(s));
2424
}
2525
} else if (StrictScalar(s)) {
2626
res = new Data_<SpDByte>(right->dim, BaseGDL::NOZERO);
@@ -33,8 +33,8 @@
3333
for (OMPInt i = 0; i < rEl; ++i) (*res)[i] = (std::norm((*right)[i]) < std::norm(s));
3434
} else {
3535
TRACEOMP(__FILE__, __LINE__)
36-
#pragma omp parallel for num_threads(GDL_NTHREADS)
37-
for (OMPInt i = 0; i < rEl; ++i) (*res)[i] = (std::norm((*right)[i]) < std::norm(s));
36+
#pragma omp parallel for num_threads(GDL_NTHREADS) default(none) shared(rEl, res, right, s)
37+
for (OMPInt i = 0; i < rEl; ++i) (*res)[i] = (std::norm((*right)[i]) < std::norm(s));
3838
}
3939
} else if (rEl < nEl) {
4040
res = new Data_<SpDByte>(right->dim, BaseGDL::NOZERO);
@@ -43,8 +43,8 @@
4343
for (OMPInt i = 0; i < rEl; ++i) (*res)[i] = (std::norm((*right)[i]) < std::norm((*this)[i]));
4444
} else {
4545
TRACEOMP(__FILE__, __LINE__)
46-
#pragma omp parallel for num_threads(GDL_NTHREADS)
47-
for (OMPInt i = 0; i < rEl; ++i) (*res)[i] = (std::norm((*right)[i]) < std::norm((*this)[i]));
46+
#pragma omp parallel for num_threads(GDL_NTHREADS) default(none) shared(rEl, res, right)
47+
for (OMPInt i = 0; i < rEl; ++i) (*res)[i] = (std::norm((*right)[i]) < std::norm((*this)[i]));
4848
}
4949
} else // ( rEl >= nEl)
5050
{
@@ -58,9 +58,8 @@
5858
for (OMPInt i = 0; i < nEl; ++i) (*res)[i] = (std::norm((*right)[i]) < std::norm((*this)[i]));
5959
} else {
6060
TRACEOMP(__FILE__, __LINE__)
61-
#pragma omp parallel for num_threads(GDL_NTHREADS)
62-
for (OMPInt i = 0; i < nEl; ++i) (*res)[i] = (std::norm((*right)[i]) < std::norm((*this)[i]));
61+
#pragma omp parallel for num_threads(GDL_NTHREADS) default(none) shared(nEl, res, right)
62+
for (OMPInt i = 0; i < nEl; ++i) (*res)[i] = (std::norm((*right)[i]) < std::norm((*this)[i]));
6363
}
6464
}
65-
return res;
66-
65+
return res;

src/snippets/basic_op_LeOpCplx.incpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
Data_* right = static_cast<Data_*> (r);
1+
auto right = dynamic_cast<Data_*> (r);
22

3-
ULong rEl = right->N_Elements();
4-
ULong nEl = N_Elements();
3+
const auto rEl = static_cast<OMPInt>(right->N_Elements());
4+
const auto nEl = static_cast<OMPInt>(N_Elements());
55
assert(rEl);
66
assert(nEl);
77

@@ -19,8 +19,8 @@
1919
for (OMPInt i = 0; i < nEl; ++i) (*res)[i] = (std::norm((*this)[i]) <= std::norm(s));
2020
} else {
2121
TRACEOMP(__FILE__, __LINE__)
22-
#pragma omp parallel for num_threads(GDL_NTHREADS)
23-
for (OMPInt i = 0; i < nEl; ++i) (*res)[i] = (std::norm((*this)[i]) <= std::norm(s));
22+
#pragma omp parallel for num_threads(GDL_NTHREADS) default(none) shared(nEl, res, s)
23+
for (OMPInt i = 0; i < nEl; ++i) (*res)[i] = (std::norm((*this)[i]) <= std::norm(s));
2424
}
2525
} else if (StrictScalar(s)) {
2626
res = new Data_<SpDByte>(right->dim, BaseGDL::NOZERO);
@@ -33,8 +33,8 @@
3333
for (OMPInt i = 0; i < rEl; ++i) (*res)[i] = (std::norm((*right)[i]) >= std::norm(s));
3434
} else {
3535
TRACEOMP(__FILE__, __LINE__)
36-
#pragma omp parallel for num_threads(GDL_NTHREADS)
37-
for (OMPInt i = 0; i < rEl; ++i) (*res)[i] = (std::norm((*right)[i]) >= std::norm(s));
36+
#pragma omp parallel for num_threads(GDL_NTHREADS) default(none) shared(rEl, res, right, s)
37+
for (OMPInt i = 0; i < rEl; ++i) (*res)[i] = (std::norm((*right)[i]) >= std::norm(s));
3838
}
3939
} else if (rEl < nEl) {
4040
res = new Data_<SpDByte>(right->dim, BaseGDL::NOZERO);
@@ -43,8 +43,8 @@
4343
for (OMPInt i = 0; i < rEl; ++i) (*res)[i] = (std::norm((*right)[i]) >= std::norm((*this)[i]));
4444
} else {
4545
TRACEOMP(__FILE__, __LINE__)
46-
#pragma omp parallel for num_threads(GDL_NTHREADS)
47-
for (OMPInt i = 0; i < rEl; ++i) (*res)[i] = (std::norm((*right)[i]) >= std::norm((*this)[i]));
46+
#pragma omp parallel for num_threads(GDL_NTHREADS) default(none) shared(rEl, res, right)
47+
for (OMPInt i = 0; i < rEl; ++i) (*res)[i] = (std::norm((*right)[i]) >= std::norm((*this)[i]));
4848
}
4949
} else // ( rEl >= nEl)
5050
{
@@ -58,9 +58,8 @@
5858
for (OMPInt i = 0; i < nEl; ++i) (*res)[i] = (std::norm((*right)[i]) >= std::norm((*this)[i]));
5959
} else {
6060
TRACEOMP(__FILE__, __LINE__)
61-
#pragma omp parallel for num_threads(GDL_NTHREADS)
62-
for (OMPInt i = 0; i < nEl; ++i) (*res)[i] = (std::norm((*right)[i]) >= std::norm((*this)[i]));
61+
#pragma omp parallel for num_threads(GDL_NTHREADS) default(none) shared(nEl, res, right)
62+
for (OMPInt i = 0; i < nEl; ++i) (*res)[i] = (std::norm((*right)[i]) >= std::norm((*this)[i]));
6363
}
6464
}
65-
return res;
66-
65+
return res;
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
Data_* right = static_cast<Data_*> (r);
1+
auto right = dynamic_cast<Data_*> (r);
22

3-
ULong nEl = N_Elements();
3+
const auto nEl = static_cast<OMPInt>(N_Elements());
44
assert(nEl);
55
if (nEl == 1) {
66
if (std::norm((*this)[0]) > std::norm((*right)[0])) (*this)[0] = (*right)[0];
@@ -11,7 +11,7 @@
1111
for (OMPInt i = 0; i < nEl; ++i) if (std::norm((*this)[i]) > std::norm((*right)[i])) (*this)[i] = (*right)[i];
1212
} else {
1313
TRACEOMP(__FILE__, __LINE__)
14-
#pragma omp parallel for num_threads(GDL_NTHREADS)
14+
#pragma omp parallel for num_threads(GDL_NTHREADS) default(none) shared(nEl, right)
1515
for (OMPInt i = 0; i < nEl; ++i) if (std::norm((*this)[i]) > std::norm((*right)[i])) (*this)[i] = (*right)[i];
1616
}
17-
return this;
17+
return this;

src/snippets/basic_op_LtMarkSCplx.incpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
Data_* right = static_cast<Data_*> (r);
1+
auto right = dynamic_cast<Data_*> (r);
22

3-
ULong nEl = N_Elements();
3+
const auto nEl = static_cast<OMPInt>(N_Elements());
44
assert(nEl);
55
if (nEl == 1) {
66
if (std::norm((*this)[0]) > std::norm((*right)[0])) (*this)[0] = (*right)[0];
@@ -13,7 +13,7 @@
1313
for (OMPInt i = 0; i < nEl; ++i) if (std::norm((*this)[i]) > snorm) (*this)[i] = s;
1414
} else {
1515
TRACEOMP(__FILE__, __LINE__)
16-
#pragma omp parallel for num_threads(GDL_NTHREADS)
16+
#pragma omp parallel for num_threads(GDL_NTHREADS) default(none) shared(nEl, s, snorm)
1717
for (OMPInt i = 0; i < nEl; ++i) if (std::norm((*this)[i]) > snorm) (*this)[i] = s;
1818
}
19-
return this;
19+
return this;

0 commit comments

Comments
 (0)