Skip to content

Add the non-kernel functions: Sigmoid, Average, VectorLength (#321) - #961

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
feat/non-kernel-functions
Aug 16, 2026
Merged

Add the non-kernel functions: Sigmoid, Average, VectorLength (#321)#961
Rafael-SOWNet merged 1 commit into
masterfrom
feat/non-kernel-functions

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Collaborator

Addresses #321.

Three functions worth being able to write, which need no node of their own because the kernel can already say what they mean:

Sigmoid(x) 1 / (1 + e ^ (-x))
Average(m) the sum of a matrix's cells over their count
VectorLength(v) Abs of the vector

VectorLength is a name, not a capability

abs([3, 4]) has always answered 5 — which is exactly @WhiteBlackGoose's observation on the issue:

VectorLength is Abs. Avg will take Matrix as an argument. Sigmoid will take Entity.

So it is here so the operation can be found under the name a caller reaches for, and a test requires the two to agree, so they cannot drift into two definitions of one thing.

Being an ordinary expression is the point

Nothing in this PR teaches the library to differentiate a sigmoid or take its limit. Both work anyway, and the tests are written to show that rather than to check one-line formulas:

d/dx Sigmoid(x)   ->  e ^ (-x) / (e ^ (-x) + 1) ^ 2
Sigmoid at +oo    ->  1
Sigmoid at -oo    ->  0

Adding a node instead would mean the eleven steps of Docs/Contributing/AddingNode.cs and a new shape for every rule to ignore, for no reach these do not already have. That is what "non-kernel" buys.

Average is symbolic: of [a, b] it is (a + b) / 2 rather than a refusal.

Scope, against the issue's checklist

  • Taylor series was already implemented and ticked — I verified rather than assumed.
  • Max / Min / Mean are struck through on the issue.
  • Mode and median are not expressible this way, which is why @Happypig375 and @WhiteBlackGoose disagreed about them in the thread. This PR does not settle that, and I would rather it were decided on the issue than smuggled in here.

Evidence

  • suite 7274 passed, 0 failed, 14 skipped
  • 11 new tests, including that VectorLength and Abs agree, that Average reads every cell of a 2×2 matrix, and that null is refused rather than dereferenced
  • PublicApi.txt regenerated: three members added, nothing else moved
  • purely additive — no answer changes, so no BREAKING-CHANGES.md entry

🤖 Generated with Claude Code

Functions worth being able to write, which need no node of their own because the
kernel can already say what they mean:

    Sigmoid(x)        1 / (1 + e ^ (-x))
    Average(m)        the sum of a matrix's cells over their count
    VectorLength(v)   Abs of the vector

The last is a name rather than a capability: abs([3, 4]) has always answered 5, which
is what @WhiteBlackGoose observed on the issue -- "VectorLength is Abs" is the whole
implementation. It is here so the operation can be found by the name a caller looks
for, and a test requires the two to agree so they cannot drift into two definitions.

Being ordinary expressions is the point rather than an implementation detail, and the
tests are written to show it: nothing here teaches the library to differentiate a
sigmoid or take its limit, and both work --

    d/dx Sigmoid(x)   e ^ (-x) / (e ^ (-x) + 1) ^ 2
    at +oo            1
    at -oo            0

A node instead would mean the eleven steps of Docs/Contributing/AddingNode.cs and a
new shape for every rule to ignore, for no reach these do not already have.

Average is symbolic: of [a, b] it is (a + b) / 2, not a refusal.

Taylor, the fourth item on the issue, was already implemented and ticked. Max, Min and
Mean are struck through there. Mode and median are a separate question -- they are not
expressible this way, which is why @Happypig375 and @WhiteBlackGoose disagreed about
them, and this does not settle it.

Purely additive: no answer changes, so no BREAKING-CHANGES entry. Suite 7274 passed,
0 failed. PublicApi.txt regenerated, three members added and nothing else moved.
@Rafael-SOWNet
Rafael-SOWNet merged commit a0d8504 into master Aug 16, 2026
25 checks passed
@Rafael-SOWNet
Rafael-SOWNet deleted the feat/non-kernel-functions branch August 16, 2026 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant