A project I'm working on used KFR's complex arg function to calculate the phase angle for some input I/Q data.
However, the results we were getting from the function appear to have the x and y inputs to the internal atan2 function flipped. We had to do this in order to get the correct results:
double RefinedDetection::get_frequency(const double sample_rate) const
{
// Compute and unwrap phase vector.
real_signal<double> angle_data( m_detection_data.size());
// kfr::arg has invalid implementation, so we convert to std::complex in order to call std::arg here.
for (uint32_t i(0); i < angle_data.size(); ++i)
{
std::complex<double> value( m_detection_data[i].real(), m_detection_data[i].imag());
angle_data[i] = std::arg(value);
}
// Function continues...
}
A project I'm working on used KFR's
complex arg
function to calculate the phase angle for some input I/Q data.However, the results we were getting from the function appear to have the x and y inputs to the internal atan2 function flipped. We had to do this in order to get the correct results:
To replicate the issue, I wrote this code:
Output of code against Standard C++ Library: