diff --git a/src/Mathematics.NET/AutoDiff/Node.cs b/src/Mathematics.NET/AutoDiff/GradientNode.cs similarity index 89% rename from src/Mathematics.NET/AutoDiff/Node.cs rename to src/Mathematics.NET/AutoDiff/GradientNode.cs index 76e6dc44..38bb92b5 100644 --- a/src/Mathematics.NET/AutoDiff/Node.cs +++ b/src/Mathematics.NET/AutoDiff/GradientNode.cs @@ -1,4 +1,4 @@ -// +// // Mathematics.NET // https://github.com/HamletTanyavong/Mathematics.NET // @@ -32,7 +32,7 @@ namespace Mathematics.NET.AutoDiff; /// Represents a node on a gradient tape /// A type that implements [StructLayout(LayoutKind.Sequential)] -internal readonly record struct Node +internal readonly record struct GradientNode where T : IComplex { /// The derivative of the left component of the binary operation @@ -45,7 +45,7 @@ internal readonly record struct Node /// The parent index of the right node public readonly int PY; - public Node(int index) + public GradientNode(int index) { DX = T.Zero; DY = T.Zero; @@ -54,7 +54,7 @@ public Node(int index) PY = index; } - public Node(T dx, int px, int py) + public GradientNode(T dx, int px, int py) { DX = dx; DY = T.Zero; @@ -63,7 +63,7 @@ public Node(T dx, int px, int py) PY = py; } - public Node(T dx, T dy, int px, int py) + public GradientNode(T dx, T dy, int px, int py) { DX = dx; DY = dy; diff --git a/src/Mathematics.NET/AutoDiff/GradientTape.cs b/src/Mathematics.NET/AutoDiff/GradientTape.cs index 4fb25865..1499e93a 100644 --- a/src/Mathematics.NET/AutoDiff/GradientTape.cs +++ b/src/Mathematics.NET/AutoDiff/GradientTape.cs @@ -70,7 +70,7 @@ public record class GradientTape : ITape { // TODO: Measure performance with Stack> instead of List> // TODO: Consider using array pools or something similar - private List> _nodes; + private List> _nodes; private int _variableCount; public GradientTape() @@ -97,8 +97,8 @@ public void PrintNodes(CancellationToken cancellationToken, int limit = 100) { const string tab = " "; - ReadOnlySpan> nodeSpan = CollectionsMarshal.AsSpan(_nodes); - Node node; + ReadOnlySpan> nodeSpan = CollectionsMarshal.AsSpan(_nodes); + GradientNode node; int i = 0; while (i < Math.Min(_variableCount, limit)) @@ -146,7 +146,7 @@ public void ReverseAccumulation(out ReadOnlySpan gradient, T seed) throw new Exception("Gradient tape contains no root nodes"); } - ReadOnlySpan> nodes = CollectionsMarshal.AsSpan(_nodes); + ReadOnlySpan> nodes = CollectionsMarshal.AsSpan(_nodes); ref var start = ref MemoryMarshal.GetReference(nodes); var length = nodes.Length;