1 #ifndef DataFormat_Math_ExtVec_H
2 #define DataFormat_Math_ExtVec_H
7 #define VECTOR_EXT(N) __attribute__((ext_vector_type(N)))
9 #define VECTOR_EXT(N) __attribute__((vector_size(N)))
19 typedef
long double VECTOR_EXT(32) cms_float128x2_t;
20 typedef
long double VECTOR_EXT(64) cms_float128x4_t;
21 typedef
long double VECTOR_EXT(128) cms_float128x8_t;
60 template <
typename T,
int N>
80 template <
typename Vec,
typename F>
83 constexpr
int N =
sizeof(Vec) /
sizeof(T);
85 for (
int i = 0;
i !=
N; ++
i)
90 template <
typename Vec>
94 Vec x1200{x[1], x[2], x[0], x[0]};
95 Vec y2010{y[2], y[0], y[1], y[0]};
96 Vec x2010{x[2], x[0], x[1], x[0]};
97 Vec y1200{y[1], y[2], y[0], y[0]};
98 return x1200 * y2010 - x2010 * y1200;
101 template <
typename V1,
typename V2>
103 return x[0] *
y[1] -
x[1] *
y[0];
132 template <
typename V>
135 constexpr
int N =
sizeof(
V) /
sizeof(T);
137 for (
int i = 0;
i !=
N; ++
i)
142 template <
typename V1,
typename V2>
146 for (
int i = 0;
i != 2; ++
i)
168 template <
typename V>
173 template <
typename V>
180 template <
typename T>
185 constexpr
Rot3() : axis{{(
Vec){
T(1), 0, 0, 0}}, {(
Vec){0,
T(1), 0, 0}}, {(
Vec){0, 0,
T(1), 0}}} {}
190 : axis{{(Vec){xx,
xy, xz, 0}}, {(Vec){yx, yy, yz, 0}}, {(Vec){zx, zy, zz, 0}}} {}
194 axis[0][0], axis[1][0], axis[2][0], axis[0][1], axis[1][1], axis[2][1], axis[0][2], axis[1][2], axis[2][2]);
197 constexpr
Vec4<T> x()
const {
return axis[0]; }
198 constexpr
Vec4<T> y()
const {
return axis[1]; }
199 constexpr
Vec4<T> z()
const {
return axis[2]; }
205 constexpr
Vec4<T> rotateBack(
Vec4<T> v)
const {
return v[0] * axis[0] + v[1] * axis[1] + v[2] * axis[2]; }
209 return Rot3(tr.rotateBack(r.
axis[0]), tr.rotateBack(r.
axis[1]), tr.rotateBack(r.
axis[2]));
212 constexpr
Rot3 rotateBack(
Rot3 const& r)
const {
213 return Rot3(rotateBack(r.
axis[0]), rotateBack(r.
axis[1]), rotateBack(r.
axis[2]));
221 template <
typename T>
223 return lh.rotateBack(rh);
226 template <
typename T>
235 constexpr
Rot2(
T xx,
T xy,
T yx,
T yy) : Rot2((Vec){xx, xy}, (Vec){yx, yy}) {}
237 constexpr
Rot2 transpose()
const {
return Rot2(axis[0][0], axis[1][0], axis[0][1], axis[1][1]); }
239 constexpr
Vec2<T> x()
const {
return axis[0]; }
240 constexpr
Vec2<T> y()
const {
return axis[1]; }
246 constexpr
Vec2<T> rotateBack(
Vec2<T> v)
const {
return v[0] * axis[0] + v[1] * axis[1]; }
250 return Rot2(tr.rotateBack(r.
axis[0]), tr.rotateBack(r.
axis[1]));
253 constexpr
Rot2 rotateBack(
Rot2 const& r)
const {
return Rot2(rotateBack(r.
axis[0]), rotateBack(r.
axis[1])); }
260 template <
typename T>
262 return lh.rotateBack(rh);
271 std::ostream& operator<<(std::ostream& out, As3D<Vec4F>
const&
v);
272 std::ostream& operator<<(std::ostream& out, As3D<Vec4D>
const&
v);
281 std::ostream&
operator<<(std::ostream&
out, ::Vec4F
const& v) {
282 return out <<
'(' << v[0] <<
", " << v[1] <<
", " << v[2] <<
", " << v[3] <<
')';
284 std::ostream&
operator<<(std::ostream&
out, ::Vec4D
const& v) {
285 return out <<
'(' << v[0] <<
", " << v[1] <<
", " << v[2] <<
", " << v[3] <<
')';
287 std::ostream&
operator<<(std::ostream&
out, ::Vec2F
const& v) {
return out <<
'(' << v[0] <<
", " << v[1] <<
')'; }
288 std::ostream&
operator<<(std::ostream&
out, ::Vec2D
const& v) {
return out <<
'(' << v[0] <<
", " << v[1] <<
')'; }
290 std::ostream& operator<<(std::ostream& out, ::As3D<Vec4F>
const&
v) {
291 return out <<
'(' << v.v[0] <<
", " << v.v[1] <<
", " << v.v[2] <<
')';
294 std::ostream& operator<<(std::ostream& out, ::As3D<Vec4D>
const&
v) {
295 return out <<
'(' << v.v[0] <<
", " << v.v[1] <<
", " << v.v[2] <<
')';
298 std::ostream&
operator<<(std::ostream&
out, ::Rot3F
const& r) {
302 std::ostream&
operator<<(std::ostream&
out, ::Rot3D
const& r) {
306 std::ostream&
operator<<(std::ostream&
out, ::Rot2F
const& r) {
return out << r.
axis[0] <<
'\n' << r.
axis[1]; }
308 std::ostream&
operator<<(std::ostream&
out, ::Rot2D
const& r) {
return out << r.
axis[0] <<
'\n' << r.
axis[1]; }
tuple ret
prodAgent to be discontinued
auto cross2(V1 x, V2 y) -> typename std::remove_reference< decltype(x[0])>::type
std::ostream & operator<<(std::ostream &out, const ALILine &li)
typename ExtVecTraits< T, N >::type ExtVec
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t V
Basic2DVector< T > xy() const
T dot(const Basic3DVector &v) const
Scalar product, or "dot" product, with a vector of same type.
auto zw(V v) -> Vec2< typename std::remove_reference< decltype(v[0])>::type >
As3D< V > as3D(V const &v)
MatrixMeschach operator*(const MatrixMeschach &mat1, const MatrixMeschach &mat2)
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
auto dot2(V1 x, V2 y) -> typename std::remove_reference< decltype(x[0])>::type