Skip to content

Template low pass filter#17

Merged
douglasichen merged 3 commits into
mainfrom
template-low-pass-filter
Oct 26, 2025
Merged

Template low pass filter#17
douglasichen merged 3 commits into
mainfrom
template-low-pass-filter

Conversation

@douglasichen

Copy link
Copy Markdown
Contributor

What? This PR is to template order variable for the low pass FIR filter.
Why? Templating the order allows static allocation of the buffer while minimizing the amount of space allocated. The previous implementation also statically allocated the buffer, but allocated more space then necessary in most cases.
How?

  1. moved implementation to the header file to provide the implementation access to the template order variable
  2. changed cmake list script to build the header file only
  3. added public readonly getOrder function to support test driven development
  4. updated tests to use new templated order variable

@douglasichen douglasichen linked an issue Oct 23, 2025 that may be closed by this pull request

@Roozki Roozki left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@@ -0,0 +1,56 @@
#ifndef FIR_FILTER_HPP
#define FIR_FILTER_HPP
#define MAX_LP_FIR_ORDER (10)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably don't need a max anymore with templates, its up to the user to choose a reasonable order

{
REQUIRE_THROWS_AS(LowPassFIRFilter(0), std::invalid_argument);
REQUIRE_THROWS_AS(LowPassFIRFilter(MAX_LP_FIR_ORDER + 1), std::invalid_argument);
REQUIRE_THROWS_AS(LowPassFIRFilter<0>(), std::invalid_argument);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good use of catch2 macros

@douglasichen douglasichen merged commit e5a8927 into main Oct 26, 2025
1 check passed
@douglasichen douglasichen deleted the template-low-pass-filter branch October 26, 2025 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Template low pass filter

2 participants