78 switch (m_operation) {
80 case ConvolutionOperation::DIRECT_CONVOLUTION: {
81 const auto ir = get_parameter_or<std::vector<double>>(
82 "impulse_response", std::vector<double> { 1.0 });
83 return apply_per_channel(input, [&ir](std::span<const double> ch) {
84 return D::convolve(ch, ir);
88 case ConvolutionOperation::CROSS_CORRELATION: {
89 const auto tmpl = get_parameter_or<std::vector<double>>(
90 "template_signal", std::vector<double> { 1.0 });
91 const auto norm = get_parameter_or<bool>(
"normalize",
true);
92 return apply_per_channel(input, [&tmpl, norm](std::span<const double> ch) {
93 return D::cross_correlate(ch, tmpl, norm);
97 case ConvolutionOperation::MATCHED_FILTER: {
98 const auto ref = get_parameter_or<std::vector<double>>(
99 "reference_signal", std::vector<double> { 1.0 });
100 return apply_per_channel(input, [&ref](std::span<const double> ch) {
101 return D::matched_filter(ch, ref);
105 case ConvolutionOperation::DECONVOLUTION: {
106 const auto ir = get_parameter_or<std::vector<double>>(
107 "impulse_response", std::vector<double> { 1.0 });
108 const auto reg = get_parameter_or<double>(
"regularization", 1e-6);
109 return apply_per_channel(input, [&ir, reg](std::span<const double> ch) {
110 return D::deconvolve(ch, ir, reg);
114 case ConvolutionOperation::AUTO_CORRELATION: {
115 const auto norm = get_parameter_or<bool>(
"normalize",
true);
116 return apply_per_channel(input, [norm](std::span<const double> ch) {
117 return D::auto_correlate(ch, norm);
122 return create_output(input);
174 auto [channels, structure_info] = OperationHelper::extract_structured_double(input);
175 m_working_buffer.resize(channels.size());
176 for (
size_t i = 0; i < channels.size(); ++i) {
177 if constexpr (std::is_void_v<std::invoke_result_t<Func, std::span<double>>>) {
178 m_working_buffer[i].assign(channels[i].begin(), channels[i].end());
179 func(std::span<double> { m_working_buffer[i] });
181 m_working_buffer[i] = func(std::span<const double> { channels[i] });
184 if (this->is_in_place())
185 for (
size_t i = 0; i < channels.size(); ++i)
186 std::ranges::copy(m_working_buffer[i], channels[i].begin());
187 return create_output(
188 OperationHelper::reconstruct_from_double<InputType>(m_working_buffer, structure_info));