Belle II Software development
SameSignChecker Class Reference

Small helper for checking the same sign of two, four or eight floats. More...

#include <SameSignChecker.h>

Static Public Member Functions

static bool sameSign (double n1, double n2)
 Check if two values have the same sign.
 
static bool sameSign (double n1, double n2, double n3, double n4)
 Check if four values have the same sign.
 
static bool sameSign (double n1, double n2, double n3, double n4, double n5, double n6, double n7, double n8)
 Check if eight values have the same sign.
 
static bool isIn (double x, double y, double x1, double x2, double y1, double y2)
 Check if two values are in the rectangle spanned by the other four values.
 

Detailed Description

Small helper for checking the same sign of two, four or eight floats.

Definition at line 20 of file SameSignChecker.h.

Member Function Documentation

◆ isIn()

static bool isIn ( double  x,
double  y,
double  x1,
double  x2,
double  y1,
double  y2 
)
inlinestatic

Check if two values are in the rectangle spanned by the other four values.

Definition at line 48 of file SameSignChecker.h.

49 {
50 return sameSign(x - x1, x2 - x, y - y1, y2 - y);
51 }
static bool sameSign(double n1, double n2)
Check if two values have the same sign.

◆ sameSign() [1/3]

static bool sameSign ( double  n1,
double  n2 
)
inlinestatic

Check if two values have the same sign.

Definition at line 24 of file SameSignChecker.h.

25 {
26 return ((n1 > 0 and n2 > 0) or (n1 < 0 and n2 < 0));
27 }

◆ sameSign() [2/3]

static bool sameSign ( double  n1,
double  n2,
double  n3,
double  n4 
)
inlinestatic

Check if four values have the same sign.

Definition at line 30 of file SameSignChecker.h.

31 {
32 return ((n1 > 0 and n2 > 0 and n3 > 0 and n4 > 0) or
33 (n1 < 0 and n2 < 0 and n3 < 0 and n4 < 0));
34 }

◆ sameSign() [3/3]

static bool sameSign ( double  n1,
double  n2,
double  n3,
double  n4,
double  n5,
double  n6,
double  n7,
double  n8 
)
inlinestatic

Check if eight values have the same sign.

Definition at line 37 of file SameSignChecker.h.

39 {
40 return ((n1 > 0 and n2 > 0 and n3 > 0 and n4 > 0 and
41 n5 > 0 and n6 > 0 and n7 > 0 and n8 > 0)
42 or
43 (n1 < 0 and n2 < 0 and n3 < 0 and n4 < 0 and
44 n5 < 0 and n6 < 0 and n7 < 0 and n8 < 0));
45 }

The documentation for this class was generated from the following file: