CbmRoot
littrack/parallel/vectors/PSEUDO_F32vec1.h
Go to the documentation of this file.
1 #ifndef LIT_F32VEC1_H
2 #define LIT_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 // int i[1];
15 // float m;
16 //}
17 //__f32vec1_true_cheat = {0xFFFFFFFF},
18 //__f32vec1_false_cheat = {0x00000000};
19 
20 //#define _f32vec1_true ((F32vec1)__f32vec1_true_cheat.m)
21 //#define _f32vec1_false ((F32vec1)__f32vec1_false_cheat.m)
22 
23 class F32vec1 {
24 public:
25  float v;
26 
27  float& operator[](int i) { return v; }
28  float operator[](int i) const { return v; }
29 
30  F32vec1() {}
31  F32vec1(const float& v0) { v = v0; }
32 
33  /* Conversion function */
34  operator float() const { return v; } /* Convert to __m128 */
35 
36  /* Arithmetic Operators */
37 
38  /* Functions */
39  //friend F32vec1 min( const F32vec1 &a, const F32vec1 &b ){ return a<b ?a :b; }
40  //friend F32vec1 max( const F32vec1 &a, const F32vec1 &b ){ return a>b ?a :b; }
41 
42  /* Square Root */
43 
44  /* Reciprocal( inverse) Square Root */
45  //friend F32vec1 rsqrt( const F32vec1 &a ){ return 1./sqrt(a); }
46 
47  /* Reciprocal (inversion) */
48  friend F32vec1 rcp(const F32vec1& a) { return 1. / a; }
49 
50  /* Absolute value */
51  //friend F32vec1 fabs(const F32vec1 &a){ return fabs(a); }
52 
53  /* Sign */
54  //friend F32vec1 sgn(const F32vec1 &a){ return a<0 ?-1 :(a>0 ?1 :0); }
55 
56  /* Logical */
57  /*
58  friend F32vec1 operator&( const F32vec1 &a, const F32vec1 &b ){ // mask returned
59  F32vec1 tmp;
60  int *x = (int*)&tmp;
61  int *y = (int*)&a;
62  int *z = (int*)&b;
63  x[0] = y[0] & z[0];
64  x[1] = y[1] & z[1];
65  return tmp;
66  }
67  */
68  /* Non intrinsic functions */
69 
70  /* Define all operators for consistensy */
71 
72  friend void operator+=(F32vec1& a, const F32vec1& b) { a = a + b; }
73  friend void operator-=(F32vec1& a, const F32vec1& b) { a = a - b; }
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 
77  friend std::ostream& operator<<(std::ostream& strm, const F32vec1& a) {
78  strm << a[0];
79  return strm;
80  }
81 
82  friend std::istream& operator>>(std::istream& strm, F32vec1& a) {
83  float tmp;
84  strm >> tmp;
85  a = tmp;
86  return strm;
87  }
88 
89 }; //__attribute__ ((aligned(16)));;
90 
91 typedef F32vec1 fvec;
92 const int fvecLen = 1;
93 typedef float fscal;
94 //#define fvec_true _f32vec1_true
95 //#define fvec_false _f32vec1_false
96 #define _fvecalignment
97 
98 #endif
fscal
float fscal
Definition: littrack/parallel/vectors/PSEUDO_F32vec1.h:93
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
F32vec1::operator>>
friend istream & operator>>(istream &strm, F32vec1 &a)
Definition: L1/vectors/PSEUDO_F32vec1.h:131
F32vec1::operator*=
friend void operator*=(F32vec1 &a, const F32vec1 &b)
Definition: L1/vectors/PSEUDO_F32vec1.h:79
F32vec1::operator-=
friend void operator-=(F32vec1 &a, const F32vec1 &b)
Definition: L1/vectors/PSEUDO_F32vec1.h:78
F32vec1::v
float v
Definition: L1/vectors/PSEUDO_F32vec1.h:30
F32vec1::operator<<
friend ostream & operator<<(ostream &strm, const F32vec1 &a)
Definition: L1/vectors/PSEUDO_F32vec1.h:126
F32vec1::operator+=
friend void operator+=(F32vec1 &a, const F32vec1 &b)
Definition: L1/vectors/PSEUDO_F32vec1.h:77
fvecLen
const int fvecLen
Definition: littrack/parallel/vectors/PSEUDO_F32vec1.h:92
F32vec1::operator/=
friend void operator/=(F32vec1 &a, const F32vec1 &b)
Definition: L1/vectors/PSEUDO_F32vec1.h:80
F32vec1
Definition: L1/vectors/PSEUDO_F32vec1.h:24
fvec
F32vec1 fvec
Definition: littrack/parallel/vectors/PSEUDO_F32vec1.h:91
F32vec1::rcp
friend F32vec1 rcp(const F32vec1 &a)
Definition: L1/vectors/PSEUDO_F32vec1.h:53
F32vec1::operator[]
float & operator[](int i)
Definition: L1/vectors/PSEUDO_F32vec1.h:32
F32vec1::F32vec1
F32vec1()
Definition: L1/vectors/PSEUDO_F32vec1.h:35