CMS 3D CMS Logo

SSERot.h
Go to the documentation of this file.
1 #ifndef DataFormat_Math_SSERot_H
2 #define DataFormat_Math_SSERot_H
3 
5 
6 namespace mathSSE {
7 
8  template <typename T>
9  struct OldRot {
10  T R11, R12, R13;
11  T R21, R22, R23;
12  T R31, R32, R33;
13  } __attribute__((aligned(16)));
14 
15  template <typename T>
16  struct Rot3 {
18 
19  Rot3() {
20  axis[0].arr[0] = 1;
21  axis[1].arr[1] = 1;
22  axis[2].arr[2] = 1;
23  }
24 
25  Rot3(Vec4<T> ix, Vec4<T> iy, Vec4<T> iz) {
26  axis[0] = ix;
27  axis[1] = iy;
28  axis[2] = iz;
29  }
30 
31  Rot3(T xx, T xy, T xz, T yx, T yy, T yz, T zx, T zy, T zz) {
32  axis[0].set(xx, xy, xz);
33  axis[1].set(yx, yy, yz);
34  axis[2].set(zx, zy, zz);
35  }
36 
37  Rot3 transpose() const {
38  return Rot3(axis[0].arr[0],
39  axis[1].arr[0],
40  axis[2].arr[0],
41  axis[0].arr[1],
42  axis[1].arr[1],
43  axis[2].arr[1],
44  axis[0].arr[2],
45  axis[1].arr[2],
46  axis[2].arr[2]);
47  }
48 
49  Vec4<T> x() { return axis[0]; }
50  Vec4<T> y() { return axis[1]; }
51  Vec4<T> z() { return axis[2]; }
52 
53  // toLocal...
54  Vec4<T> rotate(Vec4<T> v) const { return transpose().rotateBack(v); }
55 
56  // toGlobal...
58  return v.template get1<0>() * axis[0] + v.template get1<1>() * axis[1] + v.template get1<2>() * axis[2];
59  }
60 
61  Rot3 rotate(Rot3 const& r) const {
62  Rot3 tr = transpose();
63  return Rot3(tr.rotateBack(r.axis[0]), tr.rotateBack(r.axis[1]), tr.rotateBack(r.axis[2]));
64  }
65 
66  Rot3 rotateBack(Rot3 const& r) const {
67  return Rot3(rotateBack(r.axis[0]), rotateBack(r.axis[1]), rotateBack(r.axis[2]));
68  }
69  };
70 
71  typedef Rot3<float> Rot3F;
72 
74 
75 #ifdef __SSE4_1__
76  template <>
78  return _mm_or_ps(_mm_or_ps(_mm_dp_ps(axis[0].vec, v.vec, 0x71), _mm_dp_ps(axis[1].vec, v.vec, 0x72)),
79  _mm_dp_ps(axis[2].vec, v.vec, 0x74));
80  }
81  template <>
82  inline Rot3<float> Rot3<float>::rotate(Rot3<float> const& r) const {
83  return Rot3<float>(rotate(r.axis[0]), rotate(r.axis[1]), rotate(r.axis[2]));
84  }
85 
86 #endif
87 
88 } // namespace mathSSE
89 
90 template <typename T>
92  // return Rot3(lh.rotateBack(rh.axis[0]),lh.rotateBack(rh.axis[1]),lh.rotateBack(rh.axis[2]));
93  return lh.rotateBack(rh);
94 }
95 
96 namespace mathSSE {
97 
98  template <typename T>
99  struct Rot2 {
101 
102  Rot2() {
103  axis[0].arr[0] = 1;
104  axis[1].arr[1] = 1;
105  }
106 
107  Rot2(Vec2<T> ix, Vec2<T> iy) {
108  axis[0] = ix;
109  axis[1] = iy;
110  }
111 
112  Rot2(T xx, T xy, T yx, T yy) {
113  axis[0].set(xx, xy);
114  axis[1].set(yx, yy);
115  }
116 
117  Rot2 transpose() const { return Rot2(axis[0].arr[0], axis[1].arr[0], axis[0].arr[1], axis[1].arr[1]); }
118 
119  Vec2<T> x() { return axis[0]; }
120  Vec2<T> y() { return axis[1]; }
121 
122  // toLocal...
123  Vec2<T> rotate(Vec2<T> v) const { return transpose().rotateBack(v); }
124 
125  // toGlobal...
126  Vec2<T> rotateBack(Vec2<T> v) const { return v.template get1<0>() * axis[0] + v.template get1<1>() * axis[1]; }
127 
128  Rot2 rotate(Rot2 const& r) const {
129  Rot2 tr = transpose();
130  return Rot2(tr.rotateBack(r.axis[0]), tr.rotateBack(r.axis[1]));
131  }
132 
133  Rot2 rotateBack(Rot2 const& r) const { return Rot2(rotateBack(r.axis[0]), rotateBack(r.axis[1])); }
134  };
135 
137 
139 
140 } // namespace mathSSE
141 
142 template <typename T>
144  return lh.rotateBack(rh);
145 }
146 
147 #include <iosfwd>
148 std::ostream& operator<<(std::ostream& out, mathSSE::Rot3F const& v);
149 std::ostream& operator<<(std::ostream& out, mathSSE::Rot3D const& v);
150 std::ostream& operator<<(std::ostream& out, mathSSE::Rot2F const& v);
151 std::ostream& operator<<(std::ostream& out, mathSSE::Rot2D const& v);
152 
153 #endif // DataFormat_Math_SSERot_H
mathSSE::Rot3::rotateBack
Vec4< T > rotateBack(Vec4< T > v) const
Definition: SSERot.h:57
operator*
mathSSE::Rot3< T > operator*(mathSSE::Rot3< T > const &rh, mathSSE::Rot3< T > const &lh)
Definition: SSERot.h:91
geometryCSVtoXML.zz
zz
Definition: geometryCSVtoXML.py:19
mathSSE::Rot3::z
Vec4< T > z()
Definition: SSERot.h:51
geometryCSVtoXML.yz
yz
Definition: geometryCSVtoXML.py:19
mathSSE::Rot3::Rot3
Rot3(Vec4< T > ix, Vec4< T > iy, Vec4< T > iz)
Definition: SSERot.h:25
mathSSE::Rot3::axis
Vec4< T > axis[3]
Definition: SSERot.h:17
mathSSE::OldRot::R31
T R31
Definition: SSERot.h:12
Vec2
ExtVec< T, 2 > Vec2
Definition: ExtVec.h:66
operator<<
std::ostream & operator<<(std::ostream &out, mathSSE::Rot3F const &v)
mathSSE::OldRot::R11
T R11
Definition: SSERot.h:10
mathSSE::Rot3
Definition: SSERot.h:16
mathSSE::OldRot
Definition: SSERot.h:9
SSEVec.h
mathSSE::Rot2::x
Vec2< T > x()
Definition: SSERot.h:119
mathSSE::Rot3::Rot3
Rot3(T xx, T xy, T xz, T yx, T yy, T yz, T zx, T zy, T zz)
Definition: SSERot.h:31
mathSSE::Rot3::transpose
Rot3 transpose() const
Definition: SSERot.h:37
Vec4
ExtVec< T, 4 > Vec4
Definition: ExtVec.h:64
mathSSE::lh
bool int lh
Definition: SIMDVec.h:20
findQualityFiles.v
v
Definition: findQualityFiles.py:179
mathSSE::OldRot::R13
T R13
Definition: SSERot.h:10
mathSSE::Rot2D
Rot2< double > Rot2D
Definition: SSERot.h:138
mathSSE::Rot3::rotateBack
Rot3 rotateBack(Rot3 const &r) const
Definition: SSERot.h:66
mathSSE::__attribute__
struct mathSSE::Rot3 __attribute__
Rot3::rotate
constexpr Vec4< T > rotate(Vec4< T > v) const
Definition: ExtVec.h:202
geometryCSVtoXML.xy
xy
Definition: geometryCSVtoXML.py:19
mathSSE::Rot2::rotateBack
Rot2 rotateBack(Rot2 const &r) const
Definition: SSERot.h:133
mathSSE::Rot3F
Rot3< float > Rot3F
Definition: SSERot.h:71
geometryCSVtoXML.yy
yy
Definition: geometryCSVtoXML.py:19
mathSSE
Definition: AVXVec.h:6
mathSSE::OldRot::R33
T R33
Definition: SSERot.h:12
geometryCSVtoXML.xz
xz
Definition: geometryCSVtoXML.py:19
mathSSE::Vec4< float >
mathSSE::Rot2::rotateBack
Vec2< T > rotateBack(Vec2< T > v) const
Definition: SSERot.h:126
mathSSE::Rot3::x
Vec4< T > x()
Definition: SSERot.h:49
mathSSE::Rot2::Rot2
Rot2(Vec2< T > ix, Vec2< T > iy)
Definition: SSERot.h:107
mathSSE::Rot3::rotate
Rot3 rotate(Rot3 const &r) const
Definition: SSERot.h:61
alignCSCRings.r
r
Definition: alignCSCRings.py:93
mathSSE::Rot3D
Rot3< double > Rot3D
Definition: SSERot.h:73
Rot3
Definition: ExtVec.h:181
mathSSE::Rot2::y
Vec2< T > y()
Definition: SSERot.h:120
mathSSE::Rot2::axis
Vec2< T > axis[2]
Definition: SSERot.h:100
T
long double T
Definition: Basic3DVectorLD.h:48
Rot3::rotateBack
constexpr Vec4< T > rotateBack(Vec4< T > v) const
Definition: ExtVec.h:205
mathSSE::OldRot::R21
T R21
Definition: SSERot.h:11
mathSSE::Rot2F
Rot2< float > Rot2F
Definition: SSERot.h:136
mathSSE::OldRot::R12
T R12
Definition: SSERot.h:10
Rot2
Definition: ExtVec.h:227
mathSSE::Rot2::rotate
Vec2< T > rotate(Vec2< T > v) const
Definition: SSERot.h:123
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
mathSSE::Rot2::transpose
Rot2 transpose() const
Definition: SSERot.h:117
mathSSE::Rot3::rotate
Vec4< T > rotate(Vec4< T > v) const
Definition: SSERot.h:54
mathSSE::OldRot::R23
T R23
Definition: SSERot.h:11
Rot2::rotateBack
constexpr Vec2< T > rotateBack(Vec2< T > v) const
Definition: ExtVec.h:246
mathSSE::Rot2
Definition: SSERot.h:99
mathSSE::Rot3::y
Vec4< T > y()
Definition: SSERot.h:50
mathSSE::Rot2::rotate
Rot2 rotate(Rot2 const &r) const
Definition: SSERot.h:128
mathSSE::Rot2::Rot2
Rot2(T xx, T xy, T yx, T yy)
Definition: SSERot.h:112
mathSSE::OldRot::R32
T R32
Definition: SSERot.h:12
geometryCSVtoXML.xx
xx
Definition: geometryCSVtoXML.py:19
mathSSE::OldRot::R22
T R22
Definition: SSERot.h:11
mathSSE::Rot2::Rot2
Rot2()
Definition: SSERot.h:102
Rot3::axis
Vec axis[3]
Definition: ExtVec.h:183
mathSSE::Rot3::Rot3
Rot3()
Definition: SSERot.h:19