pub trait OperatorSet: Sized {
type T: Float;
const MAX_ARITY: u8;
Show 16 methods
// Required methods
fn ops_with_arity(arity: u8) -> &'static [u16];
fn meta(op: OpId) -> Option<&'static OpMeta>;
fn eval(op: OpId, ctx: EvalKernelCtx<'_, '_, Self::T>) -> bool;
fn diff(op: OpId, ctx: DiffKernelCtx<'_, '_, Self::T>) -> bool;
fn grad(op: OpId, ctx: GradKernelCtx<'_, '_, Self::T>) -> bool;
// Provided methods
fn name(op: OpId) -> &'static str { ... }
fn display(op: OpId) -> &'static str { ... }
fn infix(op: OpId) -> Option<&'static str> { ... }
fn commutative(op: OpId) -> bool { ... }
fn associative(op: OpId) -> bool { ... }
fn complexity(op: OpId) -> u16 { ... }
fn matches_token(op: OpId, tok: &str) -> bool { ... }
fn for_each_op(f: impl FnMut(OpId)) { ... }
fn lookup_all(token: &str) -> Vec<OpId> { ... }
fn lookup(token: &str) -> Result<OpId, LookupError> { ... }
fn lookup_with_arity(token: &str, arity: u8) -> Result<OpId, LookupError> { ... }
}Expand description
Operator-set abstraction.
- “What ops exist?” ->
ops_with_arity - “What are their tokens / properties?” ->
meta(plus default helpers) - “How do I eval/diff/grad?” ->
eval/diff/grad(dispatch to kernels)
Required Associated Constants§
Required Associated Types§
Required Methods§
fn ops_with_arity(arity: u8) -> &'static [u16]
fn eval(op: OpId, ctx: EvalKernelCtx<'_, '_, Self::T>) -> bool
fn diff(op: OpId, ctx: DiffKernelCtx<'_, '_, Self::T>) -> bool
fn grad(op: OpId, ctx: GradKernelCtx<'_, '_, Self::T>) -> bool
Provided Methods§
fn name(op: OpId) -> &'static str
fn display(op: OpId) -> &'static str
fn infix(op: OpId) -> Option<&'static str>
fn commutative(op: OpId) -> bool
fn associative(op: OpId) -> bool
fn complexity(op: OpId) -> u16
fn matches_token(op: OpId, tok: &str) -> bool
fn for_each_op(f: impl FnMut(OpId))
fn lookup_all(token: &str) -> Vec<OpId>
fn lookup(token: &str) -> Result<OpId, LookupError>
fn lookup_with_arity(token: &str, arity: u8) -> Result<OpId, LookupError>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.