Files
rust/tests/pretty/autodiff/inherent_impl.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
456 B
Rust
Raw Normal View History

2025-04-21 13:26:25 +05:30
//@ needs-enzyme
#![feature(autodiff)]
//@ pretty-mode:expanded
//@ pretty-compare-only
//@ pp-exact:inherent_impl.pp
use std::autodiff::autodiff_reverse;
2025-04-21 13:26:25 +05:30
struct Foo {
a: f64,
}
trait MyTrait {
fn f(&self, x: f64) -> f64;
fn df(&self, x: f64, seed: f64) -> (f64, f64);
}
impl MyTrait for Foo {
#[autodiff_reverse(df, Const, Active, Active)]
2025-04-21 13:26:25 +05:30
fn f(&self, x: f64) -> f64 {
self.a * 0.25 * (x * x - 1.0 - 2.0 * x.ln())
}
}