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
expand.h
Go to the documentation of this file.
1#pragma once
2
3#include <sstream>
4
5#include "tools/math.h"
6#include "element.h"
7#include "collapse.h" // for ProjectionAxis and ProjectionAxisToString
8
10{
14 {
17
25
26 bool operator==(const ExpandParameters& other) const
27 {
30 }
31
32 [[nodiscard]] std::string toString() const override
33 {
34 std::ostringstream result;
35 result << "Parameters: ["
36 << "Profile axis: " << ProjectionAxisToString.at(broadcastProfileAxis) << ", "
37 << "Input field dimensions: " << inputDimensions.toString()
38 << "]";
39 return result.str();
40 }
41 };
42
54 class Expand final : public Element
55 {
56 private:
57 ExpandParameters parameters;
58 public:
62 Expand(const ElementCommonParameters& elementCommonParameters,
63 const ExpandParameters& parameters);
64
65 void init() override;
66 void step(double t, double deltaT) override;
67 void addInput(const std::shared_ptr<Element>& inputElement,
68 const std::string& inputComponent = "output") override;
69 std::string toString() const override;
70 std::shared_ptr<Element> clone() const override;
71
73 void changeInputDimensions(const ElementDimensions& newInputDimensions);
74
75 void setParameters(const ExpandParameters& parameters);
76 [[nodiscard]] ExpandParameters getParameters() const;
77 };
78}
Abstract base class for all simulation elements.
Definition element.h:28
Expands a 1D input field to a 2D output by broadcasting along one axis.
Definition expand.h:55
void changeInputDimensions(const ElementDimensions &newInputDimensions)
Resize the 1D input field dimensions and rebuild the input buffer.
Definition expand.cpp:116
ExpandParameters getParameters() const
Definition expand.cpp:135
std::shared_ptr< Element > clone() const override
Definition expand.cpp:111
void addInput(const std::shared_ptr< Element > &inputElement, const std::string &inputComponent="output") override
Register inputElement as an upstream source for this element.
Definition expand.cpp:51
void init() override
Initialize the element (called once before the simulation loop).
Definition expand.cpp:16
std::string toString() const override
Definition expand.cpp:103
void setParameters(const ExpandParameters &parameters)
Definition expand.cpp:129
void step(double t, double deltaT) override
Advance the element by one time step.
Definition expand.cpp:37
ProjectionAxis
Spatial axis a projection acts on.
Definition collapse.h:41
Definition element_parameters.h:10
const std::map< ProjectionAxis, std::string > ProjectionAxisToString
Maps ProjectionAxis values to human-readable strings.
Definition collapse.h:47
Definition element_parameters.h:188
Definition element_parameters.h:159
std::string toString() const
Definition element_parameters.cpp:55
Definition element_parameters.h:206
Parameters for an Expand (1D -> 2D) element.
Definition expand.h:14
std::string toString() const override
Definition expand.h:32
ExpandParameters(const ProjectionAxis broadcastProfileAxis=ProjectionAxis::X, const ElementDimensions &inputDimensions=ElementDimensions{ 100, 1.0 })
Construct Expand parameters.
Definition expand.h:21
ProjectionAxis broadcastProfileAxis
Axis the 1D profile maps to (it is repeated along the other).
Definition expand.h:15
bool operator==(const ExpandParameters &other) const
Definition expand.h:26
ElementDimensions inputDimensions
Spatial dimensions of the 1D source field.
Definition expand.h:16