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