ATLAS Offline Software
Loading...
Searching...
No Matches
sincos.h
Go to the documentation of this file.
1// This file's extension implies that it's C, but it's really -*- C++ -*-.
2/*
3 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
4*/
11
12
13#ifndef CXXUTILS_SINCOS_H
14#define CXXUTILS_SINCOS_H
15
16
17#include <cmath>
18
19
20namespace CxxUtils {
21
22
38struct sincos
39{
41 sincos (double x)
42#if defined(__USE_GNU)
43 // Version using the GNU sincos() function.
44 { ::sincos(x, &sn, &cs); }
45#else
46 // Generic version.
47 : sn (std::sin (x)), cs (std::cos (x)) {}
48#endif
49
51 double sn;
52
54 double cs;
55
57 double apply (double a, double b) const { return a*sn + b*cs; }
58
60 double apply2 (double a, double b, double c) const
61 { return a*sn*sn + b*sn*cs + c*cs*cs; }
62};
63
64
65} // namespace CxxUtils
66
67
68#endif //not CXXUTILS_SINCOS_H
static Double_t a
#define x
sincos(double x)
Calculate sine and cosine of x.
Definition sincos.h:41
double apply2(double a, double b, double c) const
Definition sincos.h:60
double apply(double a, double b) const
Definition sincos.h:57