1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
   Appellation: operator <mod>
   Contrib: FL03 <jo3mccain@icloud.com>
*/
use super::{Unary, UnaryOp};
// use std::marker::PhantomData;

pub struct UnaryOperator<A> {
    pub args: A,
    pub differentiable: bool,
    pub op: UnaryOp,
}

impl<A> UnaryOperator<A> {
    pub fn new(args: A, op: UnaryOp) -> Self {
        Self {
            args,
            differentiable: op.differentiable(),
            op,
        }
    }

    pub fn eval(self) -> A::Output
    where
        A: Unary,
    {
        self.args.unary(self.op)
    }
}