|
Momentum
A library for solving nonlinear optimization problems related to human body kinematics
|
SIMD (vectorized) variant of GeneralizedLossT that operates on DrJit Packet<T> lanes instead of individual scalars. More...
#include <simd_generalized_loss.h>
Public Types | |
| using | Base = GeneralizedLossT<T> |
Public Member Functions | |
| SimdGeneralizedLossT (const T &a=Base::kL2, const T &c=T(1)) | |
Constructs a SIMD generalized loss with shape a and scale c. | |
| Packet< T > | value (const Packet< T > &sqrError) const |
Returns the loss value for each lane of sqrError. | |
| Packet< T > | deriv (const Packet< T > &sqrError) const |
Returns d(loss)/d(sqrError) for each lane of sqrError. | |
| Public Member Functions inherited from momentum::GeneralizedLossT< T > | |
| GeneralizedLossT (const T &a=kL2, const T &c=T(1)) | |
Constructs a generalized loss with shape a and scale c. | |
| T | value (const T &sqrError) const |
| Returns the loss value for a given squared error. | |
| T | deriv (const T &sqrError) const |
| Derivative of the loss with respect to the input squared error. | |
| bool | isL2 () const |
| Returns true if this loss is an L2 loss (alpha ~= 2). | |
| T | invC2 () const |
| Returns the stored 1/c^2 value. For default c=1, this is 1.0. | |
Additional Inherited Members | |
| Static Public Attributes inherited from momentum::GeneralizedLossT< T > | |
| static constexpr T | kL2 = T(2) |
| Special-case alpha values that are either at a singularity in the general formula or simplify to a closed-form computation. | |
| static constexpr T | kL1 = T(1) |
| static constexpr T | kCauchy = T(0) |
| static constexpr T | kWelsch = std::numeric_limits<T>::lowest() |
| Sentinel for the Welsch (alpha -> -inf) limit. | |
| Protected Types inherited from momentum::GeneralizedLossT< T > | |
| enum class | LossType { L1 , L2 , Cauchy , Welsch , General } |
| Protected Attributes inherited from momentum::GeneralizedLossT< T > | |
| const T | alpha_ |
| const T | invC2_ |
| Stored as 1/c^2 (instead of c) as a small optimization, since the loss formulas use this quantity directly. | |
| LossType | lossType_ |
| Static Protected Attributes inherited from momentum::GeneralizedLossT< T > | |
| static constexpr T | kEps = 1e-9 |
| Small threshold used to detect proximity to special-case alpha values. | |
SIMD (vectorized) variant of GeneralizedLossT that operates on DrJit Packet<T> lanes instead of individual scalars.
See GeneralizedLossT for the full mathematical description, the meaning of alpha and c, and the alpha-value reference (L2, L1/pseudo-Huber, Cauchy, Geman-McClure, Welsch).
Inherits the scalar value() / deriv() overloads and the cached lossType_ / invC2_ state from the base class. Branching on the loss type is uniform across all packet lanes (alpha is fixed at construction), so no per-lane masking is needed in the implementation.
Definition at line 33 of file simd_generalized_loss.h.
| using momentum::SimdGeneralizedLossT< T >::Base = GeneralizedLossT<T> |
Definition at line 35 of file simd_generalized_loss.h.
|
explicit |
Constructs a SIMD generalized loss with shape a and scale c.
| a | Shape parameter alpha. See GeneralizedLossT for the alpha-value reference and the special-case constants (kL2, kL1, kCauchy, kWelsch). |
| c | Scale parameter. Must be > 0. |
Definition at line 75 of file simd_generalized_loss.cpp.
|
nodiscard |
Returns d(loss)/d(sqrError) for each lane of sqrError.
Used to chain-rule the loss into the Jacobian of the underlying residual.
| sqrError | Packet of non-negative squared residuals (one per lane). |
Definition at line 115 of file simd_generalized_loss.cpp.
References momentum::GeneralizedLossT< T >::alpha_, momentum::GeneralizedLossT< T >::Cauchy, momentum::GeneralizedLossT< T >::General, momentum::GeneralizedLossT< T >::invC2_, momentum::GeneralizedLossT< T >::L1, momentum::GeneralizedLossT< T >::L2, momentum::GeneralizedLossT< T >::lossType_, MT_LOGE, and momentum::GeneralizedLossT< T >::Welsch.
|
nodiscard |
Returns the loss value for each lane of sqrError.
| sqrError | Packet of non-negative squared residuals (one per lane). |
Definition at line 81 of file simd_generalized_loss.cpp.
References momentum::GeneralizedLossT< T >::alpha_, momentum::GeneralizedLossT< T >::Cauchy, momentum::GeneralizedLossT< T >::General, momentum::GeneralizedLossT< T >::invC2_, momentum::GeneralizedLossT< T >::L1, momentum::GeneralizedLossT< T >::L2, momentum::GeneralizedLossT< T >::lossType_, MT_LOGE, and momentum::GeneralizedLossT< T >::Welsch.