// Generated by EML-lang HLSL backend (function library)
// Source module: aerospace_actuator_guard_band
// Kernel digest: sha256:0b0ef5a5baecb59acc7d28dc64bc959d9f3378cfbc278204c737cef5bc755aaa
// Functions:     1
// Constants:     0
//
// Float32-only. EML `Real` and `f64` lower to HLSL `float`.
// HLSL `double` is emulated on most GPUs and unavailable in
// many shader profiles -- if you need >32-bit precision, do
// the high-precision step on CPU and ship a float32 result.
//
// Include this file in a vertex / fragment / compute /
// raytracing shader. No entry point is provided; the file is
// a function library (compile with DXC -T lib_6_3 to verify).

#ifndef FORGE_AEROSPACE_ACTUATOR_GUARD_BAND_HLSL
#define FORGE_AEROSPACE_ACTUATOR_GUARD_BAND_HLSL

// Forward declarations -- ensures every CALL target is
// visible regardless of source order or extern placement.
float actuator_command_within_band(float error, float integral, float deriv, float kp, float ki, float kd, float u_min, float u_max);

// actuator_command_within_band
//   Pfaffian profile: pfaffian_r=0, cost_class=p0-d4-w0-c0, drift_risk=LOW.
//   forge.requires: (u_min <= u_max)
//   forge.ensures: (u_min <= result)
//   forge.ensures: (result <= u_max)
//  source obligations for actuator_command_within_band: {O1, O2}
//    O1 [43d7c3ff9568] -> DEGRADED  advisory comment only; not checked
//    O2 [ca2e303109b7] -> DEGRADED  advisory comment only; not checked
//   forge.verify: lean theorem=actuator_command_within_band
float actuator_command_within_band(float error, float integral, float deriv, float kp, float ki, float kd, float u_min, float u_max)
{
    return max(u_min, min((((kp * error) + (ki * integral)) + (kd * deriv)), u_max));
}

#endif  // FORGE_AEROSPACE_ACTUATOR_GUARD_BAND_HLSL
