include
beluga
algorithm
exponential_filter.hpp
Go to the documentation of this file.
1
// Copyright 2022-2023 Ekumen, Inc.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#ifndef BELUGA_ALGORITHM_EXPONENTIAL_FILTER_HPP
16
#define BELUGA_ALGORITHM_EXPONENTIAL_FILTER_HPP
17
23
namespace
beluga
{
24
26
class
ExponentialFilter
{
27
public
:
29
32
constexpr
explicit
ExponentialFilter
(
double
alpha) noexcept :
alpha_
{alpha} {}
33
35
constexpr
void
reset
() noexcept {
output_
= 0.; }
36
38
41
[[nodiscard]] constexpr
double
operator()
(
double
input) noexcept {
42
output_
+= (
output_
== 0.) ? input :
alpha_
* (input -
output_
);
43
return
output_
;
44
}
45
46
private
:
47
double
output_
{0.};
48
double
alpha_
{0.};
49
};
50
51
}
// namespace beluga
52
53
#endif
beluga::ExponentialFilter::operator()
constexpr double operator()(double input) noexcept
Updates the exponential filter output given an input.
Definition:
exponential_filter.hpp:41
beluga::ExponentialFilter
Callable type implementing an exponential filter.
Definition:
exponential_filter.hpp:26
beluga::ExponentialFilter::reset
constexpr void reset() noexcept
Resets the output of the exponential filter to zero.
Definition:
exponential_filter.hpp:35
beluga::ExponentialFilter::output_
double output_
Definition:
exponential_filter.hpp:47
beluga::ExponentialFilter::ExponentialFilter
constexpr ExponentialFilter(double alpha) noexcept
Constructs an exponential filter.
Definition:
exponential_filter.hpp:32
beluga::ExponentialFilter::alpha_
double alpha_
Definition:
exponential_filter.hpp:48
beluga
The main Beluga namespace.
Definition:
3d_embedding.hpp:21
beluga
Author(s):
autogenerated on Tue Jul 16 2024 02:59:53