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_2d.h
Go to the documentation of this file.
1#pragma once
2
3#include <sstream>
4#include <iomanip>
5#include <array>
6
7#include "tools/math.h"
8#include "kernel.h"
9
11{
20 {
21 double width;
22 double amplitude;
24 double timeShift_x;
25 double timeShift_y;
26 bool circular;
28
29 explicit AsymmetricGaussKernel2DParameters(double width = 3.0, double amplitude = 3.0,
30 double amplitudeGlobal = 0.0,
31 double timeShift_x = 0.0,
32 double timeShift_y = 0.0,
33 bool circular = true, bool normalized = true)
37 {}
38
40 {
41 constexpr double epsilon = 1e-6;
42 return std::abs(width - other.width) < epsilon &&
43 std::abs(amplitude - other.amplitude) < epsilon &&
44 std::abs(amplitudeGlobal - other.amplitudeGlobal) < epsilon &&
45 std::abs(timeShift_x - other.timeShift_x) < epsilon &&
46 std::abs(timeShift_y - other.timeShift_y) < epsilon &&
47 circular == other.circular &&
48 normalized == other.normalized;
49 }
50
51 [[nodiscard]] std::string toString() const override
52 {
53 std::ostringstream result;
54 result << std::fixed << std::setprecision(2);
55 result << "Parameters: ["
56 << "Width: " << width << ", "
57 << "Amplitude: " << amplitude << ", "
58 << "Amplitude global: "<< amplitudeGlobal << ", "
59 << "Time shift x: " << timeShift_x << ", "
60 << "Time shift y: " << timeShift_y << ", "
61 << "Circular: " << (circular ? "true" : "false") << ", "
62 << "Normalized: "<< (normalized ? "true" : "false") << "]";
63 return result.str();
64 }
65 };
66
79 class AsymmetricGaussKernel2D final : public Kernel
80 {
81 private:
83 std::array<int, 2> kernelRange_x{};
84 std::array<int, 2> kernelRange_y{};
85 std::vector<int> extIndex_x;
86 std::vector<int> extIndex_y;
87 std::vector<double> kernel_1d_x;
88 std::vector<double> kernel_1d_y;
89 std::vector<double> scratchTmp_;
90 std::vector<double> scratchConvolution_;
91 public:
92 AsymmetricGaussKernel2D(const ElementCommonParameters& elementCommonParameters,
93 const AsymmetricGaussKernel2DParameters& parameters);
94
95 void init() override;
96 void step(double t, double deltaT) override;
97 [[nodiscard]] std::string toString() const override;
98 [[nodiscard]] std::shared_ptr<Element> clone() const override;
99
100 void setParameters(const AsymmetricGaussKernel2DParameters& parameters);
102 };
103}
2D asymmetric Gaussian kernel that induces directional peak drift.
Definition asymmetric_gauss_kernel_2d.h:80
std::string toString() const override
Definition asymmetric_gauss_kernel_2d.cpp:121
AsymmetricGaussKernel2DParameters getParameters() const
Definition asymmetric_gauss_kernel_2d.cpp:140
void init() override
Initialize the element (called once before the simulation loop).
Definition asymmetric_gauss_kernel_2d.cpp:17
void step(double t, double deltaT) override
Advance the element by one time step.
Definition asymmetric_gauss_kernel_2d.cpp:102
std::shared_ptr< Element > clone() const override
Definition asymmetric_gauss_kernel_2d.cpp:129
void setParameters(const AsymmetricGaussKernel2DParameters &parameters)
Definition asymmetric_gauss_kernel_2d.cpp:134
Abstract base class for all convolution-based interaction kernels.
Definition kernel.h:17
Definition element_parameters.h:10
Parameters for AsymmetricGaussKernel2D.
Definition asymmetric_gauss_kernel_2d.h:20
std::string toString() const override
Definition asymmetric_gauss_kernel_2d.h:51
bool operator==(const AsymmetricGaussKernel2DParameters &other) const
Definition asymmetric_gauss_kernel_2d.h:39
double amplitude
Peak amplitude.
Definition asymmetric_gauss_kernel_2d.h:22
bool normalized
Normalise the Gaussian before applying amplitude.
Definition asymmetric_gauss_kernel_2d.h:27
double amplitudeGlobal
Spatially uniform offset added after convolution.
Definition asymmetric_gauss_kernel_2d.h:23
double timeShift_x
Spatial shift along x (positive = rightward drift).
Definition asymmetric_gauss_kernel_2d.h:24
AsymmetricGaussKernel2DParameters(double width=3.0, double amplitude=3.0, double amplitudeGlobal=0.0, double timeShift_x=0.0, double timeShift_y=0.0, bool circular=true, bool normalized=true)
Definition asymmetric_gauss_kernel_2d.h:29
double width
Gaussian standard deviation σ (same for both axes).
Definition asymmetric_gauss_kernel_2d.h:21
bool circular
Enable circular (toroidal) convolution.
Definition asymmetric_gauss_kernel_2d.h:26
double timeShift_y
Spatial shift along y (positive = downward drift).
Definition asymmetric_gauss_kernel_2d.h:25
Definition element_parameters.h:188
Definition element_parameters.h:206