forked from Point72/csp
-
Notifications
You must be signed in to change notification settings - Fork 0
2. Math Nodes (csp.math)
github-actions[bot] edited this page Mar 14, 2024
·
2 revisions
In an effort not to bloat the wiki, the following boolean and mathematical operations are available which should be self explanatory.
Also note that there is syntactic sugar in place when wiring a graph.
Edges have most operators overloaded includes +, -, *, /, **, >, >=, <, <=, ==, !=, so you can have code like csp.const(1) + csp.const(2) work properly.
Right hand side values will also automatically be upgraded to csp.const(<value>) if its detected that its not an edge, so something like x = csp.const(1) + 2 will work as well.
csp.not_(ts[bool]) → ts[bool]csp.and_(x: [ts[bool]]) → ts[bool]csp.or_(x: [ts[bool]]) → ts[bool]
csp.add(x: ts['T'], y: ts['T']) → ts['T']csp.sub(x: ts['T'], y: ts['T']) → ts['T']csp.multiply(x: ts['T'], y: ts['T']) → ts['T']csp.divide(x: ts['T'], y: ts['T']) → ts[float]csp.pow(x: ts['T'], y: ts['T']) → ts['T']csp.min/max(x: ts['T'], y: ts['T']) → ts['T']gt/ge/lt/le/eq/ne(x: ts['T'], y: ts['T']) → ts[bool]
ln/log2/log10(x: ts[float]) → ts[float]exp/exp2(x: ts[float]) → ts[float]sqrt(x: ts[float]) → ts[float]abs(x: ts[float]) → ts[float]sin/cos/tan/arcsin/arccos/arctan/sinh/cosh/tanh/arcsinh/arccosh/arctanh(x: ts[float]) → ts[float]erf(x: ts[float]) → ts[float]
Many of these are also exposed as dunder operators:
__add____sub____mul____truediv____floordiv____pow__-
__invert__: bitwise not __mod____abs____pos____neg__
__gt____ge____lt____le____eq____ne__