BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
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
6#include <cmath>
7#include <iostream>
8
9/**********************************
10 *
11 * Vector of four doubles
12 *
13 **********************************/
14
16{
17 public:
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
24 F64vec1(const F64vec1& a) { v[0] = a.v[0]; }
25 F64vec1(const double& a) { v[0] = a; }
26
27 friend double min(double x, double y) { return x < y ? x : y; }
28 friend double max(double x, double y) { return x < y ? y : x; }
29 friend double asgnb(double x, double y) { return y >= 0 ? fabs(x) : -fabs(x); }
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
73
74 friend std::ostream& operator<<(std::ostream& strm, const F64vec1& a)
75 {
76 strm << a[0];
77 return strm;
78 }
79
80 friend std::istream& operator>>(std::istream& strm, F64vec1& a)
81 {
82 double tmp;
83 strm >> tmp;
84 a = tmp;
85 return strm;
86 }
87
88}; // __attribute__ ((aligned(16)));;
89
90typedef F64vec1 fvec;
91const int fvecLen = 1;
92typedef double fscal;
93
94// #define fvec_true _f32vec1_true
95// #define fvec_false _f32vec1_false
96#define _fvecalignment
97
98#endif
float fscal
Definition P4_F32vec4.h:232
const int fvecLen
Definition P4_F32vec4.h:233
int i
Definition P4_F32vec4.h:22
F32vec4 fvec
Definition P4_F32vec4.h:231
#define _f2(A, B, F)
#define _f1(A, F)
#define _op(A, B, O)
friend F64vec1 sgn(const F64vec1 &a)
friend F64vec1 sqrt(const F64vec1 &a)
vec_arithmetic(F64vec1, double)
friend double max(double x, double y)
friend F64vec1 exp(const F64vec1 &a)
friend double min(double x, double y)
friend F64vec1 operator-(const F64vec1 &a, const F64vec1 &b)
F64vec1(const F64vec1 &a)
friend double sgn(double x)
friend F64vec1 operator+(const F64vec1 &a, const F64vec1 &b)
friend F64vec1 asgnb(const F64vec1 &a, const F64vec1 &b)
friend double asgnb(double x, double y)
friend F64vec1 max(const F64vec1 &a, const F64vec1 &b)
double operator[](int i) const
friend double rcp(double x)
friend F64vec1 log(const F64vec1 &a)
friend F64vec1 min(const F64vec1 &a, const F64vec1 &b)
friend F64vec1 rsqrt(const F64vec1 &a)
friend F64vec1 fabs(const F64vec1 &a)
double & operator[](int i)
double v[1]
friend F64vec1 operator/(const F64vec1 &a, const F64vec1 &b)
friend F64vec1 operator*(const F64vec1 &a, const F64vec1 &b)
friend F64vec1 rcp(const F64vec1 &a)
friend double rsqrt(double x)
friend std::istream & operator>>(std::istream &strm, F64vec1 &a)
friend F64vec1 sin(const F64vec1 &a)
F64vec1(const double &a)
friend std::ostream & operator<<(std::ostream &strm, const F64vec1 &a)
friend F64vec1 cos(const F64vec1 &a)