Module easy_ml::differentiation::record_operations [−][src]
Operator implementations for Records.
These implementations are written here but Rust docs will display them on the Record struct page.
Records of any Numeric type (provided the type also implements the operations by reference
as described in the numeric module) implement all the standard
library traits for addition, subtraction, multiplication and division, so you can
use the normal + - * /
operators as you can with normal number types. As a convenience,
these operations can also be used with a Record on the left hand side and a the same type
that the Record is generic over on the right hand side, so you can do
use easy_ml::differentiation::{Record, WengertList}; let list = WengertList::new(); let x: Record<f32> = Record::variable(2.0, &list); let y: f32 = 2.0; let z: Record<f32> = x * y; assert_eq!(z.number, 4.0);
or more succinctly
use easy_ml::differentiation::{Record, WengertList}; assert_eq!((Record::variable(2.0, &WengertList::new()) * 2.0).number, 4.0);
Records of a Real type (provided the type also implements the operations by reference as described in the numeric module) also implement all of those extra traits and operations. Note that to use a method defined in a trait you have to import the trait as well as have a type that implements it!
Traits
SwappedOperations | A trait which defines subtraction and division with the arguments swapped around, ie 5.sub_swapped(7) would equal 2. This trait is only implemented for Records and constant operations. |