pub enum UnaryOp {
Neg,
Pos,
Factorial,
Transpose,
}Expand description
Unary operators for mathematical expressions.
Represents operators that take a single operand.
§Operator Semantics
Neg: Arithmetic negation (-x). Applied as a prefix operator.Pos: Unary plus (+x). Applied as a prefix operator. Usually redundant but can be explicitly represented in the AST.Factorial: Factorial operator (n!). Applied as a postfix operator. Typically used with non-negative integers.Transpose: Matrix or vector transpose (AᵀorA'). Applied as a postfix operator. Used in linear algebra contexts.
§Position
- Prefix operators:
Neg,Pos- appear before the operand - Postfix operators:
Factorial,Transpose- appear after the operand
§Examples
use mathlex::ast::{UnaryOp, Expression};
// Negation: -5
let neg_expr = Expression::Unary {
op: UnaryOp::Neg,
operand: Box::new(Expression::Integer(5)),
};
// Factorial: n!
let fact_expr = Expression::Unary {
op: UnaryOp::Factorial,
operand: Box::new(Expression::Variable("n".to_string())),
};
// Transpose: A'
let transpose_expr = Expression::Unary {
op: UnaryOp::Transpose,
operand: Box::new(Expression::Variable("A".to_string())),
};Variants§
Neg
Negation operator (-)
Pos
Positive sign operator (+)
Factorial
Factorial operator (!)
Transpose
Matrix/vector transpose operator (ᵀ or ’)
Trait Implementations§
impl Copy for UnaryOp
impl Eq for UnaryOp
impl StructuralPartialEq for UnaryOp
Auto Trait Implementations§
impl Freeze for UnaryOp
impl RefUnwindSafe for UnaryOp
impl Send for UnaryOp
impl Sync for UnaryOp
impl Unpin for UnaryOp
impl UnsafeUnpin for UnaryOp
impl UnwindSafe for UnaryOp
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more