Skip to content

[AUD-027][Medium] Preserve pole semantics in frequency response #324

Description

@gabrielsantosphilips

Audit finding

  • ID: AUD-027
  • Status: Verified defect
  • Severity: Medium
  • Confidence: High
  • Audited revision: 2f479320d805a1f9f35ebe4afaaeeded48913a94

Problem

When the evaluated transfer denominator is exactly zero, FrequencyResponse::Calculate() replaces it with 1+0i. An exact pole is therefore reported as the numerator magnitude instead of infinity, a documented saturation, or failure. The current test encodes this false finite result.

Source:

std::complex<T> numerator(static_cast<T>(0), static_cast<T>(0));
std::complex<T> denominator(static_cast<T>(0), static_cast<T>(0));
for (std::size_t i = 0; i < b.size(); ++i)
numerator += b[i] * std::polar(static_cast<T>(1), -omega * static_cast<T>(i));
for (std::size_t i = 0; i < a.size(); ++i)
denominator += a[i] * std::polar(static_cast<T>(1), -omega * static_cast<T>(i));
if (denominator == static_cast<T>(0))
denominator.real(static_cast<T>(1));
auto h = numerator / denominator;
auto magnitude = std::max(std::abs(h), std::numeric_limits<T>::min());
frequencies.emplace_back(f);
response.emplace_back(static_cast<T>(20) * math::Log10(magnitude));
phase.emplace_back(std::arg(h) * static_cast<T>(180) / static_cast<T>(std::numbers::pi));

Acceptance criteria

  • Define pole and near-pole behavior in the API/documentation.
  • Preserve infinity or return explicit status rather than substituting an unrelated denominator.
  • Add a known-pole test with an independent expected outcome.
  • Handle finite-range dB display separately from transfer-function evaluation.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions