BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
PSEUDO_F32vec1.h
Go to the documentation of this file.
1#ifndef CBM_KF_F32vec1_H
2#define CBM_KF_F32vec1_H
4#include <cmath>
5#include <iostream>
7/**********************************
8 *
9 * Vector of one single float
10 *
11 **********************************/
12
13// const union
14// {
15// int i[1];
16// float m;
17// }
18// __f32vec1_true_cheat = {0xFFFFFFFF},
19// __f32vec1_false_cheat = {0x00000000};
20
21// #define _f32vec1_true ((F32vec1)__f32vec1_true_cheat.m)
22// #define _f32vec1_false ((F32vec1)__f32vec1_false_cheat.m)
23
25{
26 public:
27 float v;
28
29 float& operator[](int i) { return v; }
30 float operator[](int i) const { return v; }
31
33 F32vec1(const float& v0) { v = v0; }
34
35 /* Conversion function */
36 operator float() const { return v; } /* Convert to __m128 */
37
38 /* Arithmetic Operators */
39
40 /* Functions */
41 // friend F32vec1 min( const F32vec1 &a, const F32vec1 &b ){ return a<b ?a :b; }
42 // friend F32vec1 max( const F32vec1 &a, const F32vec1 &b ){ return a>b ?a :b; }
43
44 /* Square Root */
45
46 /* Reciprocal( inverse) Square Root */
47 // friend F32vec1 rsqrt( const F32vec1 &a ){ return 1./sqrt(a); }
49 /* Reciprocal (inversion) */
50 friend F32vec1 rcp(const F32vec1& a) { return 1. / a; }
52 /* Absolute value */
53 // friend F32vec1 fabs(const F32vec1 &a){ return fabs(a); }
54
55 /* Sign */
56 // friend F32vec1 sgn(const F32vec1 &a){ return a<0 ?-1 :(a>0 ?1 :0); }
57
58 /* Logical */
59 /*
60 friend F32vec1 operator&( const F32vec1 &a, const F32vec1 &b ){ // mask returned
61 F32vec1 tmp;
62 int *x = (int*)&tmp;
63 int *y = (int*)&a;
64 int *z = (int*)&b;
65 x[0] = y[0] & z[0];
66 x[1] = y[1] & z[1];
67 return tmp;
68 }
69 */
70 /* Non intrinsic functions */
71
72 /* Define all operators for consistensy */
73
74 friend void operator+=(F32vec1& a, const F32vec1& b) { a = a + b; }
75 friend void operator-=(F32vec1& a, const F32vec1& b) { a = a - b; }
76 friend void operator*=(F32vec1& a, const F32vec1& b) { a = a * b; }
77 friend void operator/=(F32vec1& a, const F32vec1& b) { a = a / b; }
79#define _op(A, B, O) \
80 F32vec1 z; \
81 z.v = A.v O B.v; \
82 return z;
83
84 // /* Comparison */
85 friend F32vec1 operator<(const F32vec1& a, const F32vec1& b) { _op(a, b, <) }
86 friend F32vec1 operator<=(const F32vec1& a, const F32vec1& b) { _op(a, b, <=) }
87 friend F32vec1 operator>(const F32vec1& a, const F32vec1& b) { _op(a, b, >) }
88 friend F32vec1 operator>=(const F32vec1& a, const F32vec1& b) { _op(a, b, >=) }
89
90 // /* Logic */
91 friend F32vec1 operator&(const F32vec1& a, const F32vec1& b) { _op(a, b, &&) }
92 friend F32vec1 operator|(const F32vec1& a, const F32vec1& b) { _op(a, b, ||) }
93 friend F32vec1 operator||(const F32vec1& a, const F32vec1& b) { _op(a, b, ||) }
94#undef _op
95
96 friend F32vec1 operator!(const F32vec1& a)
97 {
98 F32vec1 z;
99 z[0] = !a[0];
100
101 return z;
102 }
103
104 friend F32vec1 if3(const F32vec1& a, const F32vec1& b, const F32vec1& c)
105 {
106 F32vec1 z;
107 z[0] = (a[0]) ? b[0] : c[0];
108
109 return z;
110 }
111
112#define NotEmpty(a) bool((a)[0])
113#define Empty(a) !(bool((a)[0]))
114 friend F32vec1 bool2int(const F32vec1& a)
115 { // mask returned
116 return if3(a, 1, 0);
117 }
118
119 friend ostream& operator<<(ostream& strm, const F32vec1& a)
120 {
121 strm << a[0];
122 return strm;
123 }
124
125 friend istream& operator>>(istream& strm, F32vec1& a)
126 {
127 float tmp;
128 strm >> tmp;
129 a = tmp;
130 return strm;
131 }
132
133} __attribute__((aligned(4)));
134;
135
136typedef F32vec1 fvec;
137const int fvecLen = 1;
138// #define fvec_true _f32vec1_true
139// #define fvec_false _f32vec1_false
140#define _fvecalignment
141
142namespace nsL1
143{
144template<typename T>
145struct vector
146{
147 typedef std::vector<T> TStd;
148 typedef std::vector<T> TSimd;
149};
150
152}; // namespace nsL1
153
154template<typename T>
155struct nsL1vector : public nsL1::vector<T> // just for use std::vector simultaniosly
156{};
157
158#endif
__m128 v
Definition P4_F32vec4.h:1
const int fvecLen
Definition P4_F32vec4.h:233
int i
Definition P4_F32vec4.h:22
#define if3(a, b, c)
Definition P4_F32vec4.h:148
F32vec4 fvec
Definition P4_F32vec4.h:231
nsL1vector __attribute__
M-Stream Header https://afi.jinr.ru/MpdDeviceRawDataFormat.
#define _op(A, B, O)
friend F32vec1 rcp(const F32vec1 &a)
friend F32vec1 operator<(const F32vec1 &a, const F32vec1 &b)
friend void operator-=(F32vec1 &a, const F32vec1 &b)
friend F32vec1 operator&(const F32vec1 &a, const F32vec1 &b)
friend void operator*=(F32vec1 &a, const F32vec1 &b)
friend F32vec1 operator||(const F32vec1 &a, const F32vec1 &b)
friend istream & operator>>(istream &strm, F32vec1 &a)
friend F32vec1 bool2int(const F32vec1 &a)
friend F32vec1 if3(const F32vec1 &a, const F32vec1 &b, const F32vec1 &c)
friend void operator+=(F32vec1 &a, const F32vec1 &b)
friend ostream & operator<<(ostream &strm, const F32vec1 &a)
friend F32vec1 operator<=(const F32vec1 &a, const F32vec1 &b)
friend F32vec1 operator>=(const F32vec1 &a, const F32vec1 &b)
float operator[](int i) const
friend F32vec1 operator|(const F32vec1 &a, const F32vec1 &b)
F32vec1(const float &v0)
friend void operator/=(F32vec1 &a, const F32vec1 &b)
friend F32vec1 operator!(const F32vec1 &a)
float & operator[](int i)
friend F32vec1 operator>(const F32vec1 &a, const F32vec1 &b)
nsL1::vector< fvec >::TSimd vector_fvec
std::vector< T > TStd
std::vector< T > TSimd