max_rrule

Function max_rrule 

Source
pub fn max_rrule<R: Float>(x: R, y: R, cotangent: R) -> (R, R)
Expand description

Reverse rule for max.

When x == y, the cotangent goes to y. If exactly one input is NaN, the non-NaN input receives the cotangent.

ยงExamples

use chainrules::max_rrule;

let (dx, dy) = max_rrule(1.0_f64, 2.0_f64, 0.5);
assert_eq!(dx, 0.0);
assert_eq!(dy, 0.5);