project update
This commit is contained in:
56
Modules/ComputationalModules/Unary/CopyModule.cs
Normal file
56
Modules/ComputationalModules/Unary/CopyModule.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina;
|
||||
using TabulaSmaragdina.Constants;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Unary;
|
||||
public partial class CopyModule : UnaryComputationalModule, IPolymorphismModule
|
||||
{
|
||||
private DataOutPort? Output1 { get; set; }
|
||||
private DataOutPort? Output2 { get; set; }
|
||||
private DataOutPort? Output3 { get; set; }
|
||||
private DataOutPort? Output4 { get; set; }
|
||||
private IDataPortGroup? InputGroup { get; set; }
|
||||
private IDataPortGroup? OutputGroup { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => base.Ports.Union(new[] { Output1, Output2, Output3, Output4 })!;
|
||||
public HashSet<IDataPortGroup> ConfigurablePortGroups { get; set; } = new();
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Output1 = GetPort<DataOutPort>("Output1");
|
||||
Output2 = GetPort<DataOutPort>("Output2");
|
||||
Output3 = GetPort<DataOutPort>("Output3");
|
||||
Output4 = GetPort<DataOutPort>("Output4");
|
||||
InputGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
this,
|
||||
new IDataPort[] {Input1},
|
||||
"",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
Array.Empty<StringName>()
|
||||
);
|
||||
OutputGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
this,
|
||||
new IDataPort[] { Output1, Output2, Output3, Output4 },
|
||||
"Output Port Type",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
EnigmosConstant.DataPortTypes.AnyType
|
||||
);
|
||||
ConfigurablePortGroups = new HashSet<IDataPortGroup> { OutputGroup };
|
||||
PostInit();
|
||||
}
|
||||
|
||||
|
||||
protected override void Compute(IDataPackage input1)
|
||||
{
|
||||
foreach (IDataPort port in OutputGroup!)
|
||||
(port as DataOutPort)!.ResultData.Assign(input1, OutputGroup.SelectedType);
|
||||
|
||||
}
|
||||
|
||||
public void Inference() => InputGroup!.SelectedType = OutputGroup!.SelectedType;
|
||||
|
||||
}
|
||||
26
Modules/ComputationalModules/Unary/LogicalNegationModule.cs
Normal file
26
Modules/ComputationalModules/Unary/LogicalNegationModule.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.DataStructures;
|
||||
using TabulaSmaragdina.Constants;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Unary;
|
||||
|
||||
public partial class LogicalNegationModule : UnaryComputationalModule
|
||||
{
|
||||
private DataOutPort Output1 { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => base.Ports.Union(new[] { Output1 });
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Output1 = GetPort<DataOutPort>("Output1");
|
||||
Input1.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
Output1.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Compute(IDataPackage input1)
|
||||
{
|
||||
Output1.ResultData.Bit = !input1.Bit;
|
||||
}
|
||||
|
||||
}
|
||||
58
Modules/ComputationalModules/Unary/NegationModule.cs
Normal file
58
Modules/ComputationalModules/Unary/NegationModule.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina;
|
||||
using TabulaSmaragdina.Constants;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Unary;
|
||||
|
||||
public partial class NegationModule : UnaryComputationalModule, IPolymorphismModule
|
||||
{
|
||||
private DataOutPort? Output1 { get; set; }
|
||||
private DataOutPort? Output2 { get; set; }
|
||||
private DataOutPort? Output3 { get; set; }
|
||||
private DataOutPort? Output4 { get; set; }
|
||||
private IDataPortGroup? InputGroup { get; set; }
|
||||
private IDataPortGroup? OutputGroup { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => base.Ports.Union(new[] { Output1, Output2, Output3, Output4 })!;
|
||||
|
||||
public HashSet<IDataPortGroup> ConfigurablePortGroups { get; set; } = new();
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Output1 = GetPort<DataOutPort>("Output1");
|
||||
Output2 = GetPort<DataOutPort>("Output2");
|
||||
Output3 = GetPort<DataOutPort>("Output3");
|
||||
Output4 = GetPort<DataOutPort>("Output4");
|
||||
InputGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
this,
|
||||
new IDataPort[] {Input1},
|
||||
"",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
Array.Empty<StringName>()
|
||||
);
|
||||
OutputGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
this,
|
||||
new IDataPort[] { Output1, Output2, Output3, Output4 },
|
||||
"Output Port Type",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
EnigmosConstant.DataPortTypes.AnyTensor
|
||||
);
|
||||
ConfigurablePortGroups = new HashSet<IDataPortGroup> { OutputGroup };
|
||||
PostInit();
|
||||
}
|
||||
|
||||
|
||||
protected override void Compute(IDataPackage input1)
|
||||
{
|
||||
IDataPackage res = GlobalProvider.PolymorphismProvider.Neg(input1, OutputGroup.SelectedType);
|
||||
foreach (IDataPort port in OutputGroup)
|
||||
(port as DataOutPort)!.ResultData.Assign(res, OutputGroup.SelectedType);
|
||||
|
||||
}
|
||||
|
||||
public void Inference() => InputGroup.SelectedType = OutputGroup.SelectedType;
|
||||
}
|
||||
60
Modules/ComputationalModules/Unary/SquareModule.cs
Normal file
60
Modules/ComputationalModules/Unary/SquareModule.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina;
|
||||
using TabulaSmaragdina.Constants;
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Unary;
|
||||
|
||||
public partial class SquareModule : UnaryComputationalModule, IPolymorphismModule
|
||||
{
|
||||
private DataOutPort? Output1 { get; set; }
|
||||
private DataOutPort? Output2 { get; set; }
|
||||
private DataOutPort? Output3 { get; set; }
|
||||
private DataOutPort? Output4 { get; set; }
|
||||
private IDataPortGroup? InputGroup { get; set; }
|
||||
private IDataPortGroup? OutputGroup { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => base.Ports.Union(new[] { Output1, Output2, Output3, Output4 })!;
|
||||
|
||||
public HashSet<IDataPortGroup> ConfigurablePortGroups { get; set; }
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Output1 = GetPort<DataOutPort>("Output1");
|
||||
Output2 = GetPort<DataOutPort>("Output2");
|
||||
Output3 = GetPort<DataOutPort>("Output3");
|
||||
Output4 = GetPort<DataOutPort>("Output4");
|
||||
InputGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
this,
|
||||
new IDataPort[] {Input1},
|
||||
"",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
Array.Empty<StringName>()
|
||||
);
|
||||
OutputGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
this,
|
||||
new DataPort[] { Output1, Output2, Output3, Output4 },
|
||||
"Output Port Type",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
EnigmosConstant.DataPortTypes.NumericTypes
|
||||
);
|
||||
ConfigurablePortGroups = new HashSet<IDataPortGroup> { OutputGroup };
|
||||
PostInit();
|
||||
}
|
||||
|
||||
|
||||
protected override void Compute(IDataPackage input1)
|
||||
{
|
||||
IDataPackage res = GlobalProvider.PolymorphismProvider.Square(input1, OutputGroup.SelectedType);
|
||||
foreach (DataOutPort port in OutputGroup.OfType<DataOutPort>())
|
||||
port.ResultData.Assign(res, OutputGroup.SelectedType);
|
||||
|
||||
}
|
||||
|
||||
public void Inference() => InputGroup!.SelectedType = OutputGroup!.SelectedType;
|
||||
|
||||
}
|
||||
61
Modules/ComputationalModules/Unary/V2ComponentModule.cs
Normal file
61
Modules/ComputationalModules/Unary/V2ComponentModule.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina;
|
||||
using TabulaSmaragdina.Constants;
|
||||
|
||||
|
||||
namespace Enigmos.Modules.ComputationalModules.Unary;
|
||||
|
||||
public partial class V2ComponentModule : UnaryComputationalModule, IPolymorphismModule
|
||||
{
|
||||
private IDataPortGroup? VectorInputGroup { get; set; }
|
||||
private IDataPortGroup? ScalarOutputGroup { get; set; }
|
||||
private DataOutPort? Output1 { get; set; }
|
||||
private DataOutPort? Output2 { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => base.Ports.Union(new[] { Output1, Output2 })!;
|
||||
public HashSet<IDataPortGroup> ConfigurablePortGroups { get; set; } = new();
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Output1 = GetPort<DataOutPort>("Output1");
|
||||
Output2 = GetPort<DataOutPort>("Output2");
|
||||
VectorInputGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
this,
|
||||
new IDataPort[] { Input1 },
|
||||
"Vector Input Type",
|
||||
EnigmosConstant.DataPortTypes.R2,
|
||||
EnigmosConstant.DataPortTypes.VectorTypes
|
||||
);
|
||||
ScalarOutputGroup = GlobalProvider.DataStructureProvider.NewDataPortGroup(
|
||||
this,
|
||||
new IDataPort[] { Output1, Output2 },
|
||||
"",
|
||||
EnigmosConstant.DataPortTypes.Real,
|
||||
Array.Empty<StringName>()
|
||||
);
|
||||
ConfigurablePortGroups = new HashSet<IDataPortGroup> { VectorInputGroup };
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Compute(IDataPackage input1)
|
||||
{
|
||||
if (VectorInputGroup!.SelectedType == EnigmosConstant.DataPortTypes.R2)
|
||||
{
|
||||
Output1!.ResultData.Real = input1.R2[1];
|
||||
Output2!.ResultData.Real = input1.R2[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
Output1!.ResultData.Complex = input1.C2[1];
|
||||
Output2!.ResultData.Complex = input1.C2[2];
|
||||
}
|
||||
}
|
||||
public void Inference() =>
|
||||
ScalarOutputGroup!.SelectedType = GlobalProvider.DataPackageTypeProvider!.GetBaseField(VectorInputGroup.SelectedType);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user