ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Friends | List of all members
GlobalSim::ap_fixed< width, dp, S, T, WS > Struct Template Reference

#include <ap_fixed.h>

Collaboration diagram for GlobalSim::ap_fixed< width, dp, S, T, WS >:

Public Member Functions

 ap_fixed ()=default
 
 ap_fixed (const double d) requires(std
 
 ap_fixed (const double d) requires(std
 
 operator double () const
 
const ap_fixed operator+ (const ap_fixed &f) const
 
const ap_fixedoperator+= (const ap_fixed &f)
 
ap_fixed operator- (const ap_fixed &f) const
 
const ap_fixedoperator-= (const ap_fixed &f)
 
ap_fixed operator* (const ap_fixed &f) const
 
const ap_fixedoperator*= (const ap_fixed &f)
 
ap_fixed operator/ (const ap_fixed &f) const
 
const ap_fixedoperator/= (const ap_fixed &f)
 
ap_fixed operator- () const
 
void test_overflow ()
 

Static Public Member Functions

static ap_fixed form (T v)
 

Public Attributes

m_value = T{0}
 
bool m_ovflw {false}
 

Static Public Attributes

static constexpr T m_overflow_mask = max_to_overflow<width, T>()
 
static bool s_check_overflow {false}
 
static bool s_print_value {false}
 
static bool s_debug {s_check_overflow or s_print_value}
 

Friends

std::ostream & operator<< (std::ostream &os, const ap_fixed< width, dp, S, T, WS > ap)
 

Detailed Description

template<std::size_t width, std::size_t dp, typename S = XilDef, typename T = int16_t, typename WS = int32_t>
struct GlobalSim::ap_fixed< width, dp, S, T, WS >

Definition at line 47 of file ap_fixed.h.

Constructor & Destructor Documentation

◆ ap_fixed() [1/3]

template<std::size_t width, std::size_t dp, typename S = XilDef, typename T = int16_t, typename WS = int32_t>
GlobalSim::ap_fixed< width, dp, S, T, WS >::ap_fixed ( )
default

◆ ap_fixed() [2/3]

template<std::size_t width, std::size_t dp, typename S = XilDef, typename T = int16_t, typename WS = int32_t>
GlobalSim::ap_fixed< width, dp, S, T, WS >::ap_fixed ( const double  d)
inline

Definition at line 65 of file ap_fixed.h.

65  :
66  m_value(d * double (1<< dp) + (d >= 0 ? 0.5 : -0.5)){
67  test_overflow();
68  }

◆ ap_fixed() [3/3]

template<std::size_t width, std::size_t dp, typename S = XilDef, typename T = int16_t, typename WS = int32_t>
GlobalSim::ap_fixed< width, dp, S, T, WS >::ap_fixed ( const double  d)
inline

Definition at line 70 of file ap_fixed.h.

70  :
71  m_value(d * double (1<< dp) + (d >= 0 ? 0. : -1.0)){
72  test_overflow();
73  }

Member Function Documentation

◆ form()

template<std::size_t width, std::size_t dp, typename S = XilDef, typename T = int16_t, typename WS = int32_t>
static ap_fixed GlobalSim::ap_fixed< width, dp, S, T, WS >::form ( v)
inlinestatic

Definition at line 81 of file ap_fixed.h.

81  {
82  ap_fixed k; k.m_value = v; k.test_overflow();return k;
83  }

◆ operator double()

template<std::size_t width, std::size_t dp, typename S = XilDef, typename T = int16_t, typename WS = int32_t>
GlobalSim::ap_fixed< width, dp, S, T, WS >::operator double ( ) const
inline

Definition at line 76 of file ap_fixed.h.

76  {
77  return double(this->m_value) / double(1 << dp);
78  }

◆ operator*()

template<std::size_t width, std::size_t dp, typename S = XilDef, typename T = int16_t, typename WS = int32_t>
ap_fixed GlobalSim::ap_fixed< width, dp, S, T, WS >::operator* ( const ap_fixed< width, dp, S, T, WS > &  f) const
inline

Definition at line 107 of file ap_fixed.h.

107  {
108  return form((WS(this->m_value) * WS(f.m_value)) >> dp);
109  }

◆ operator*=()

template<std::size_t width, std::size_t dp, typename S = XilDef, typename T = int16_t, typename WS = int32_t>
const ap_fixed& GlobalSim::ap_fixed< width, dp, S, T, WS >::operator*= ( const ap_fixed< width, dp, S, T, WS > &  f)
inline

Definition at line 111 of file ap_fixed.h.

111  {
112  this->m_value = (WS(this->m_value) * WS(f.m_value) >> dp);
113  test_overflow();
114  return *this;
115  }

◆ operator+()

template<std::size_t width, std::size_t dp, typename S = XilDef, typename T = int16_t, typename WS = int32_t>
const ap_fixed GlobalSim::ap_fixed< width, dp, S, T, WS >::operator+ ( const ap_fixed< width, dp, S, T, WS > &  f) const
inline

Definition at line 85 of file ap_fixed.h.

85  {
86  return form(this->m_value + f.m_value);
87  }

◆ operator+=()

template<std::size_t width, std::size_t dp, typename S = XilDef, typename T = int16_t, typename WS = int32_t>
const ap_fixed& GlobalSim::ap_fixed< width, dp, S, T, WS >::operator+= ( const ap_fixed< width, dp, S, T, WS > &  f)
inline

Definition at line 90 of file ap_fixed.h.

90  {
91  this->m_value += f.m_value;
92  test_overflow();
93  return *this;
94  }

◆ operator-() [1/2]

template<std::size_t width, std::size_t dp, typename S = XilDef, typename T = int16_t, typename WS = int32_t>
ap_fixed GlobalSim::ap_fixed< width, dp, S, T, WS >::operator- ( ) const
inline

Definition at line 129 of file ap_fixed.h.

129  {
130  return form(-this->m_value);
131  }

◆ operator-() [2/2]

template<std::size_t width, std::size_t dp, typename S = XilDef, typename T = int16_t, typename WS = int32_t>
ap_fixed GlobalSim::ap_fixed< width, dp, S, T, WS >::operator- ( const ap_fixed< width, dp, S, T, WS > &  f) const
inline

Definition at line 96 of file ap_fixed.h.

96  {
97  return form(this->m_value - f.m_value);
98  }

◆ operator-=()

template<std::size_t width, std::size_t dp, typename S = XilDef, typename T = int16_t, typename WS = int32_t>
const ap_fixed& GlobalSim::ap_fixed< width, dp, S, T, WS >::operator-= ( const ap_fixed< width, dp, S, T, WS > &  f)
inline

Definition at line 101 of file ap_fixed.h.

101  {
102  this->m_value -= f.m_value;
103  test_overflow();
104  return *this;
105  }

◆ operator/()

template<std::size_t width, std::size_t dp, typename S = XilDef, typename T = int16_t, typename WS = int32_t>
ap_fixed GlobalSim::ap_fixed< width, dp, S, T, WS >::operator/ ( const ap_fixed< width, dp, S, T, WS > &  f) const
inline

Definition at line 118 of file ap_fixed.h.

118  {
119  return form((WS(this->m_value) << dp) / WS(f.m_value));
120  }

◆ operator/=()

template<std::size_t width, std::size_t dp, typename S = XilDef, typename T = int16_t, typename WS = int32_t>
const ap_fixed& GlobalSim::ap_fixed< width, dp, S, T, WS >::operator/= ( const ap_fixed< width, dp, S, T, WS > &  f)
inline

Definition at line 122 of file ap_fixed.h.

122  {
123  this->m_value = ((WS(this->m_value) << dp) / WS(f.m_value));
124  test_overflow();
125  return *this;
126  }

◆ test_overflow()

template<std::size_t width, std::size_t dp, typename S = XilDef, typename T = int16_t, typename WS = int32_t>
void GlobalSim::ap_fixed< width, dp, S, T, WS >::test_overflow ( )
inline

Definition at line 133 of file ap_fixed.h.

133  {
134 
135  if (m_value > 0) {
136  if (m_value & m_overflow_mask) {
137  m_ovflw=true;
138  }
139  } else {
140  if (-m_value & m_overflow_mask) {
141  m_ovflw=true;
142  }
143  }
144 
145  if (m_ovflw) {
146  std::stringstream ss;
147  T val = std::abs(m_value);
148 
149  ss << "ap_fixed overflow. val: "
150  << m_value << " abs(val): " << val
151  << ' ' << std::hex << val
152  << " masked " << (val & m_overflow_mask);
153  throw std::out_of_range(ss.str());
154  }
155  }

Friends And Related Function Documentation

◆ operator<<

template<std::size_t width, std::size_t dp, typename S = XilDef, typename T = int16_t, typename WS = int32_t>
std::ostream& operator<< ( std::ostream &  os,
const ap_fixed< width, dp, S, T, WS >  ap 
)
friend

Definition at line 57 of file ap_fixed.h.

58  {
59  os << ap.m_value << ' ' << double(ap);
60  return os;
61  }

Member Data Documentation

◆ m_overflow_mask

template<std::size_t width, std::size_t dp, typename S = XilDef, typename T = int16_t, typename WS = int32_t>
constexpr T GlobalSim::ap_fixed< width, dp, S, T, WS >::m_overflow_mask = max_to_overflow<width, T>()
staticconstexpr

Definition at line 50 of file ap_fixed.h.

◆ m_ovflw

template<std::size_t width, std::size_t dp, typename S = XilDef, typename T = int16_t, typename WS = int32_t>
bool GlobalSim::ap_fixed< width, dp, S, T, WS >::m_ovflw {false}

Definition at line 56 of file ap_fixed.h.

◆ m_value

template<std::size_t width, std::size_t dp, typename S = XilDef, typename T = int16_t, typename WS = int32_t>
T GlobalSim::ap_fixed< width, dp, S, T, WS >::m_value = T{0}

Definition at line 49 of file ap_fixed.h.

◆ s_check_overflow

template<std::size_t width, std::size_t dp, typename S = XilDef, typename T = int16_t, typename WS = int32_t>
bool GlobalSim::ap_fixed< width, dp, S, T, WS >::s_check_overflow {false}
inlinestatic

Definition at line 52 of file ap_fixed.h.

◆ s_debug

template<std::size_t width, std::size_t dp, typename S = XilDef, typename T = int16_t, typename WS = int32_t>
bool GlobalSim::ap_fixed< width, dp, S, T, WS >::s_debug {s_check_overflow or s_print_value}
inlinestatic

Definition at line 54 of file ap_fixed.h.

◆ s_print_value

template<std::size_t width, std::size_t dp, typename S = XilDef, typename T = int16_t, typename WS = int32_t>
bool GlobalSim::ap_fixed< width, dp, S, T, WS >::s_print_value {false}
inlinestatic

Definition at line 53 of file ap_fixed.h.


The documentation for this struct was generated from the following file:
TileDCSDataPlotter.dp
dp
Definition: TileDCSDataPlotter.py:840
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
hist_file_dump.d
d
Definition: hist_file_dump.py:137
GlobalSim::ap_fixed::m_value
T m_value
Definition: ap_fixed.h:49
python.AtlRunQueryParser.ap
ap
Definition: AtlRunQueryParser.py:826
GlobalSim::ap_fixed::form
static ap_fixed form(T v)
Definition: ap_fixed.h:81
GlobalSim::ap_fixed::m_ovflw
bool m_ovflw
Definition: ap_fixed.h:56
GlobalSim::ap_fixed::test_overflow
void test_overflow()
Definition: ap_fixed.h:133
hist_file_dump.f
f
Definition: hist_file_dump.py:135
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
GlobalSim::ap_fixed::m_overflow_mask
static constexpr T m_overflow_mask
Definition: ap_fixed.h:50
python.PyAthena.v
v
Definition: PyAthena.py:154
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
GlobalSim::ap_fixed::ap_fixed
ap_fixed()=default
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
fitman.k
k
Definition: fitman.py:528