ATLAS Offline Software
Loading...
Searching...
No Matches
GlobalSim::ap_int< n_dig, T > Struct Template Reference

#include <ap_int.h>

Collaboration diagram for GlobalSim::ap_int< n_dig, T >:

Public Member Functions

 ap_int ()=default
 ap_int (const double d)
 operator int () const
const ap_int operator+ (const ap_int &f) const
const ap_intoperator+= (const ap_int &f)
ap_int operator- (const ap_int &f) const
const ap_intoperator-= (const ap_int &f)
ap_int operator* (const ap_int &f) const
const ap_intoperator*= (const ap_int &f)
ap_int operator/ (const ap_int &f) const
const ap_intoperator/= (const ap_int &f)
ap_int operator- () const
void test_overflow ()

Static Public Member Functions

static ap_int form (T v)

Public Attributes

m_value {0}
bool m_ovflw {false}

Detailed Description

template<std::size_t n_dig, typename T = int16_t>
struct GlobalSim::ap_int< n_dig, T >

Definition at line 23 of file ap_int.h.

Constructor & Destructor Documentation

◆ ap_int() [1/2]

template<std::size_t n_dig, typename T = int16_t>
GlobalSim::ap_int< n_dig, T >::ap_int ( )
default

◆ ap_int() [2/2]

template<std::size_t n_dig, typename T = int16_t>
GlobalSim::ap_int< n_dig, T >::ap_int ( const double d)
inline

Definition at line 30 of file ap_int.h.

30 {
31 m_value = T(d + (d >= 0 ? 0.5 : -0.5));
33 }
void test_overflow()
Definition ap_int.h:92

Member Function Documentation

◆ form()

template<std::size_t n_dig, typename T = int16_t>
ap_int GlobalSim::ap_int< n_dig, T >::form ( T v)
inlinestatic

Definition at line 40 of file ap_int.h.

40 {
41 ap_int k; k.m_value = v; k.test_overflow(); return k;
42 }

◆ operator int()

template<std::size_t n_dig, typename T = int16_t>
GlobalSim::ap_int< n_dig, T >::operator int ( ) const
inline

Definition at line 35 of file ap_int.h.

35 {
36 return m_value;
37 }

◆ operator*()

template<std::size_t n_dig, typename T = int16_t>
ap_int GlobalSim::ap_int< n_dig, T >::operator* ( const ap_int< n_dig, T > & f) const
inline

Definition at line 66 of file ap_int.h.

66 {
67 return form(this->m_value * f.m_value);
68 }
static ap_int form(T v)
Definition ap_int.h:40

◆ operator*=()

template<std::size_t n_dig, typename T = int16_t>
const ap_int & GlobalSim::ap_int< n_dig, T >::operator*= ( const ap_int< n_dig, T > & f)
inline

Definition at line 70 of file ap_int.h.

70 {
71 this->m_value -= this->m_value * f.m_value;
73 return *this;
74 }

◆ operator+()

template<std::size_t n_dig, typename T = int16_t>
const ap_int GlobalSim::ap_int< n_dig, T >::operator+ ( const ap_int< n_dig, T > & f) const
inline

Definition at line 44 of file ap_int.h.

44 {
45 return form(this->m_value + f.m_value);
46 }

◆ operator+=()

template<std::size_t n_dig, typename T = int16_t>
const ap_int & GlobalSim::ap_int< n_dig, T >::operator+= ( const ap_int< n_dig, T > & f)
inline

Definition at line 49 of file ap_int.h.

49 {
50 this->m_value +=f.m_value;
52 return *this;
53 }

◆ operator-() [1/2]

template<std::size_t n_dig, typename T = int16_t>
ap_int GlobalSim::ap_int< n_dig, T >::operator- ( ) const
inline

Definition at line 88 of file ap_int.h.

88 {
89 return form(-this->m_value);
90 }

◆ operator-() [2/2]

template<std::size_t n_dig, typename T = int16_t>
ap_int GlobalSim::ap_int< n_dig, T >::operator- ( const ap_int< n_dig, T > & f) const
inline

Definition at line 55 of file ap_int.h.

55 {
56 return form(this->m_value - f.m_value);
57 }

◆ operator-=()

template<std::size_t n_dig, typename T = int16_t>
const ap_int & GlobalSim::ap_int< n_dig, T >::operator-= ( const ap_int< n_dig, T > & f)
inline

Definition at line 60 of file ap_int.h.

60 {
61 this->m_value -= f.m_value;
63 return *this;
64 }

◆ operator/()

template<std::size_t n_dig, typename T = int16_t>
ap_int GlobalSim::ap_int< n_dig, T >::operator/ ( const ap_int< n_dig, T > & f) const
inline

Definition at line 77 of file ap_int.h.

77 {
78 return form(this->m_value / f.m_value);
79 }

◆ operator/=()

template<std::size_t n_dig, typename T = int16_t>
const ap_int & GlobalSim::ap_int< n_dig, T >::operator/= ( const ap_int< n_dig, T > & f)
inline

Definition at line 81 of file ap_int.h.

81 {
82 this->m_value /= this->m_value / f.m_value;
84 return *this;
85 }

◆ test_overflow()

template<std::size_t n_dig, typename T = int16_t>
void GlobalSim::ap_int< n_dig, T >::test_overflow ( )
inline

Definition at line 92 of file ap_int.h.

92 {
93 auto val = m_value >= 0 ? m_value : -m_value;
94
95 if (val > (1<< n_dig)) {
96 m_ovflw=true;
97 throw std::runtime_error("ap_int overflow " + std::to_string(m_value));
98 }
99 }

Member Data Documentation

◆ m_ovflw

template<std::size_t n_dig, typename T = int16_t>
bool GlobalSim::ap_int< n_dig, T >::m_ovflw {false}

Definition at line 26 of file ap_int.h.

26{false};

◆ m_value

template<std::size_t n_dig, typename T = int16_t>
T GlobalSim::ap_int< n_dig, T >::m_value {0}

Definition at line 24 of file ap_int.h.

24{0};

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