Skip to content

Commit 0e4c52a

Browse files
committed
[Math] Use std::experimental::simd subset of Vc API in GenVector
Using the subset of the Vc API that is also part of `std::experimental::simd` makes it possible to transparently use `std::experimental::simd` as a GenVector template parameter.
1 parent a8cbca6 commit 0e4c52a

File tree

8 files changed

+42
-42
lines changed

8 files changed

+42
-42
lines changed

math/experimental/genvectorx/inc/MathX/GenVectorX/DisplacementVector3D.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ class DisplacementVector3D {
344344
DisplacementVector3D Unit() const
345345
{
346346
SCALAR tot = R();
347-
tot(tot == SCALAR(0)) = SCALAR(1);
347+
where(tot == SCALAR(0), tot) = SCALAR(1);
348348
return DisplacementVector3D(*this) / tot;
349349
}
350350

@@ -681,7 +681,7 @@ operator<<(std::basic_ostream<char_t, traits_t> &os, DisplacementVector3D<T, U>
681681
{
682682
if (os) {
683683
os << "{ ";
684-
for (std::size_t i = 0; i < PositionVector3D<T, U>::Scalar::Size; ++i) {
684+
for (std::size_t i = 0; i < PositionVector3D<T, U>::Scalar::size(); ++i) {
685685
os << "(" << v.x()[i] << "," << v.y()[i] << "," << v.z()[i] << ") ";
686686
}
687687
os << "}";

math/experimental/genvectorx/inc/MathX/GenVectorX/Plane3D.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ class Plane3D {
242242
// what to do if s = 0 ?
243243
const auto m = (s == SCALAR(0));
244244
// set zero entries to 1 in the vector to avoid /0 later on
245-
s(m) = SCALAR(1);
246-
fD(m) = SCALAR(0);
245+
where(m, s) = SCALAR(1);
246+
where(m, fD) = SCALAR(0);
247247
const SCALAR w = SCALAR(1) / s;
248248
fA *= w;
249249
fB *= w;

math/experimental/genvectorx/inc/MathX/GenVectorX/PositionVector3D.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ operator<<(std::basic_ostream<char_t, traits_t> &os, PositionVector3D<T, U> cons
646646
{
647647
if (os) {
648648
os << "{ ";
649-
for (std::size_t i = 0; i < PositionVector3D<T, U>::Scalar::Size; ++i) {
649+
for (std::size_t i = 0; i < PositionVector3D<T, U>::Scalar::size(); ++i) {
650650
os << "(" << v.x()[i] << "," << v.y()[i] << "," << v.z()[i] << ") ";
651651
}
652652
os << "}";

math/experimental/genvectorx/inc/MathX/GenVectorX/Transform3D.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ class Transform3D {
859859
const auto detZmask = (det == T(0));
860860
if (any_of(detZmask)) {
861861
std::cerr << "Transform3D::inverse error: zero determinant" << std::endl;
862-
det(detZmask) = T(1);
862+
where(detZmask, det) = T(1);
863863
}
864864
det = T(1) / det;
865865
detxx *= det;
@@ -873,15 +873,15 @@ class Transform3D {
873873
T detzz = (fM[kXX] * fM[kYY] - fM[kXY] * fM[kYX]) * det;
874874
// Set det=0 cases to 0
875875
if (any_of(detZmask)) {
876-
detxx(detZmask) = T(0);
877-
detxy(detZmask) = T(0);
878-
detxz(detZmask) = T(0);
879-
detyx(detZmask) = T(0);
880-
detyy(detZmask) = T(0);
881-
detyz(detZmask) = T(0);
882-
detzx(detZmask) = T(0);
883-
detzy(detZmask) = T(0);
884-
detzz(detZmask) = T(0);
876+
where(detZmask, detxx) = T(0);
877+
where(detZmask, detxy) = T(0);
878+
where(detZmask, detxz) = T(0);
879+
where(detZmask, detyx) = T(0);
880+
where(detZmask, detyy) = T(0);
881+
where(detZmask, detyz) = T(0);
882+
where(detZmask, detzx) = T(0);
883+
where(detZmask, detzy) = T(0);
884+
where(detZmask, detzz) = T(0);
885885
}
886886
// set final components
887887
SetComponents(detxx, -detyx, detzx, -detxx * fM[kDX] + detyx * fM[kDY] - detzx * fM[kDZ], -detxy, detyy, -detzy,

math/genvector/inc/Math/GenVector/DisplacementVector3D.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ namespace ROOT {
345345
DisplacementVector3D Unit() const
346346
{
347347
SCALAR tot = R();
348-
tot(tot == SCALAR(0)) = SCALAR(1);
348+
where(tot == SCALAR(0), tot) = SCALAR(1);
349349
return DisplacementVector3D(*this) / tot;
350350
}
351351

@@ -660,7 +660,7 @@ namespace ROOT {
660660
{
661661
if (os) {
662662
os << "{ ";
663-
for (std::size_t i = 0; i < PositionVector3D<T, U>::Scalar::Size; ++i) {
663+
for (std::size_t i = 0; i < PositionVector3D<T, U>::Scalar::size(); ++i) {
664664
os << "(" << v.x()[i] << "," << v.y()[i] << "," << v.z()[i] << ") ";
665665
}
666666
os << "}";

math/genvector/inc/Math/GenVector/Plane3D.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ class Plane3D {
244244
// what to do if s = 0 ?
245245
const auto m = (s == SCALAR(0));
246246
// set zero entries to 1 in the vector to avoid /0 later on
247-
s(m) = SCALAR(1);
248-
fD(m) = SCALAR(0);
247+
where(m, s) = SCALAR(1);
248+
where(m, fD) = SCALAR(0);
249249
const SCALAR w = SCALAR(1) / s;
250250
fA *= w;
251251
fB *= w;

math/genvector/inc/Math/GenVector/PositionVector3D.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ namespace ROOT {
616616
{
617617
if (os) {
618618
os << "{ ";
619-
for (std::size_t i = 0; i < PositionVector3D<T, U>::Scalar::Size; ++i) {
619+
for (std::size_t i = 0; i < PositionVector3D<T, U>::Scalar::size(); ++i) {
620620
os << "(" << v.x()[i] << "," << v.y()[i] << "," << v.z()[i] << ") ";
621621
}
622622
os << "}";

math/genvector/inc/Math/GenVector/Transform3D.h

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ class Transform3D {
838838
const auto detZmask = (det == T(0));
839839
if (any_of(detZmask)) {
840840
std::cerr << "Transform3D::inverse error: zero determinant" << std::endl;
841-
det(detZmask) = T(1);
841+
where(detZmask, det) = T(1);
842842
}
843843
det = T(1) / det;
844844
detxx *= det;
@@ -852,15 +852,15 @@ class Transform3D {
852852
T detzz = (fM[kXX] * fM[kYY] - fM[kXY] * fM[kYX]) * det;
853853
// Set det=0 cases to 0
854854
if (any_of(detZmask)) {
855-
detxx(detZmask) = T(0);
856-
detxy(detZmask) = T(0);
857-
detxz(detZmask) = T(0);
858-
detyx(detZmask) = T(0);
859-
detyy(detZmask) = T(0);
860-
detyz(detZmask) = T(0);
861-
detzx(detZmask) = T(0);
862-
detzy(detZmask) = T(0);
863-
detzz(detZmask) = T(0);
855+
where(detZmask, detxx) = T(0);
856+
where(detZmask, detxy) = T(0);
857+
where(detZmask, detxz) = T(0);
858+
where(detZmask, detyx) = T(0);
859+
where(detZmask, detyy) = T(0);
860+
where(detZmask, detyz) = T(0);
861+
where(detZmask, detzx) = T(0);
862+
where(detZmask, detzy) = T(0);
863+
where(detZmask, detzz) = T(0);
864864
}
865865
// set final components
866866
SetComponents(detxx, -detyx, detzx, -detxx * fM[kDX] + detyx * fM[kDY] - detzx * fM[kDZ], -detxy, detyy, -detzy,
@@ -984,18 +984,18 @@ class Transform3D {
984984
void SetIdentity(const typename SCALAR::mask_type m)
985985
{
986986
// set identity ( identity rotation and zero translation)
987-
fM[kXX](m) = T(1);
988-
fM[kXY](m) = T(0);
989-
fM[kXZ](m) = T(0);
990-
fM[kDX](m) = T(0);
991-
fM[kYX](m) = T(0);
992-
fM[kYY](m) = T(1);
993-
fM[kYZ](m) = T(0);
994-
fM[kDY](m) = T(0);
995-
fM[kZX](m) = T(0);
996-
fM[kZY](m) = T(0);
997-
fM[kZZ](m) = T(1);
998-
fM[kDZ](m) = T(0);
987+
where(m, fM[kXX]) = T(1);
988+
where(m, fM[kXY]) = T(0);
989+
where(m, fM[kXZ]) = T(0);
990+
where(m, fM[kDX]) = T(0);
991+
where(m, fM[kYX]) = T(0);
992+
where(m, fM[kYY]) = T(1);
993+
where(m, fM[kYZ]) = T(0);
994+
where(m, fM[kDY]) = T(0);
995+
where(m, fM[kZX]) = T(0);
996+
where(m, fM[kZY]) = T(0);
997+
where(m, fM[kZZ]) = T(1);
998+
where(m, fM[kDZ]) = T(0);
999999
}
10001000

10011001
private:

0 commit comments

Comments
 (0)