-
Notifications
You must be signed in to change notification settings - Fork 70
Math and Logic Nodes API
github-actions[bot] edited this page Apr 10, 2024
·
1 revision
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.
- Binary logical operators
csp.not_(ts[bool]) → ts[bool]csp.and_(x: [ts[bool]]) → ts[bool]csp.or_(x: [ts[bool]]) → ts[bool]
- Binary mathematical operators
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]
- Unary mathematical operators
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:
a. Operators
__add____sub____mul____truediv____floordiv____pow__-
__invert__: bitwise not __mod____abs____pos____neg__
a. Comparators
__gt____ge____lt____le____eq____ne__
This wiki is autogenerated. To made updates, open a PR against the original source file in docs/wiki.
Get Started (Tutorials)
Concepts
- CSP Node
- CSP Graph
- Historical Buffers
- Execution Modes
- Adapters
- Feedback and Delayed Edge
- Common Mistakes
How-to guides
- Use Statistical Nodes
- Create Dynamic Baskets
- Write Adapters:
- Profile CSP Code
References
- API Reference
- Glossary of Terms
- Examples
Developer Guide