Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Public Attributes | List of all members
CxxUtils::sincos Struct Reference

Helper to simultaneously calculate sin and cos of the same angle. More...

#include <sincos.h>

Collaboration diagram for CxxUtils::sincos:

Public Member Functions

 sincos (double x)
 Calculate sine and cosine of x. More...
 
double apply (double a, double b) const
 \(a\sin(x) + b\cos(x)\) More...
 
double apply2 (double a, double b, double c) const
 \(a\sin^2(x) + b\sin(x)\cos(x) + c\cos^2(x)\) More...
 

Public Attributes

double sn
 \(\sin(x)\) More...
 
double cs
 \(\cos(x)\) More...
 

Detailed Description

Helper to simultaneously calculate sin and cos of the same angle.

Instantiate an instance of this object, passing the angle to the constructor. The sin and cos are then available as the sn and cs members. In addition, the apply() method may be used to calculate a*sin(x) + b*cos(x).

Implementation notes:

This used to inline the fsincos x87 instruction. However, with current compilers on x86_64, it's faster to just use sincos(). We keep this around since sincos() is a GNU extension and we don't want to have to put #ifdefs everywhere we use this.

Definition at line 38 of file sincos.h.

Constructor & Destructor Documentation

◆ sincos()

CxxUtils::sincos::sincos ( double  x)
inline

Calculate sine and cosine of x.

Definition at line 41 of file sincos.h.

44  { ::sincos(x, &sn, &cs); }
45 #else
46  // Generic version.
47  : sn (std::sin (x)), cs (std::cos (x)) {}

Member Function Documentation

◆ apply()

double CxxUtils::sincos::apply ( double  a,
double  b 
) const
inline

\(a\sin(x) + b\cos(x)\)

Definition at line 57 of file sincos.h.

57 { return a*sn + b*cs; }

◆ apply2()

double CxxUtils::sincos::apply2 ( double  a,
double  b,
double  c 
) const
inline

\(a\sin^2(x) + b\sin(x)\cos(x) + c\cos^2(x)\)

Definition at line 60 of file sincos.h.

61  { return a*sn*sn + b*sn*cs + c*cs*cs; }

Member Data Documentation

◆ cs

double CxxUtils::sincos::cs

\(\cos(x)\)

Definition at line 54 of file sincos.h.

◆ sn

double CxxUtils::sincos::sn

\(\sin(x)\)

Definition at line 51 of file sincos.h.


The documentation for this struct was generated from the following file:
CxxUtils::sincos::sincos
sincos(double x)
Calculate sine and cosine of x.
Definition: sincos.h:41
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
x
#define x
CxxUtils::sincos::cs
double cs
Definition: sincos.h:54
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
CxxUtils::sincos::sn
double sn
Definition: sincos.h:51
a
TList * a
Definition: liststreamerinfos.cxx:10
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
python.compressB64.c
def c
Definition: compressB64.py:93