BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
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
3
4
#include <cmath>
5
#include <iostream>
6
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
24
class
F32vec1
25
{
26
public
:
27
float
v
;
28
29
float
&
operator[]
(
int
i
) {
return
v
; }
30
float
operator[]
(
int
i
)
const
{
return
v
; }
31
32
F32vec1
() {}
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); }
48
49
/* Reciprocal (inversion) */
50
friend
F32vec1
rcp
(
const
F32vec1
& a) {
return
1. / a; }
51
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; }
78
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
136
typedef
F32vec1
fvec
;
137
const
int
fvecLen
= 1;
138
// #define fvec_true _f32vec1_true
139
// #define fvec_false _f32vec1_false
140
#define _fvecalignment
141
142
namespace
nsL1
143
{
144
template
<
typename
T>
145
struct
vector
146
{
147
typedef
std::vector<T>
TStd
;
148
typedef
std::vector<T>
TSimd
;
149
};
150
151
typedef
nsL1::vector<fvec>::TSimd
vector_fvec
;
152
};
// namespace nsL1
153
154
template
<
typename
T>
155
struct
nsL1vector
:
public
nsL1::vector
<T>
// just for use std::vector simultaniosly
156
{};
157
158
#endif
v
__m128 v
Definition
P4_F32vec4.h:1
fvecLen
const int fvecLen
Definition
P4_F32vec4.h:233
i
int i
Definition
P4_F32vec4.h:22
if3
#define if3(a, b, c)
Definition
P4_F32vec4.h:148
fvec
F32vec4 fvec
Definition
P4_F32vec4.h:231
__attribute__
nsL1vector __attribute__
M-Stream Header https://afi.jinr.ru/MpdDeviceRawDataFormat.
Definition
BmnTrigUnion.h:33
_op
#define _op(A, B, O)
Definition
PSEUDO_F32vec1.h:79
F32vec1
Definition
PSEUDO_F32vec1.h:25
F32vec1::rcp
friend F32vec1 rcp(const F32vec1 &a)
Definition
PSEUDO_F32vec1.h:50
F32vec1::operator<
friend F32vec1 operator<(const F32vec1 &a, const F32vec1 &b)
Definition
PSEUDO_F32vec1.h:85
F32vec1::operator-=
friend void operator-=(F32vec1 &a, const F32vec1 &b)
Definition
PSEUDO_F32vec1.h:75
F32vec1::v
float v
Definition
PSEUDO_F32vec1.h:27
F32vec1::operator&
friend F32vec1 operator&(const F32vec1 &a, const F32vec1 &b)
Definition
PSEUDO_F32vec1.h:91
F32vec1::operator*=
friend void operator*=(F32vec1 &a, const F32vec1 &b)
Definition
PSEUDO_F32vec1.h:76
F32vec1::operator||
friend F32vec1 operator||(const F32vec1 &a, const F32vec1 &b)
Definition
PSEUDO_F32vec1.h:93
F32vec1::operator>>
friend istream & operator>>(istream &strm, F32vec1 &a)
Definition
PSEUDO_F32vec1.h:125
F32vec1::bool2int
friend F32vec1 bool2int(const F32vec1 &a)
Definition
PSEUDO_F32vec1.h:114
F32vec1::if3
friend F32vec1 if3(const F32vec1 &a, const F32vec1 &b, const F32vec1 &c)
Definition
PSEUDO_F32vec1.h:104
F32vec1::operator+=
friend void operator+=(F32vec1 &a, const F32vec1 &b)
Definition
PSEUDO_F32vec1.h:74
F32vec1::operator<<
friend ostream & operator<<(ostream &strm, const F32vec1 &a)
Definition
PSEUDO_F32vec1.h:119
F32vec1::operator<=
friend F32vec1 operator<=(const F32vec1 &a, const F32vec1 &b)
Definition
PSEUDO_F32vec1.h:86
F32vec1::operator>=
friend F32vec1 operator>=(const F32vec1 &a, const F32vec1 &b)
Definition
PSEUDO_F32vec1.h:88
F32vec1::operator[]
float operator[](int i) const
Definition
PSEUDO_F32vec1.h:30
F32vec1::operator|
friend F32vec1 operator|(const F32vec1 &a, const F32vec1 &b)
Definition
PSEUDO_F32vec1.h:92
F32vec1::F32vec1
F32vec1(const float &v0)
Definition
PSEUDO_F32vec1.h:33
F32vec1::operator/=
friend void operator/=(F32vec1 &a, const F32vec1 &b)
Definition
PSEUDO_F32vec1.h:77
F32vec1::operator!
friend F32vec1 operator!(const F32vec1 &a)
Definition
PSEUDO_F32vec1.h:96
F32vec1::operator[]
float & operator[](int i)
Definition
PSEUDO_F32vec1.h:29
F32vec1::F32vec1
F32vec1()
Definition
PSEUDO_F32vec1.h:32
F32vec1::operator>
friend F32vec1 operator>(const F32vec1 &a, const F32vec1 &b)
Definition
PSEUDO_F32vec1.h:87
nsL1
Definition
PSEUDO_F32vec1.h:143
nsL1::vector_fvec
nsL1::vector< fvec >::TSimd vector_fvec
Definition
PSEUDO_F32vec1.h:151
nsL1::vector
Definition
PSEUDO_F32vec1.h:146
nsL1::vector::vector
vector()
Definition
std_alloc.h:132
nsL1::TSimd::TStd
std::vector< T > TStd
Definition
PSEUDO_F32vec1.h:147
nsL1::TSimd::TSimd
std::vector< T > TSimd
Definition
PSEUDO_F32vec1.h:148
nsL1vector
Definition
PSEUDO_F32vec1.h:156
reconstruction
cat
vectors
PSEUDO_F32vec1.h
Generated on
for BmnRoot by
1.17.0