DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq
sourcecode
tpglibs
include
tpglibs
NaiveUtils.hpp
Go to the documentation of this file.
1
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
_naive_div_int16
(
const
int16_t& a,
const
int16_t& b) {
27
int16_t vb = (1 << 15) / b;
// 1 / b * 2^15
28
int32_t mulhrs = a * vb;
// a / b * 2^15
29
mulhrs = (mulhrs >> 14) + 1;
// (a / b * 2^15) * 2^-14 + 1 ~ a / b * 2 + 1
30
mulhrs = mulhrs >> 1;
//~ a / b. The +1 causes unorthodox rounding.
31
return
(int16_t)(mulhrs);
32
}
33
34
}
// namespace tpglibs
35
36
#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:26
Generated on Sat Jun 28 2025 for DUNE-DAQ by
1.12.0