signum function
Can someone provide some advice on implementing the following signum function?
G(x)= -Bx + Csgn(x)
I tried it here in gen~ which I am not very confident in using. I wonder if I screwed up the math here, which I am prone to do, and am misrepresenting the formula.
Based on Sprott's formula provided here:
https://sprott.physics.wisc.edu/pubs/paper244.pdf
The only issue I see is that you are computing the sign of C instead of x.
FWIW, you can also use sign directly:

You could also remove that [+] since multiple cords getting in the same inlet are summed anyway.
And if you're more comfortable with lines of code:

Next time you want to share patchers, instead of uploading a file that we need to download, you can select the relevant objects then in the Max menu bar: Edit > Copy Compressed, and paste here.
Thanks so much! I didn't know about the summing rule in gen~. Here's a revision.
If you just need the signum behaviour, it’s basically a three-way result- 1 for negative values, 0 for zero, and 1 for positive values. In Max, you can build that with a couple of comparisons, which also makes it easy to handle edge cases.
in most other languages / in many custom usecases a signum function wil spit out data type int, and not the input type.
but there is no wrong or right with that and there is no relevant cpu overhead to return it as float.
before i used [gen~ @expr "out1 = sign(in1);"] or similar cryptic nonsense with dependencies i would also use MSP comparison operators and make it an abstraction.
while i havent tried it, the chance is high that [>~] will treat a real "-0." wrong, though.