DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
tpglibs
include
tpglibs
NaiveUtils.hpp
Go to the documentation of this file.
1
8
9
#include <cstdint>
10
11
#ifndef TPGLIBS_NAIVEUTILS_HPP_
12
#define TPGLIBS_NAIVEUTILS_HPP_
13
14
namespace
tpglibs
{
15
16
// Modeled to be consistent with AVX.
26
inline
int16_t
27
_naive_div_int16
(
const
int16_t& a,
const
int16_t& b)
28
{
29
int16_t vb = (1 << 15) / b;
// 1 / b * 2^15
30
int32_t mulhrs = a * vb;
// a / b * 2^15
31
mulhrs = (mulhrs >> 14) + 1;
// (a / b * 2^15) * 2^-14 + 1 ~ a / b * 2 + 1
32
mulhrs = mulhrs >> 1;
//~ a / b. The +1 causes unorthodox rounding.
33
return
(int16_t)(mulhrs);
34
}
35
36
}
// namespace tpglibs
37
38
#endif
// TPGLIBS_NAIVEUTILS_HPP_
tpglibs
Definition
AbstractFactory.hpp:20
tpglibs::_naive_div_int16
int16_t _naive_div_int16(const int16_t &a, const int16_t &b)
Naive model of AVX division in AVXUtils.
Definition
NaiveUtils.hpp:27
Generated on
for DUNE-DAQ by
1.18.0