#[auto_jacobian]Expand description
Attribute macro that generates a jacobian method from a residual method.
Apply this to an impl block containing a method marked with #[residual].
The macro will parse the residual expression and generate the corresponding
Jacobian computation using symbolic differentiation.
§Attributes
#[jacobian(array_param = "x")]- Name of the state vector parameter (default: “x”)
§Example
ⓘ
#[auto_jacobian(array_param = "x")]
impl MyConstraint {
#[residual]
fn residual(&self, x: &[f64]) -> f64 {
x[0] * x[0] + x[1] * x[1] - 1.0 // Unit circle constraint
}
}
// Generates:
// fn jacobian_entries(&self, x: &[f64]) -> Vec<(usize, usize, f64)> {
// vec![
// (0, 0, 2.0 * x[0]), // d/dx[0]
// (0, 1, 2.0 * x[1]), // d/dx[1]
// ]
// }