CbmRoot
PSEUDO_F64vec1.h
Go to the documentation of this file.
1 #ifndef L1Algo_PSEUDO_F64vec1_H
2 #define L1Algo_PSEUDO_F64vec1_H
3 
4 #include "vec_arithmetic.h"
5 #include <cmath>
6 #include <iostream>
7 
8 /**********************************
9  *
10  * Vector of four doubles
11  *
12  **********************************/
13 
14 class F64vec1 {
15 public:
16  double v[1];
17 
18  double& operator[](int i) { return ((double*) &v)[i]; }
19  double operator[](int i) const { return ((double*) &v)[i]; }
20 
21  F64vec1() {}
22  F64vec1(const F64vec1& a) { v[0] = a.v[0]; }
23  F64vec1(const double& a) { v[0] = a; }
24 
25  friend double min(double x, double y) { return x < y ? x : y; }
26  friend double max(double x, double y) { return x < y ? y : x; }
27  friend double asgnb(double x, double y) {
28  return y >= 0 ? fabs(x) : -fabs(x);
29  }
30  friend double rsqrt(double x) { return 1. / sqrt(x); }
31  friend double rcp(double x) { return 1. / x; }
32  friend double sgn(double x) { return x >= 0 ? 1 : -1; }
33 
34 #define _f2(A, B, F) \
35  F64vec1 z; \
36  z.v[0] = F(A.v[0], B.v[0]); \
37  return z;
38 #define _f1(A, F) \
39  F64vec1 z; \
40  z.v[0] = F(A.v[0]); \
41  return z;
42 #define _op(A, B, O) \
43  F64vec1 z; \
44  z.v[0] = A.v[0] O B.v[0]; \
45  return z;
46 
47  /* Arithmetic Operators */
48  friend F64vec1 operator+(const F64vec1& a, const F64vec1& b) { _op(a, b, +) }
49  friend F64vec1 operator-(const F64vec1& a, const F64vec1& b) { _op(a, b, -) }
50  friend F64vec1 operator*(const F64vec1& a, const F64vec1& b) { _op(a, b, *) }
51  friend F64vec1 operator/(const F64vec1& a, const F64vec1& b) { _op(a, b, /) }
52 
53  /* Functions */
54  friend F64vec1 min(const F64vec1& a, const F64vec1& b) { _f2(a, b, min) }
55  friend F64vec1 max(const F64vec1& a, const F64vec1& b) { _f2(a, b, max) }
56  friend F64vec1 asgnb(const F64vec1& a, const F64vec1& b) { _f2(a, b, asgnb) }
57  friend F64vec1 sqrt(const F64vec1& a) { _f1(a, sqrt) }
58  friend F64vec1 rsqrt(const F64vec1& a) { _f1(a, rsqrt) }
59  friend F64vec1 rcp(const F64vec1& a) { _f1(a, rcp) }
60  friend F64vec1 fabs(const F64vec1& a) { _f1(a, fabs) }
61  friend F64vec1 sgn(const F64vec1& a) { _f1(a, sgn) }
62  friend F64vec1 exp(const F64vec1& a) { _f1(a, exp) }
63  friend F64vec1 log(const F64vec1& a) { _f1(a, log) }
64  friend F64vec1 sin(const F64vec1& a) { _f1(a, sin) }
65  friend F64vec1 cos(const F64vec1& a) { _f1(a, cos) }
66 #undef _f1
67 #undef _f2
68 #undef _op
69 
70  /* Define all operators for consistensy */
71 
72  vec_arithmetic(F64vec1, double);
73 
74  friend std::ostream& operator<<(std::ostream& strm, const F64vec1& a) {
75  strm << a[0];
76  return strm;
77  }
78 
79  friend std::istream& operator>>(std::istream& strm, F64vec1& a) {
80  double tmp;
81  strm >> tmp;
82  a = tmp;
83  return strm;
84  }
85 
86 }; // __attribute__ ((aligned(16)));;
87 
88 typedef F64vec1 fvec;
89 const int fvecLen = 1;
90 typedef double fscal;
91 
92 //#define fvec_true _f32vec1_true
93 //#define fvec_false _f32vec1_false
94 #define _fvecalignment
95 
96 
97 #endif
F64vec1::fabs
friend F64vec1 fabs(const F64vec1 &a)
Definition: PSEUDO_F64vec1.h:64
F64vec1
Definition: PSEUDO_F64vec1.h:14
vec_arithmetic.h
F64vec1::log
friend F64vec1 log(const F64vec1 &a)
Definition: PSEUDO_F64vec1.h:67
F64vec1::rcp
friend double rcp(double x)
Definition: PSEUDO_F64vec1.h:35
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
F64vec1::operator*
friend F64vec1 operator*(const F64vec1 &a, const F64vec1 &b)
Definition: PSEUDO_F64vec1.h:54
F64vec1::sgn
friend double sgn(double x)
Definition: PSEUDO_F64vec1.h:36
fvecLen
const int fvecLen
Definition: PSEUDO_F64vec1.h:89
fscal
double fscal
Definition: PSEUDO_F64vec1.h:90
fvec
F64vec1 fvec
Definition: PSEUDO_F64vec1.h:88
F64vec1::operator[]
double & operator[](int i)
Definition: PSEUDO_F64vec1.h:22
F64vec1::max
friend double max(double x, double y)
Definition: PSEUDO_F64vec1.h:30
F64vec1::asgnb
friend double asgnb(double x, double y)
Definition: PSEUDO_F64vec1.h:31
F64vec1::exp
friend F64vec1 exp(const F64vec1 &a)
Definition: PSEUDO_F64vec1.h:66
F64vec1::operator+
friend F64vec1 operator+(const F64vec1 &a, const F64vec1 &b)
Definition: PSEUDO_F64vec1.h:52
F64vec1::sqrt
friend F64vec1 sqrt(const F64vec1 &a)
Definition: PSEUDO_F64vec1.h:61
F64vec1::rsqrt
friend double rsqrt(double x)
Definition: PSEUDO_F64vec1.h:34
F64vec1::min
friend double min(double x, double y)
Definition: PSEUDO_F64vec1.h:29
F64vec1::vec_arithmetic
vec_arithmetic(F64vec1, double)
_op
#define _op(A, B, O)
Definition: PSEUDO_F64vec1.h:46
F64vec1::operator>>
friend std::istream & operator>>(std::istream &strm, F64vec1 &a)
Definition: PSEUDO_F64vec1.h:83
F64vec1::v
double v[1]
Definition: PSEUDO_F64vec1.h:20
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68
F64vec1::operator<<
friend std::ostream & operator<<(std::ostream &strm, const F64vec1 &a)
Definition: PSEUDO_F64vec1.h:78
y
Double_t y
Definition: CbmMvdSensorDigiToHitTask.cxx:68
F64vec1::F64vec1
F64vec1()
Definition: PSEUDO_F64vec1.h:25
_f1
#define _f1(A, F)
Definition: PSEUDO_F64vec1.h:42
F64vec1::operator/
friend F64vec1 operator/(const F64vec1 &a, const F64vec1 &b)
Definition: PSEUDO_F64vec1.h:55
F64vec1::sin
friend F64vec1 sin(const F64vec1 &a)
Definition: PSEUDO_F64vec1.h:68
F64vec1::cos
friend F64vec1 cos(const F64vec1 &a)
Definition: PSEUDO_F64vec1.h:69
F64vec1::operator-
friend F64vec1 operator-(const F64vec1 &a, const F64vec1 &b)
Definition: PSEUDO_F64vec1.h:53
_f2
#define _f2(A, B, F)
Definition: PSEUDO_F64vec1.h:38