@@ -162,7 +162,31 @@ namespace GridKit
162162 }
163163
164164 /* *
165- * @brief Smooth two-sided deadband function
165+ * @brief Smooth Type 1 no-offset two-sided deadband function
166+ *
167+ * Smooth approximation to a deadband that returns zero inside the band and
168+ * passes the input through unchanged outside the band.
169+ *
170+ * @tparam ScalarT - scalar data type
171+ * @tparam RealT - Real data type (see GridKit::ScalarTraits<ScalarT>::RealT)
172+ *
173+ * @param[in] x - Input signal
174+ * @param[in] lower - Lower breakpoint
175+ * @param[in] upper - Upper breakpoint
176+ * @return Smooth no-offset deadbanded value
177+ */
178+ template <class ScalarT , typename RealT>
179+ __attribute__ ((always_inline)) inline ScalarT deadband1 (
180+ const ScalarT x,
181+ const RealT lower,
182+ const RealT upper)
183+ {
184+ assert (lower <= upper);
185+ return x * (sigmoid (lower - x) + sigmoid (x - upper));
186+ }
187+
188+ /* *
189+ * @brief Smooth Type 2 offset two-sided deadband function
166190 *
167191 * Smooth approximation to x - min(max(x, lower), upper), composed from the
168192 * smooth ramp function.
@@ -173,10 +197,10 @@ namespace GridKit
173197 * @param[in] x - Input signal
174198 * @param[in] lower - Lower breakpoint
175199 * @param[in] upper - Upper breakpoint
176- * @return Smooth deadbanded value
200+ * @return Smooth offset deadbanded value
177201 */
178202 template <class ScalarT , typename RealT>
179- __attribute__ ((always_inline)) inline ScalarT deadband (
203+ __attribute__ ((always_inline)) inline ScalarT deadband2 (
180204 const ScalarT x,
181205 const RealT lower,
182206 const RealT upper)
0 commit comments