Dynamic Neural Field Composer 0.0.0
A C++20 library and interactive application for building and simulating Dynamic Neural Field (DNF) architectures.
Loading...
Searching...
No Matches
asymmetric_gauss_kernel.h
Go to the documentation of this file.
1#pragma once
2
3#include "kernel.h"
4#include "tools/math.h"
5
7{
11 {
12 double width;
13 double amplitude;
15 double timeShift;
16 bool circular;
18
19 explicit AsymmetricGaussKernelParameters(const double width = 3.0, const double amp = 3.0,
20 const double ampGlobal = 0.00, const double timeShift = 0.00,
21 const bool circular = true, const bool normalized = true)
24 {}
25
27 constexpr double epsilon = 1e-6;
28
29 return std::abs(width - other.width) < epsilon &&
30 std::abs(amplitude - other.amplitude) < epsilon &&
31 std::abs(amplitudeGlobal - other.amplitudeGlobal) < epsilon &&
32 std::abs(timeShift - other.timeShift) < epsilon &&
33 circular == other.circular &&
34 normalized == other.normalized;
35 }
36
37 [[nodiscard]] std::string toString() const override
38 {
39 std::ostringstream result;
40 result << std::fixed << std::setprecision(2);
41 result << "Parameters: ["
42 << "Width: " << width << ", "
43 << "Amplitude: " << amplitude << ", "
44 << "Amplitude global: " << amplitudeGlobal << ", "
45 << "Time shift: " << timeShift << ", "
46 << "Circular: " << (circular ? "true" : "false") << ", "
47 << "Normalized: " << (normalized ? "true" : "false") << "]";
48 return result.str();
49 }
50 };
51
60 class AsymmetricGaussKernel final : public Kernel
61 {
62 private:
64 std::vector<double> gauss;
65 std::vector<double> gaussDerivative;
66 std::vector<double> scratchExtended;
67 std::vector<double> scratchConvolution;
68 public:
72 AsymmetricGaussKernel(const ElementCommonParameters& elementCommonParameters,
73 AsymmetricGaussKernelParameters agk_parameters);
74
75 void init() override;
76 void step(double t, double deltaT) override;
77 std::string toString() const override;
78 std::shared_ptr<Element> clone() const override;
79
80 void setParameters(const AsymmetricGaussKernelParameters& gk_parameters);
82 };
83}
Spatially shifted Gaussian kernel that induces directional peak drift.
Definition asymmetric_gauss_kernel.h:61
AsymmetricGaussKernelParameters getParameters() const
Definition asymmetric_gauss_kernel.cpp:108
void init() override
Initialize the element (called once before the simulation loop).
Definition asymmetric_gauss_kernel.cpp:15
void setParameters(const AsymmetricGaussKernelParameters &gk_parameters)
Definition asymmetric_gauss_kernel.cpp:102
std::shared_ptr< Element > clone() const override
Definition asymmetric_gauss_kernel.cpp:96
std::string toString() const override
Definition asymmetric_gauss_kernel.cpp:88
void step(double t, double deltaT) override
Advance the element by one time step.
Definition asymmetric_gauss_kernel.cpp:67
Abstract base class for all convolution-based interaction kernels.
Definition kernel.h:17
Definition element_parameters.h:10
Parameters for an asymmetric (shifted) Gaussian convolution kernel.
Definition asymmetric_gauss_kernel.h:11
AsymmetricGaussKernelParameters(const double width=3.0, const double amp=3.0, const double ampGlobal=0.00, const double timeShift=0.00, const bool circular=true, const bool normalized=true)
Definition asymmetric_gauss_kernel.h:19
bool circular
Enable circular (toroidal) convolution.
Definition asymmetric_gauss_kernel.h:16
bool normalized
Normalise the Gaussian before convolution.
Definition asymmetric_gauss_kernel.h:17
double width
Gaussian standard deviation σ.
Definition asymmetric_gauss_kernel.h:12
std::string toString() const override
Definition asymmetric_gauss_kernel.h:37
double amplitude
Peak amplitude of the Gaussian.
Definition asymmetric_gauss_kernel.h:13
double timeShift
Spatial shift of the kernel centre (positive = rightward drift).
Definition asymmetric_gauss_kernel.h:15
double amplitudeGlobal
Spatially uniform offset added after convolution.
Definition asymmetric_gauss_kernel.h:14
bool operator==(const AsymmetricGaussKernelParameters &other) const
Definition asymmetric_gauss_kernel.h:26
Definition element_parameters.h:188
Definition element_parameters.h:206