Robotics operators#
The robotics-specialized small-operator families — spatial 6-D ops (cross
products, coordinate transforms, and the 10-parameter inertia: rigid-body
dynamics), the SO(3)/SE(3)/quaternion Lie family with pose-error metrics
(manifold states, their derivatives, and goal costs),
projection/cone/augmented-Lagrangian scalars (constrained trajectory
optimization), geometry distance primitives (sphere-decomposed collision
checking), the 3x3 estimation kit (eig3/svd3/closest_rotation:
ICP, alignment, re-orthonormalization), and the sampling-planner L1 additions
(softmax/logsumexp/argmax/argmin + _fast twins).
Read the conventions first: Robotics operators & conventions
pins the angular-first spatial ordering, the linear-first SE(3) tangent blocks,
the QuatLayout storage tag, column-major storage, and the small-angle
branch policy. Every array-shaped op below also exists as glass::warp::
and glass::thread:: (same serial core, one tier per problem-packing
granularity); scalar ops are tier-free.
Spatial 6-D cross products#
Functions
-
template<typename T, bool TRAILING_SYNC = true>
void motion_cross(const T *v, T *M)# Spatial motion cross-product matrix:
M = motion_cross(v)(6x6, “crm”).M·x = v ×ₘ xfor spatial motion vectors,M = [[ωₓ, 0],[v_linₓ, ωₓ]]withv = [ω; v_lin](angular-first) and column-major storage. Prefer the fusedmotion_cross_mulwhen only the product is needed.- Template Parameters:
T – Scalar type (e.g.
float,double).TRAILING_SYNC – Emit a trailing
__syncthreads()(default true).
- Parameters:
v – Spatial motion vector (6 elements,
[ω; v_lin]).M – Output 6x6 matrix (36 elements, column-major; no aliasing).
-
template<typename T, int AXIS = -1, bool HAS_BETA = false, bool TRAILING_SYNC = true>
void motion_cross_mul(T alpha, const T *v, const T *x, T beta, T *y)# Fused spatial motion cross apply:
y = alpha·(v ×ₘ x) + beta·y.Never materializes the 6x6 — each output row is its 2-4 term formula (the hot inner op of RNEA/ABA velocity sweeps; ~70 call sites in a typical generated dynamics suite). With compile-time
AXISin 0..5 the multiply specializes to the cardinal basis columnx = e_AXIS(the revolute/ prismatic motion-subspace fast path;xis ignored and may be nullptr).betais only read whenHAS_BETA(BLAS beta==0 semantics viabeta_blend); the(alpha, beta)pair replaces the_peq/_scaledvariant explosion. Equivalent togemv(motion_cross(v), x)— tested against exactly that composition.- Template Parameters:
T – Scalar type.
AXIS – −1 for a dense
x(default), or 0..5 forx = e_AXIS.HAS_BETA – Read/accumulate into
y(default false = overwrite).TRAILING_SYNC – Emit a trailing
__syncthreads()(default true).
- Parameters:
alpha – Scalar on the product.
v – Spatial motion vector (6 elements,
[ω; v_lin]).x – Right operand (6 elements; ignored when
AXIS >= 0).beta – Scalar on the existing
y(read only whenHAS_BETA).y – Output spatial vector (6 elements; no aliasing with
v/x).
-
template<typename T, bool TRAILING_SYNC = true>
void force_cross(const T *v, T *M)# Spatial force cross-product matrix:
M = force_cross(v)(6x6, “crf”/”fx”).The dual cross for spatial FORCE vectors:
force_cross(v) = −motion_cross(v)ᵀ = [[ωₓ, v_linₓ],[0, ωₓ]]. Column-major; always writes all 36 entries (no pre-zeroed-destination variant). Prefer the fusedforce_cross_mul.- Template Parameters:
T, TRAILING_SYNC – See
motion_cross.- Parameters:
v – Spatial motion vector (6 elements,
[ω; v_lin]).M – Output 6x6 matrix (36 elements, column-major; no aliasing).
-
template<typename T, bool HAS_BETA = false, bool TRAILING_SYNC = true>
void force_cross_mul(T alpha, const T *v, const T *f, T beta, T *y)# Fused spatial force cross apply:
y = alpha·(v ×* f) + beta·y.Row formulas of
force_cross(v)·f, fused (no 6x6 materialized). Same(alpha, beta)/beta_blendsemantics asmotion_cross_mul. Tested against thegemv(force_cross(v), f)composition.- Template Parameters:
T, HAS_BETA, TRAILING_SYNC – See
motion_cross_mul.- Parameters:
alpha – Scalar on the product.
v – Spatial motion vector (6 elements,
[ω; v_lin]).f – Spatial force vector (6 elements,
[n; f_lin]).beta – Scalar on the existing
y(read only whenHAS_BETA).y – Output spatial force vector (6 elements; no aliasing).
-
template<typename T, bool TRAILING_SYNC = true>
void force_cross_dual(const T *f, T *M)# Operand-swapped force cross matrix:
M = force_cross_dual(f)(6x6, “icrf”).DEFINED by the identity
force_cross(v)·f == force_cross_dual(f)·vfor allv— it swaps which operand becomes the matrix, the rearrangement inertia-gradient kernels need (∂/∂q ofv ×* (I·v)terms). Column-major.- Template Parameters:
T, TRAILING_SYNC – See
motion_cross.- Parameters:
f – Spatial force vector (6 elements,
[n; f_lin]).M – Output 6x6 matrix (36 elements, column-major; no aliasing).
-
template<typename T>
void motion_cross(const T *v, T *M)# Single-warp motion cross matrix.
Single-thread motion cross matrix.
See
glass::motion_cross.
-
template<typename T, int AXIS = -1, bool HAS_BETA = false>
void motion_cross_mul(T alpha, const T *v, const T *x, T beta, T *y)# Single-warp fused motion cross apply.
Single-thread fused motion cross apply (fully unrolled).
See
glass::motion_cross_mul.
-
template<typename T>
void force_cross(const T *v, T *M)# Single-warp force cross matrix.
Single-thread force cross matrix.
See
glass::force_cross.
-
namespace spatial_detail#
Functions
-
namespace warp
-
namespace thread
Spatial coordinate transforms#
Functions
-
template<typename T, bool TRAILING_SYNC = true>
void motion_transform(const T *E, const T *r, T *X)# Spatial motion transform matrix:
X = [[E, 0], [−E·[r]ₓ, E]](6x6).Materializes Featherstone’s
ᴮX_Afrom the(E, r)pair (see the file header for the frame convention). Column-major. Prefer the fusedmotion_transform_mulwhen only a product is needed.- Template Parameters:
T – Scalar type (e.g.
float,double).TRAILING_SYNC – Emit a trailing
__syncthreads()(default true).
- Parameters:
E – 3x3 rotation A→B (9 elements, column-major).
r – Origin of B expressed in A (3 elements).
X – Output 6x6 transform (36 elements, column-major; no aliasing).
-
template<typename T, bool TRAILING_SYNC = true>
void force_transform(const T *E, const T *r, T *X)# Spatial force transform matrix:
X* = X⁻ᵀ = [[E, −E·[r]ₓ], [0, E]](6x6).The dual transform for spatial FORCE vectors. Column-major. Prefer the fused
force_transform_mul.- Template Parameters:
T, TRAILING_SYNC – See
motion_transform.- Parameters:
E, r – The transform pair (see
motion_transform).X – Output 6x6 transform (36 elements, column-major; no aliasing).
-
template<typename T, bool INVERSE = false, bool HAS_BETA = false, bool TRAILING_SYNC = true>
void motion_transform_mul(T alpha, const T *E, const T *r, const T *v, T beta, T *y)# Fused spatial motion transform apply:
y = alpha·X·v + beta·y(orX⁻¹·vwhenINVERSE).Never materializes the 6x6:
X·v = [E·ω; E·(v_lin − r×ω)],X⁻¹·v = [Eᵀ·ω; Eᵀ·v_lin + r×(Eᵀ·ω)]. The forward form is the RNEA/ABA velocity down-sweep (v_child = X·v_parent); the inverse recovers parent-frame coordinates.betais only read whenHAS_BETA(BLAS beta==0 semantics viabeta_blend). Tested against thegemv(motion_transform(E, r), v)composition.- Template Parameters:
T – Scalar type.
INVERSE – Apply
X⁻¹instead ofX(default false).HAS_BETA – Read/accumulate into
y(default false = overwrite).TRAILING_SYNC – Emit a trailing
__syncthreads()(default true).
- Parameters:
alpha – Scalar on the product.
E, r – The transform pair (see
motion_transform).v – Spatial motion vector (6 elements,
[ω; v_lin]).beta – Scalar on the existing
y(read only whenHAS_BETA).y – Output spatial motion vector (6 elements; no aliasing).
-
template<typename T, bool INVERSE = false, bool HAS_BETA = false, bool TRAILING_SYNC = true>
void force_transform_mul(T alpha, const T *E, const T *r, const T *f, T beta, T *y)# Fused spatial force transform apply:
y = alpha·X*·f + beta·y(orX*⁻¹·f = Xᵀ·fwhenINVERSE).X*·f = [E·(n − r×f_lin); E·f_lin],Xᵀ·f = [Eᵀ·n + r×(Eᵀ·f_lin); Eᵀ·f_lin]. The INVERSE form is THE RNEA back-pass (f_parent += Xᵀ·f_child— useHAS_BETA = true, beta = 1). Same(alpha, beta)semantics asmotion_transform_mul. Tested against thegemv(force_transform(E, r), f)composition.- Template Parameters:
T, INVERSE, HAS_BETA, TRAILING_SYNC – See
motion_transform_mul.- Parameters:
alpha – Scalar on the product.
E, r – The transform pair (see
motion_transform).f – Spatial force vector (6 elements,
[n; f_lin]).beta – Scalar on the existing
y(read only whenHAS_BETA).y – Output spatial force vector (6 elements; no aliasing).
-
template<typename T>
void motion_transform(const T *E, const T *r, T *X)# Single-warp motion transform matrix.
Single-thread motion transform matrix.
See
glass::motion_transform.
-
template<typename T>
void force_transform(const T *E, const T *r, T *X)# Single-warp force transform matrix.
Single-thread force transform matrix.
See
glass::force_transform.
-
namespace spatial_detail
-
namespace warp
-
namespace thread
Spatial inertia (10 parameters)#
Functions
-
template<typename T, bool TRAILING_SYNC = true>
void spatial_inertia(const T *pi, T *M)# Spatial inertia matrix from the 10 standard parameters (6x6).
M = [[I_O, [h]ₓ], [[h]ₓᵀ, m·1₃]]withpi = [m, h(3), I_O(6)](see the file header for the packing and the Pinocchio-ordering caveat). Column-major; symmetric by construction. Prefer the fusedspatial_inertia_mulwhen only a product is needed.- Template Parameters:
T – Scalar type (e.g.
float,double).TRAILING_SYNC – Emit a trailing
__syncthreads()(default true).
- Parameters:
pi – The 10 inertial parameters
[m, h(3), Ixx, Ixy, Ixz, Iyy, Iyz, Izz].M – Output 6x6 spatial inertia (36 elements, column-major; no aliasing).
-
template<typename T, bool HAS_BETA = false, bool TRAILING_SYNC = true>
void spatial_inertia_mul(T alpha, const T *pi, const T *v, T beta, T *f)# Fused spatial inertia apply:
f = alpha·I(pi)·v + beta·f.I(pi)·v = [I_O·ω + h × v_lin ; m·v_lin − h × ω]— momentum from motion (RNEA’sI·vandI·aterms) straight from the parameter 10-vector; the 6x6 never materializes.betais only read whenHAS_BETA(BLAS beta==0 semantics viabeta_blend). Tested against thegemv(spatial_inertia(pi), v)composition.- Template Parameters:
T – Scalar type.
HAS_BETA – Read/accumulate into
f(default false = overwrite).TRAILING_SYNC – Emit a trailing
__syncthreads()(default true).
- Parameters:
alpha – Scalar on the product.
pi – The 10 inertial parameters (see
spatial_inertia).v – Spatial motion vector (6 elements,
[ω; v_lin]).beta – Scalar on the existing
f(read only whenHAS_BETA).f – Output spatial force vector (6 elements; no aliasing).
-
namespace spatial_detail
-
namespace warp
-
namespace thread
Quaternions#
Enums
-
enum class QuatLayout#
Compile-time quaternion storage layout tag.
xyzw— vector part first, scalar last (Eigen / NVIDIA Warp / cuRobo / GRiD storage order; the GLASS default).wxyz— scalar first (MuJoCo / Ceres / GTSAM / ROS geometry_msgs order). Both are HAMILTON quaternions; the tag only moves where each component is stored.Values:
-
enumerator xyzw#
-
enumerator wxyz#
-
enumerator xyzw#
Functions
-
template<typename T, QuatLayout L = QuatLayout::xyzw, bool TRAILING_SYNC = true>
void quat_mul(const T *a, const T *b, T *out)# Hamilton quaternion product:
out = a ⊗ b.Composition of rotations:
R(out) = R(a)·R(b)(applybfirst in the body frame ofa). Layout via theLtag (defaultxyzw); both operands and the result share one layout.outmust not aliasa/bat block/warp scope. NumPy equivalent (xyzw, scipy):(Rotation.from_quat(a) * Rotation.from_quat(b)).as_quat().- Template Parameters:
T – Scalar type (e.g.
float,double).L – Quaternion storage layout (default
QuatLayout::xyzw).TRAILING_SYNC – Emit a trailing
__syncthreads()(default true).
- Parameters:
a – Left quaternion (4 elements).
b – Right quaternion (4 elements).
out – Result quaternion (4 elements; no aliasing).
-
template<typename T, QuatLayout L = QuatLayout::xyzw, bool TRAILING_SYNC = true>
void quat_conj(const T *a, T *out)# Quaternion conjugate (= inverse for unit quaternions):
out = a*.Negates the vector part. NumPy equivalent (xyzw):
[-x, -y, -z, w].- Template Parameters:
T, L, TRAILING_SYNC – See
quat_mul.- Parameters:
a – Input quaternion (4 elements).
out – Conjugated quaternion (4 elements; no aliasing at block/warp scope).
-
template<typename T, QuatLayout L = QuatLayout::xyzw, bool CANONICAL = false, bool TRAILING_SYNC = true>
void quat_normalize(const T *q, T *out)# Normalize a quaternion to unit length:
out = q / |q|.With
CANONICAL = truethe result is also flipped onto thew >= 0half of the double cover (qand-qencode the same rotation) — useful before comparing or interpolating quaternions. In-place (out == q) is safe at thread:: scope only.- Template Parameters:
T, L, TRAILING_SYNC – See
quat_mul.CANONICAL – Also canonicalize the sign to
w >= 0(default false).
- Parameters:
q – Input quaternion (4 elements, nonzero).
out – Unit quaternion (4 elements).
-
template<typename T, QuatLayout L = QuatLayout::xyzw, bool TRAILING_SYNC = true>
void quat_exp(const T *phi, T *out)# Quaternion exponential of a rotation vector:
out = exp([φ/2]).φis the FULL rotation vector (axis · angle, radians); the half-angle is taken internally:out = [sin(|φ|/2)·φ̂ ; cos(|φ|/2)], with thesin(θ)/θTaylor head below θ = 1e-12 so the derivative is exact through φ = 0. NumPy equivalent (xyzw):Rotation.from_rotvec(phi).as_quat().- Template Parameters:
T, L, TRAILING_SYNC – See
quat_mul.- Parameters:
phi – Rotation vector (3 elements).
out – Unit quaternion (4 elements; no aliasing at block/warp scope).
-
template<typename T, QuatLayout L = QuatLayout::xyzw, bool TRAILING_SYNC = true>
void quat_log(const T *q, T *phi)# Quaternion logarithm: the rotation vector
φof a unit quaternion.The inverse of
quat_expon the canonical branch|φ| ≤ π:φ = 2·log(q)with the double cover folded (q and −q return the SAME shortest-path vector). Routed through2·atan2(|v|, w)— stable across the whole range including θ near π — with a series head below|v| = 1e-8keeping the map smooth through the identity.qmust be unit length. NumPy equivalent (xyzw):Rotation.from_quat(q).as_rotvec().- Template Parameters:
T, L, TRAILING_SYNC – See
quat_mul.- Parameters:
q – Unit quaternion (4 elements).
phi – Output rotation vector (3 elements; no aliasing at block/warp scope).
-
template<typename T, QuatLayout L = QuatLayout::xyzw, bool TRAILING_SYNC = true>
void quat_rotate(const T *q, const T *p, T *out)# Rotate a 3-vector by a unit quaternion:
out = R(q)·p.Uses the cross-product form
p + 2w(v×p) + 2v×(v×p)(no 3x3 materialized; 18 mul + 12 add vs 15 mul + 15 add through the matrix, but with no scratch).qmust be unit length. NumPy equivalent (xyzw):Rotation.from_quat(q).apply(p).- Template Parameters:
T, L, TRAILING_SYNC – See
quat_mul.- Parameters:
q – Unit quaternion (4 elements).
p – Input vector (3 elements).
out – Rotated vector (3 elements; no aliasing at block/warp scope).
-
template<typename T, QuatLayout L = QuatLayout::xyzw, uint32_t LDA = 3, bool TRAILING_SYNC = true>
void quat_to_rot(const T *q, T *R)# Rotation matrix (3x3 column-major) from a unit quaternion.
LDAis the destination’s leading dimension (row stride between columns; default 3 = contiguous).LDA = 4writes the rotation block of a column-major 4x4 homogeneous transform IN PLACE — only the nine rotation entries are touched (thegemv/gemmROW_STRIDE pattern extended to the Lie corner). NumPy equivalent (xyzw):Rotation.from_quat(q).as_matrix()(flatten Fortran-order for the column-major array).- Template Parameters:
T, L, TRAILING_SYNC – See
quat_mul.LDA – Destination leading dimension (default 3).
- Parameters:
q – Unit quaternion (4 elements).
R – Output rotation (column-major, leading dimension LDA; no aliasing).
-
template<typename T, QuatLayout L = QuatLayout::xyzw, uint32_t LDA = 3, bool TRAILING_SYNC = true>
void rot_to_quat(const T *R, T *q)# Unit quaternion from a rotation matrix (Shepperd max-pivot extraction).
Branches on the largest of the trace and the three diagonal entries so the divisor is never small — numerically safe for every rotation including the θ = π family. Result is canonicalized to
w >= 0.Ris column-major with leading dimensionLDA(default 3 = contiguous;LDA = 4reads the rotation block of a column-major 4x4 homogeneous transform in place — no repack). NumPy equivalent (xyzw):Rotation.from_matrix(R).as_quat()(up to the double-cover sign).- Template Parameters:
T, L, TRAILING_SYNC – See
quat_mul.LDA – Source leading dimension (default 3).
- Parameters:
R – Input rotation matrix (column-major, leading dimension LDA).
q – Output unit quaternion (4 elements; no aliasing at block/warp scope).
-
template<typename T, QuatLayout L = QuatLayout::xyzw, bool TRAILING_SYNC = true>
void quat_to_basis(const T *q, T *u, T *v, T *w)# Normalize a quaternion and return the three rotation-matrix columns.
u/v/wreceive columns 0/1/2 ofR(q/|q|)— the body frame’s three axes in the parent frame. The explicit normalize makes this safe on raw stored quaternions (e.g. parsed poses). Collision-geometry / frame-setup helper.- Template Parameters:
T, L, TRAILING_SYNC – See
quat_mul.- Parameters:
q – Quaternion (4 elements; NOT required to be unit).
u – Output column 0 (3 elements).
v – Output column 1 (3 elements).
w – Output column 2 (3 elements).
-
template<typename T, QuatLayout L = QuatLayout::xyzw, bool TRAILING_SYNC = true>
void quat_retract(const T *q, const T *phi, T *q_new)# SO(3) retract on the quaternion chart:
q_new = normalize(q ⊗ exp([φ/2])).The manifold update
q ⊞ φ(body-frame tangentφ, radians): one integrator step of a spherical joint / orientation state under angular velocity isquat_retract(q, ω·dt, q_new). The trailing renormalize keeps repeated retracts on the unit sphere (drift-free). NumPy equivalent (xyzw):(Rotation.from_quat(q) * Rotation.from_rotvec(phi)).as_quat().- Template Parameters:
T, L, TRAILING_SYNC – See
quat_mul.- Parameters:
q – Current unit quaternion (4 elements).
phi – Tangent step — full rotation vector (3 elements).
q_new – Updated unit quaternion (4 elements; no aliasing at block/warp scope).
-
template<typename T, QuatLayout L = QuatLayout::xyzw>
void quat_mul(const T *a, const T *b, T *out)# Single-warp
out = a ⊗ b.Single-thread
out = a ⊗ b.See
glass::quat_mul.
-
template<typename T, QuatLayout L = QuatLayout::xyzw>
void quat_conj(const T *a, T *out)# Single-warp conjugate.
Single-thread conjugate.
See
glass::quat_conj.
-
template<typename T, QuatLayout L = QuatLayout::xyzw, bool CANONICAL = false>
void quat_normalize(const T *q, T *out)# Single-warp normalize.
Single-thread normalize (optional
w>=0canonicalization).See
glass::quat_normalize.
-
template<typename T, QuatLayout L = QuatLayout::xyzw>
void quat_exp(const T *phi, T *out)# Single-warp
exp([φ/2]).Single-thread
exp([φ/2]).See
glass::quat_exp.
-
template<typename T, QuatLayout L = QuatLayout::xyzw>
void quat_log(const T *q, T *phi)# Single-warp quaternion logarithm.
Single-thread quaternion logarithm.
See
glass::quat_log.
-
template<typename T, QuatLayout L = QuatLayout::xyzw>
void quat_rotate(const T *q, const T *p, T *out)# Single-warp
R(q)·p.Single-thread
R(q)·p.See
glass::quat_rotate.
-
template<typename T, QuatLayout L = QuatLayout::xyzw, uint32_t LDA = 3>
void quat_to_rot(const T *q, T *R)# Single-warp quaternion → column-major 3x3 (LDA-strided).
Single-thread quaternion → column-major 3x3 (LDA-strided).
See
glass::quat_to_rot.
-
template<typename T, QuatLayout L = QuatLayout::xyzw, uint32_t LDA = 3>
void rot_to_quat(const T *R, T *q)# Single-warp 3x3 (LDA-strided) → quaternion (Shepperd).
Single-thread column-major 3x3 (LDA-strided) → quaternion (Shepperd).
See
glass::rot_to_quat.
-
template<typename T, QuatLayout L = QuatLayout::xyzw>
void quat_to_basis(const T *q, T *u, T *v, T *w)# Single-warp normalize + rotation columns.
Single-thread normalize + rotation columns.
See
glass::quat_to_basis.
-
template<typename T, QuatLayout L = QuatLayout::xyzw>
void quat_retract(const T *q, const T *phi, T *q_new)# Single-warp SO(3) quaternion retract.
Single-thread SO(3) quaternion retract.
See
glass::quat_retract.
-
namespace lie_detail#
Functions
-
template<typename T, QuatLayout L>
void quat_mul_core(const T *a, const T *b, T *out)#
-
template<typename T, QuatLayout L>
void quat_exp_core(const T *phi, T *out)#
-
template<typename T, QuatLayout L, bool CANONICAL>
void quat_normalize_core(const T *q, T *out)#
-
template<typename T, QuatLayout L>
void quat_rotate_core(const T *q, const T *p, T *out)#
-
template<typename T, QuatLayout L>
void quat_to_rot_core(const T *q, T *R)#
-
template<typename T, QuatLayout L, uint32_t LDA = 3>
void rot_to_quat_core(const T *R, T *q)#
-
template<typename T, QuatLayout L>
void quat_retract_core(const T *q, const T *phi, T *q_new)#
-
template<typename T, QuatLayout L>
void quat_log_core(const T *q, T *phi)#
-
template<>
struct layout<QuatLayout::wxyz>#
-
template<>
struct layout<QuatLayout::xyzw>#
-
template<typename T, QuatLayout L>
-
namespace warp
-
namespace thread
Pose errors#
Enums
-
enum class ErrorFrame#
Compile-time frame tag for the pose-error family.
LOCAL(default) — the error resolved in the body frame ofq_des(log(q_des⁻¹ ⊗ q); pair with body-frame Jacobians).WORLD— the same from-desired-to-current step resolved in the world frame (log(q ⊗ q_des⁻¹); pair with world-frame geometric Jacobians). Field precedent: pinocchioReferenceFrame::{LOCAL, WORLD}.Values:
-
enumerator LOCAL#
-
enumerator WORLD#
-
enumerator LOCAL#
Functions
-
template<typename T, QuatLayout L = QuatLayout::xyzw, ErrorFrame F = ErrorFrame::LOCAL, bool TRAILING_SYNC = true>
void quat_error(const T *q, const T *q_des, T *e)# Shortest-path rotation error, frame-tagged: LOCAL (default)
e = log(q_des⁻¹ ⊗ q); WORLDe = log(q ⊗ q_des⁻¹).Both frames are the tangent step FROM
q_desTOq(|e| ≤ πalways, double cover folded): LOCAL satisfiesquat_retract(q_des, e) == qand pairs with body-frame Jacobians (exact tangent JacobianJr(e)⁻¹,so3_right_jacobian_inv); WORLD satisfiesquat_mul(quat_exp(e), q_des) == q, equalsR(q_des)·e_LOCAL, and pairs with world-frame geometric Jacobians (IK / visual servoing / task-space control). Swapping the arguments negates the error in either frame. Both inputs must be unit. NumPy equivalents (xyzw, scipy): LOCAL(Rotation.from_quat(q_des).inv() * Rotation.from_quat(q)).as_rotvec(); WORLD(Rotation.from_quat(q) * Rotation.from_quat(q_des).inv()).as_rotvec().- Template Parameters:
T – Scalar type (e.g.
float,double).L – Quaternion storage layout (default
QuatLayout::xyzw).F – Error frame (default
ErrorFrame::LOCAL).TRAILING_SYNC – Emit a trailing
__syncthreads()(default true).
- Parameters:
q – Current unit quaternion (4 elements).
q_des – Desired unit quaternion (4 elements).
e – Output rotation-error vector (3 elements; no aliasing).
-
template<typename T, QuatLayout L = QuatLayout::xyzw, ErrorFrame F = ErrorFrame::LOCAL, bool TRAILING_SYNC = true>
void pose_error(const T *pose, const T *pose_des, T *e)# Decoupled 6-D pose error:
e = [p − p_des ; quat_error(q, q_des)].Poses are
[p(3); q(4)](these3_retractlayout); the error is linear-first, matching the SE(3)-tangent[ρ; φ]block order — but it is the R³ × SO(3) product error every GPU goal cost minimizes, NOT the coupled SE(3) log (see the file header). Exact tangent Jacobian: identity on the translation block,Jr(e_rot)⁻¹on the rotation block.- Template Parameters:
T, L, F, TRAILING_SYNC – See
quat_error(the frame tag applies to the rotation block; the translation difference is world-frame in both).- Parameters:
pose – Current pose
[p; q](7 elements, unit q).pose_des – Desired pose
[p; q](7 elements, unit q).e – Output error (6 elements,
[dp; drot]; no aliasing).
-
template<typename T, QuatLayout L = QuatLayout::xyzw>
T quat_angle(const T *q, const T *q_des)# Geodesic angle between two orientations:
θ = |quat_error(q, q_des)|.Computed as
2·atan2(|vec(q_des⁻¹ ⊗ q)|, |w(q_des⁻¹ ⊗ q)|)— stable across the whole range (no acos precision cliff near θ = 0), double cover folded,θ ∈ [0, π]. FRAME-INVARIANT: the LOCAL and WORLD errors are the same vector resolved in different frames, so their magnitude — this angle — is identical (noErrorFrametag by design). Both inputs must be unit. Scalar, tier-free. NumPy equivalent (xyzw, scipy):(Rotation.from_quat(q_des).inv() * Rotation.from_quat(q)).magnitude().- Template Parameters:
T – Scalar type.
L – Quaternion storage layout (default
QuatLayout::xyzw).
- Parameters:
q – Current unit quaternion (4 elements).
q_des – Desired unit quaternion (4 elements).
- Returns:
The geodesic angle (radians).
-
template<typename T, QuatLayout L = QuatLayout::xyzw, ErrorFrame F = ErrorFrame::LOCAL>
void quat_error(const T *q, const T *q_des, T *e)# Single-warp frame-tagged rotation error.
Single-thread frame-tagged rotation error.
See
glass::quat_error.
-
template<typename T, QuatLayout L = QuatLayout::xyzw, ErrorFrame F = ErrorFrame::LOCAL>
void pose_error(const T *pose, const T *pose_des, T *e)# Single-warp decoupled 6-D pose error.
Single-thread decoupled 6-D pose error.
See
glass::pose_error.
-
namespace lie_detail
Functions
-
template<typename T, QuatLayout L, ErrorFrame F = ErrorFrame::LOCAL>
void quat_error_core(const T *q, const T *q_des, T *e)#
-
template<typename T, QuatLayout L, ErrorFrame F = ErrorFrame::LOCAL>
void pose_error_core(const T *pose, const T *pose_des, T *e)#
-
template<typename T, QuatLayout L, ErrorFrame F = ErrorFrame::LOCAL>
-
namespace warp
-
namespace thread
SO(3): exp / log / Jacobians#
Functions
-
template<typename T, bool TRAILING_SYNC = true>
void skew(const T *v, T *S)# Hat map:
S = [v]ₓ(3x3 column-major skew-symmetric matrix).S·x = v × x. The SO(3) building block under every op in this family. NumPy equivalent:np.array([[0,-v[2],v[1]],[v[2],0,-v[0]],[-v[1],v[0],0]])(flatten Fortran-order for the column-major array).- Template Parameters:
T – Scalar type (e.g.
float,double).TRAILING_SYNC – Emit a trailing
__syncthreads()(default true).
- Parameters:
v – Input 3-vector.
S – Output 3x3 skew matrix (9 elements, column-major; no aliasing).
-
template<typename T, bool TRAILING_SYNC = true>
void so3_exp(const T *phi, T *R)# SO(3) exponential (Rodrigues):
R = exp([φ]ₓ).φis the full rotation vector (axis·angle). Taylor heads below θ = 1e-8 keep the map smooth through the identity. NumPy equivalent:Rotation.from_rotvec(phi).as_matrix()(Fortran-order flatten).- Template Parameters:
T, TRAILING_SYNC – See
skew.- Parameters:
phi – Rotation vector (3 elements).
R – Output 3x3 rotation (9 elements, column-major; no aliasing).
-
template<typename T, bool TRAILING_SYNC = true>
void so3_log(const T *R, T *phi)# SO(3) logarithm:
φ = log(R), canonical branch|φ| ≤ π.Implemented through the Shepperd quaternion extraction plus
φ = 2·atan2(|v|, w)·v̂— numerically stable across the WHOLE range, including θ near π where the textbookθ/(2 sinθ)·vee(R−Rᵀ)formula loses the axis. Inverse ofso3_exp(round-trip exact to floating tolerance for |φ| < π; at exactly θ = π the axis sign is the canonical-cover choice). NumPy equivalent:Rotation.from_matrix(R).as_rotvec().- Template Parameters:
T, TRAILING_SYNC – See
skew.- Parameters:
R – Input 3x3 rotation (9 elements, column-major).
phi – Output rotation vector (3 elements; no aliasing at block/warp scope).
-
template<typename T, bool TRAILING_SYNC = true>
void so3_right_jacobian(const T *phi, T *J)# SO(3) right Jacobian:
Jr(φ) = I − b·[φ]ₓ + c·[φ]ₓ².b = (1−cosθ)/θ²,c = (θ−sinθ)/θ³. Maps additive tangent perturbations to the manifold:exp(φ+δ) ≈ exp(φ)·exp(Jr(φ)·δ)— the object every on-manifold optimizer and covariance propagation needs. Identity:Jr(φ) = Jl(−φ).- Template Parameters:
T, TRAILING_SYNC – See
skew.- Parameters:
phi – Rotation vector (3 elements).
J – Output 3x3 Jacobian (9 elements, column-major; no aliasing).
-
template<typename T, bool TRAILING_SYNC = true>
void so3_right_jacobian_inv(const T *phi, T *J)# Inverse right Jacobian:
Jr(φ)⁻¹ = I + [φ]ₓ/2 + e·[φ]ₓ².e = 1/θ² − cot(θ/2)/(2θ)(half-angle form — finite at θ = π, exactly 1/π²; series1/12 + θ²/720 + …below θ = 1e-4).Jr⁻¹pulls manifold differences back to the tangent (IMU preintegration, on-manifold GN steps). Genuinely singular only at θ = 2π, outside the canonical |φ| ≤ π range.- Template Parameters:
T, TRAILING_SYNC – See
skew.- Parameters:
phi – Rotation vector (3 elements).
J – Output 3x3 inverse Jacobian (9 elements, column-major; no aliasing).
-
template<typename T, bool TRAILING_SYNC = true>
void so3_left_jacobian(const T *phi, T *J)# SO(3) left Jacobian:
Jl(φ) = Jr(−φ) = I + b·[φ]ₓ + c·[φ]ₓ².Also the SE(3) translation “V matrix”:
exp_se3(ρ,φ)translates byJl(φ)·ρ— some codebases (including the GRiD emitters this is promoted from) carry it under that name; it is the SAME matrix.- Template Parameters:
T, TRAILING_SYNC – See
skew.- Parameters:
phi – Rotation vector (3 elements).
J – Output 3x3 Jacobian (9 elements, column-major; no aliasing).
-
template<typename T, bool TRAILING_SYNC = true>
void so3_left_jacobian_inv(const T *phi, T *J)# Inverse left Jacobian:
Jl(φ)⁻¹ = I − [φ]ₓ/2 + e·[φ]ₓ².Same
ecoefficient (and the same θ = 2π caveat) asso3_right_jacobian_inv;Jl⁻¹(φ) = Jr⁻¹(−φ).- Template Parameters:
T, TRAILING_SYNC – See
skew.- Parameters:
phi – Rotation vector (3 elements).
J – Output 3x3 inverse Jacobian (9 elements, column-major; no aliasing).
-
template<typename T>
void skew(const T *v, T *S)# Single-warp hat map.
Single-thread hat map.
See
glass::skew.
-
template<typename T>
void so3_exp(const T *phi, T *R)# Single-warp Rodrigues exponential.
Single-thread Rodrigues exponential.
See
glass::so3_exp.
-
template<typename T>
void so3_log(const T *R, T *phi)# Single-warp SO(3) log (canonical branch).
Single-thread SO(3) log (canonical branch).
See
glass::so3_log.
-
template<typename T>
void so3_right_jacobian(const T *phi, T *J)# Single-warp right Jacobian.
Single-thread right Jacobian.
See
glass::so3_right_jacobian.
-
template<typename T>
void so3_right_jacobian_inv(const T *phi, T *J)# Single-warp inverse right Jacobian.
Single-thread inverse right Jacobian.
See
glass::so3_right_jacobian_inv.
-
namespace lie_detail
Functions
-
namespace warp
-
namespace thread
SE(3): retract + derivatives#
Functions
-
template<typename T, bool TRAILING_SYNC = true>
void se3_Q_block(const T *rho, const T *phi, T *Q)# Barfoot Q coupling block of the SE(3) exponential derivative (3x3).
The off-diagonal block of the SE(3) right Jacobian
[[Jr(φ), Q(ρ,φ)],[0, Jr(φ)]]; Pinocchio sign convention (validated againstpin.dIntegrateARG1 in the GRiD arc this is promoted from). Series form below θ = 1e-4.- Template Parameters:
T – Scalar type (e.g.
float,double).TRAILING_SYNC – Emit a trailing
__syncthreads()(default true).
- Parameters:
rho – Linear tangent (3 elements).
phi – Angular tangent (3 elements).
Q – Output 3x3 block (9 elements, column-major; no aliasing).
-
template<typename T, QuatLayout L = QuatLayout::xyzw, bool TRAILING_SYNC = true>
void se3_retract(const T *pose, const T *rho, const T *phi, T *pose_new)# SE(3) retract on a
[p(3); quat(4)]pose block:pose_new = pose ⊞ (ρ, φ).The free-flyer manifold update (one floating-base integrator step is
se3_retract(pose, v_lin·dt, ω·dt, pose_new)with a BODY-frame twist): orientationq_new = normalize(q ⊗ exp([φ/2])), positionp_new = p + R(q)·(Jl(φ)·ρ). Matches Pinocchio’sintegrateon the free-flyer joint. Joint-space tails (revolute q += v·dt) are a plain vector add — compose withglass::axpy, they are not this op’s job.- Template Parameters:
T – Scalar type.
L – Quaternion layout inside the pose block (default
xyzw— the Pinocchio nq layout[x,y,z, qx,qy,qz,qw]).TRAILING_SYNC – Emit a trailing
__syncthreads()(default true).
- Parameters:
pose – Input pose block (7 elements: position then quaternion).
rho – Linear tangent step (3 elements, body frame).
phi – Angular tangent step (3 elements, body frame).
pose_new – Output pose block (7 elements; no aliasing at block/warp scope).
-
template<typename T, QuatLayout L = QuatLayout::xyzw, bool TRAILING_SYNC = true>
void se3_difference(const T *pose_from, const T *pose_to, T *rho, T *phi)# SE(3) difference (boxminus): the tangent
[ρ; φ]withse3_retract(pose_from, ρ, φ) == pose_to— the exact inverse of the retract, equal to Pinocchiodifference(model, q_from, q_to)on the free-flyer block.Canonical branch |φ| ≤ π.
φ = log(q_from⁻¹ ⊗ q_to),ρ = Jl(φ)⁻¹ · R(q_from)ᵀ · (p_to − p_from)(body-frame tangent, linear-first — the same conventions as the retract).- Template Parameters:
T – Scalar type.
L – Quaternion layout inside the pose blocks (default
xyzw).TRAILING_SYNC – Emit a trailing
__syncthreads()(default true).
- Parameters:
pose_from – Base pose block (7 elements: position then quaternion).
pose_to – Target pose block (7 elements).
rho – Output linear tangent (3 elements; no aliasing at block scope).
phi – Output angular tangent (3 elements; no aliasing at block scope).
-
template<typename T, bool TRAILING_SYNC = true>
void se3_retract_jacobian_q(const T *rho, const T *phi, T *J)# 6x6 derivative of the SE(3) retract w.r.t.
the BASE POSE:
J = Ad_{exp(−[ρ;φ])}(PinocchiodIntegrateARG0).Column-major, tangent ordered
[ρ; φ](linear-first): block form[[R⁻, [−Jl(−φ)ρ]ₓ·R⁻],[0, R⁻]]withR⁻ = exp(−[φ]ₓ).- Template Parameters:
T, TRAILING_SYNC – See
se3_Q_block.- Parameters:
rho – Linear tangent (3 elements).
phi – Angular tangent (3 elements).
J – Output 6x6 block (36 elements, column-major; no aliasing).
-
template<typename T, bool TRAILING_SYNC = true>
void se3_retract_jacobian_v(const T *rho, const T *phi, T *J)# 6x6 derivative of the SE(3) retract w.r.t.
the TANGENT: the SE(3) right Jacobian
J = [[Jr(φ), Q(ρ,φ)],[0, Jr(φ)]](PinocchiodIntegrateARG1).Column-major, tangent ordered
[ρ; φ](linear-first).- Template Parameters:
T, TRAILING_SYNC – See
se3_Q_block.- Parameters:
rho – Linear tangent (3 elements).
phi – Angular tangent (3 elements).
J – Output 6x6 block (36 elements, column-major; no aliasing).
-
template<typename T, bool IS_Q, bool TRAILING_SYNC = true>
void se3_retract_hessian(const T *rho, const T *phi, T *J2)# 6x6x6 second derivative of the SE(3) retract:
J2[k·36 + c·6 + r] = ∂J(r,c)/∂w_k, w = [ρ; φ].The closed-form SE(3)-exp second derivative (structured chain rule on the Rodrigues/Q coefficient series; small-angle series below θ = 0.2), for
IS_Q = truedifferentiating the base-pose block (se3_retract_jacobian_q) and forIS_Q = falsethe tangent block (se3_retract_jacobian_v). Computed in DOUBLE internally regardless ofT(tiny once-per-step block; keeps float32 kernels matching float64 oracles — the validated design this is promoted from, mpmath-complex-step ground truth ≈1e-14). Layout: six stacked column-major 6x6 slices, one per tangent directionk.Parallelism: the block/warp tiers stride the 6 directions over the active threads (each direction’s slice is computed serially by one thread).
- Template Parameters:
T – Scalar type of the interface (output cast from double).
IS_Q – Differentiate the ARG0 (base-pose) block instead of ARG1.
TRAILING_SYNC – Emit a trailing
__syncthreads()(default true).
- Parameters:
rho – Linear tangent (3 elements).
phi – Angular tangent (3 elements).
J2 – Output tensor (216 elements; no aliasing).
-
template<typename T>
void se3_Q_block(const T *rho, const T *phi, T *Q)# Single-warp Barfoot Q block.
Single-thread Barfoot Q block.
See
glass::se3_Q_block.
-
template<typename T, QuatLayout L = QuatLayout::xyzw>
void se3_retract(const T *pose, const T *rho, const T *phi, T *pose_new)# Single-warp SE(3) retract.
Single-thread SE(3) retract.
See
glass::se3_retract.
-
template<typename T, QuatLayout L = QuatLayout::xyzw>
void se3_difference(const T *pose_from, const T *pose_to, T *rho, T *phi)# Single-warp SE(3) difference (boxminus).
Single-thread SE(3) difference (boxminus).
See
glass::se3_difference.
-
template<typename T>
void se3_retract_jacobian_q(const T *rho, const T *phi, T *J)# Single-warp retract Jacobian w.r.t.
Single-thread retract Jacobian w.r.t.
the base pose. See
glass::se3_retract_jacobian_q.
-
namespace lie_detail
Functions
-
template<typename T, QuatLayout L>
void se3_retract_core(const T *pose, const T *rho, const T *phi, T *out)#
-
template<typename T, QuatLayout L>
void se3_difference_core(const T *pose_from, const T *pose_to, T *rho, T *phi)#
-
void se3_d2_coefs(double t, double c[5], double dc[5])#
-
void se3_d2_dJr(const double phi[3], double t, const double c[5], const double dc[5], int k, double out[9])#
-
void se3_d2_dRinv(const double phi[3], double t, const double c[5], const double dc[5], int k, double out[9])#
-
void se3_d2_dQ(const double rho[3], const double phi[3], double t, const double c[5], const double dc[5], int kk, double out[9])#
-
void se3_d2_doff(const double rho[3], const double phi[3], double t, const double c[5], const double dc[5], int kk, double out[9])#
-
template<typename T, QuatLayout L>
-
namespace warp
-
namespace thread
Planar angles#
Functions
-
template<typename T>
T angle_wrap(T x)# Wrap an angle to the principal branch
(−π, π].Scalar, tier-free (see the header note). NumPy equivalent:
np.arctan2(np.sin(x), np.cos(x))— but computed by shifting, cheaper and exact for inputs already in range.- Template Parameters:
T – Scalar type (e.g.
float,double).- Parameters:
x – Angle in radians (any magnitude).
- Returns:
The equivalent angle in
(−π, π].
-
template<typename T>
T angle_diff(T a, T b)# Shortest signed angular difference
a − b, wrapped to(−π, π].The SO(2) “boxminus”: the smallest-magnitude rotation taking
btoa(positive = counterclockwise). Scalar, tier-free.- Template Parameters:
T – Scalar type.
- Parameters:
a – First angle (radians).
b – Second angle (radians).
- Returns:
angle_wrap(a − b).
-
template<typename T>
T angle_lerp(T a, T b, T t)# Wraparound-aware linear interpolation between two angles.
Interpolates along the SHORTEST arc:
angle_lerp(a, b, t) = a + t·(b ⊖ a)wrapped back to(−π, π]— so interpolating 179° → −179° passes through 180°, not 0°. Scalar, tier-free.- Template Parameters:
T – Scalar type.
- Parameters:
a – Start angle (radians).
b – End angle (radians).
t – Interpolation parameter (0 →
a, 1 →b).
- Returns:
The interpolated angle in
(−π, π].
-
template<typename T>
T clamp_unit(T v)# Clamp to
[−1, 1]— the acos/asin domain guard.Dot products of nominally-unit vectors drift past ±1 in floating point; feeding
acosa value like1 + 1e-7returns NaN. Clamp first:acos(clamp_unit(dot)). Scalar, tier-free.- Template Parameters:
T – Scalar type.
- Parameters:
v – Input value.
- Returns:
vclamped to[−1, 1].
-
namespace lie_detail
Cones & projections#
Functions
-
template<typename T>
T soc_tail_norm(const T *g, int32_t m)# Norm of the cone tail:
‖g[1:m]‖.Serial per-caller scalar (tier-free — see the header note). The
m ≤ ~16regime these ops serve makes a serial loop the right shape.- Template Parameters:
T – Scalar type (e.g.
float,double).- Parameters:
g – Cone-space vector (m elements; row 0 is the axis).
m – Vector length (axis + m−1 tail rows).
- Returns:
sqrt(Σ_{i>=1} g[i]²).
-
template<typename T>
T soc_violation(const T *g, int32_t m)# Second-order-cone violation:
max(0, ‖g[1:]‖ − g[0]).The margin metric (0 inside the cone). NOT the Euclidean distance to K — outside both K and its polar the distance divides this by √2. Scalar, tier-free.
- Template Parameters:
T – Scalar type.
- Parameters:
g – Cone-space vector (m elements).
m – Vector length.
- Returns:
The violation (>= 0).
-
template<typename T, bool TRAILING_SYNC = true>
void soc_project(const T *w, T *p, int32_t m)# Euclidean projection onto the second-order cone:
p = Π_K(w).K = {g : ‖g[1:m]‖ ≤ g[0]}. Idempotent; fixes points of K; maps the polar cone to 0; on the intermediate region returns the boundary point((w0+r)/2)·(1, w̄/r).wandpMAY alias at thread:: scope (GATO’s calling pattern); at block/warp scope they must not (strided writers race a reader). m = 1 degenerates tomax(0, ·)— the scalar hinge.- Template Parameters:
T – Scalar type.
TRAILING_SYNC – Emit a trailing
__syncthreads()(default true).
- Parameters:
w – Input vector (m elements).
p – Output projection (m elements).
m – Vector length.
-
template<typename T>
T al_soc_value(const T *g, const T *lam, T rho, int32_t m)# Conic PHR augmented-Lagrangian value:
φ = (‖Π_K(λ − ρg)‖² − ‖λ‖²) / (2ρ).The exact conic generalization of the hinge PHR term (m = 1 reduces to the
g >= 0hinge). C¹ ing;∇_g φ = −Π_K(λ − ρg); GN Hessian = ρ·JΠ on the active set. Computed WITHOUT materializing the projection:‖Π_K(w)‖²follows from the case split (inside:‖w‖²; polar: 0; boundary:2α²withα = (w0+r)/2). Scalar, tier-free.- Template Parameters:
T – Scalar type.
- Parameters:
g – Constraint values in cone space (m elements).
lam – Multiplier estimate (m elements).
rho – Penalty parameter (> 0).
m – Vector length.
- Returns:
The AL value contribution.
-
namespace proj_detail#
-
namespace warp
-
namespace thread
Interval / AL / barrier scalars#
Functions
-
template<typename T>
T interval_violation(T g, T lo, T hi)# Interval violation:
max(0, g − hi) + max(0, lo − g).The true (unsigned) constraint violation of
lo <= g <= hi; 0 when feasible. Scalar, tier-free.- Template Parameters:
T – Scalar type (e.g.
float,double).- Parameters:
g – Constraint value.
lo – Lower bound (may be −inf).
hi – Upper bound (may be +inf).
- Returns:
The violation (>= 0).
-
template<typename T>
bool al_is_eq_row(T lo, T hi)# Is this interval row an equality (
lo == hi, finite)?Scalar, tier-free. Equality rows carry a signed multiplier in the
lam_hislot of the interval AL ops.
-
template<typename T>
T al_hinge_value(T c, T lam, T rho, T sigma)# One hinge side’s PHR augmented-Lagrangian value (optionally elastic).
For the signed constraint
c(feasible whenc <= 0) with multiplierlam >= 0and penaltyrho:φ = (max(0, λ + ρc)² − λ²)/(2ρ), sodφ/dc = max(0, λ + ρc)and the GN Hessian is ρ on the active set. Withsigma > 0(L1 elastic slack weight) the activation saturates atsigma: beyond itφ = σc − (σ−λ)²/(2ρ)(linear; C¹ at the seam).sigma <= 0keeps the exact hard path. Scalar, tier-free.- Template Parameters:
T – Scalar type.
- Parameters:
c – Signed constraint value (
g − hi, orlo − g).lam – Multiplier (>= 0).
rho – Penalty parameter (> 0).
sigma – Elastic saturation weight (<= 0 disables softening).
- Returns:
The AL value contribution.
-
template<typename T>
T al_interval_value(T g, T lo, T hi, T lam_hi, T lam_lo, T rho, T sigma)# PHR augmented-Lagrangian VALUE of an interval row
lo <= g <= hi.Splits into independent hinge sides (
lam_hiforg <= hi,lam_loforg >= lo); infinite bounds contribute 0;lo == hirows are always-active equalities (φ = λc + ρc²/2, signed multiplier inlam_hi, elastic saturation symmetric at ±sigma). Scalar, tier-free. The matching outer multiplier update isλ ← max(0, λ + ρc)(equalities unclamped, elastic capped at sigma) on the ACCEPTED iterate.- Template Parameters:
T – Scalar type.
- Parameters:
g – Constraint value.
lo, hi – Interval bounds (either may be infinite).
lam_hi – Upper-side multiplier (equality rows: the signed multiplier).
lam_lo – Lower-side multiplier (unused on equality rows).
rho – Penalty parameter (> 0).
sigma – Elastic saturation weight (<= 0 disables softening).
- Returns:
The AL value contribution.
-
template<typename T>
void al_interval_grad_hess(T g, T lo, T hi, T lam_hi, T lam_lo, T rho, T sigma, T &gr, T &h)# PHR augmented-Lagrangian GRADIENT and GN HESSIAN of an interval row.
gr = dφ/dg,h = d²φ/dg²(GN: ρ per active side, 0 in the elastic saturation region). Same row semantics asal_interval_value. Scalar, tier-free.- Template Parameters:
T – Scalar type.
- Parameters:
g, lo, hi, lam_hi, lam_lo, rho, sigma – See
al_interval_value.gr – Output gradient.
h – Output GN Hessian.
-
template<typename T>
T relaxed_barrier_value(T d, T mu, T delta)# C² relaxed log-barrier VALUE on a bound distance
d.B(d) = −μ·log(d)ford > δ; the C² quadratic extension−μ·(log δ − 3/2 + 2d/δ − d²/(2δ²))ford <= δ— defined for ALLd(including infeasibled <= 0), Hessian bounded byμ/δ². Chain the sign ofdd/dgat the call site (+1 lower bound, −1 upper). Scalar, tier-free.- Template Parameters:
T – Scalar type.
- Parameters:
d – Distance to the bound (
g − loorhi − g).mu – Barrier weight (> 0).
delta – Relaxation threshold (> 0).
- Returns:
The barrier value.
-
template<typename T>
T relaxed_barrier_grad(T d, T mu, T delta)# Relaxed log-barrier derivative
dB/dd.See
relaxed_barrier_value.
-
template<typename T>
T relaxed_barrier_hess(T d, T mu, T delta)# Relaxed log-barrier second derivative
d²B/dd²(sign-free in the bound direction).See
relaxed_barrier_value.
-
template<typename T>
T relaxed_barrier_interval_value(T g, T lo, T hi, T mu, T delta)# Two-sided relaxed-barrier VALUE on
g ∈ [lo, hi](infinite bound → 0).Scalar, tier-free. See
relaxed_barrier_valuefor the one-sided form.
-
template<typename T>
T relaxed_barrier_interval_grad(T g, T lo, T hi, T mu, T delta)# Two-sided relaxed-barrier GRADIENT
dB/dg.See
relaxed_barrier_interval_value.
-
template<typename T>
T relaxed_barrier_interval_hess(T g, T lo, T hi, T mu, T delta)# Two-sided relaxed-barrier HESSIAN
d²B/dg².See
relaxed_barrier_interval_value.
-
template<typename T>
T smooth_hinge(T d, T eta)# Smooth hinge on a signed distance (collision-cost activation).
The CHOMP/cuRobo η-metric: for signed distance
d(positive = clear) and activation widtheta > 0,d <= 0:−d + η/2(linear in penetration)0 < d < η:(d−η)²/(2η)(quadratic taper)d >= η:0(inactive) C¹ at both seams. Compose withsphere_*_distfor collision costs. Scalar, tier-free.- Template Parameters:
T – Scalar type.
- Parameters:
d – Signed distance (positive = clear of contact).
eta – Activation width (> 0).
- Returns:
The activation cost (>= 0).
-
template<typename T>
T smooth_hinge_grad(T d, T eta)# Smooth-hinge derivative
d(cost)/dd.See
smooth_hinge.
-
template<typename T>
T log_cosh(T x)# Smooth absolute value:
log(cosh(x))(overflow-safe).The classic C-infinity |x| surrogate of pose/tracking costs (cuRobo’s smooth pose-distance metric): quadratic (
x²/2) near zero, asymptotically|x| − log 2. Evaluated as|x| + log1p(exp(−2|x|)) − log 2, which never overflows (naivelog(cosh(x))dies at |x| ≈ 89 in f32). For a scaled width uselog_cosh(x/s)·s. Scalar, tier-free.- Template Parameters:
T – Scalar type (e.g.
float,double).- Parameters:
x – Input value.
- Returns:
log(cosh(x))(>= 0).
Geometry distances#
Functions
-
template<typename T>
T sphere_sphere_dist(const T *c1, T r1, const T *c2, T r2)# Sphere-sphere signed distance:
‖c1 − c2‖ − (r1 + r2).Positive = separated, negative = penetrating. Scalar, tier-free.
- Template Parameters:
T – Scalar type (e.g.
float,double).- Parameters:
c1 – Center of sphere 1 (3 elements).
r1 – Radius of sphere 1.
c2 – Center of sphere 2 (3 elements).
r2 – Radius of sphere 2.
- Returns:
The signed distance.
-
template<typename T>
T sphere_sphere_dist(const T *c1, T r1, const T *c2, T r2, T *grad)# Sphere-sphere signed distance with the gradient w.r.t.
c1.grad = ∂d/∂c1 = (c1 − c2)/‖c1 − c2‖(the unit separating direction; the gradient w.r.t.c2is its negation). Coincident centers (‖·‖ below 1e-12) return a zero gradient — the caller sees the (measure-zero) degenerate case explicitly rather than a NaN. Scalar, tier-free.- Template Parameters:
T – Scalar type.
- Parameters:
c1, r1, c2, r2 – See
sphere_sphere_dist.grad – Output ∂d/∂c1 (3 elements).
- Returns:
The signed distance.
-
template<typename T>
T sphere_box_dist(const T *c, T r, const T *half, T *grad)# Sphere-box signed distance (box frame) with the gradient w.r.t.
the center.
The box is axis-aligned in ITS OWN frame, centered at the origin with half extents
half[3]; transform the sphere center into the box frame first for an OBB (quat_rotatewith the inverse box pose — the cuRobo pattern). Uses the canonical box SDF: withq_i = |c_i| − half_i,d_box = ‖max(q, 0)‖ + min(max_i q_i, 0); the sphere distance isd_box − r. Negative = penetrating.grad = ∂d/∂c: the normalized outward offset outside the box, the (sign-carrying) max-penetration face normal inside — the direction to move the CENTER to increase clearance. Scalar, tier-free.- Template Parameters:
T – Scalar type.
- Parameters:
c – Sphere center IN THE BOX FRAME (3 elements).
r – Sphere radius.
half – Box half extents (3 elements, > 0).
grad – Output ∂d/∂c (3 elements; box frame).
- Returns:
The signed distance.
-
template<typename T>
T sphere_box_dist(const T *c, T r, const T *half)# Sphere-box signed distance (box frame), distance only.
See the gradient overload for semantics.
- Template Parameters:
T – Scalar type.
- Parameters:
c – Sphere center IN THE BOX FRAME (3 elements).
r – Sphere radius.
half – Box half extents (3 elements, > 0).
- Returns:
The signed distance.
-
template<typename T, QuatLayout L = QuatLayout::xyzw>
void transform_sphere(const T *q, const T *p, const T *sph, T *out)# Rigid-transform a sphere: rotate + translate the center, keep the radius.
sph = [cx, cy, cz, r](the standard packed GPU collision-sphere layout);out[0:3] = R(q)·c + p,out[3] = r.qmust be unit. Scalar, tier-free;outmay aliassph.- Template Parameters:
T – Scalar type.
L – Quaternion layout of
q(defaultxyzw).
- Parameters:
q – Unit rotation quaternion (4 elements).
p – Translation (3 elements).
sph – Input sphere
[c(3); r](4 elements).out – Output sphere
[c(3); r](4 elements; aliasing allowed).
Functions
-
template<typename T>
void frame_from_vector(const T *n, T *t, T *b)# Right-handed orthonormal tangent basis from a unit vector (branchless).
Given UNIT
n, writestandbwith{t, b, n}orthonormal and right-handed (t × b = n). Duff et al. (JCGT 2017) construction: exact orthonormality to rounding for every input direction, no branch, no normalization — continuity breaks only across the singlen_zsign change (unavoidable: no globally continuous tangent field exists on the sphere).nmust be normalized (‖n‖ = 1); the basis quality degrades smoothly with ‖n‖ error. Scalar, tier-free.- Template Parameters:
T – Scalar type (e.g.
float,double).- Parameters:
n – Unit vector (3 elements).
t – Output tangent (3 elements).
b – Output bitangent (3 elements).
Functions
-
template<typename T>
T segment_segment_closest(const T *p1, const T *q1, const T *p2, const T *q2, T &s, T &t, T *c1, T *c2)# Closest points between segments
[p1, q1]and[p2, q2].Returns the SQUARED distance between the closest points and writes the parameters
s, t ∈ [0, 1]plus the points themselves (c1 = p1 + s·(q1−p1),c2 = p2 + t·(q2−p2)). Degenerate (point-like) segments and near-parallel pairs are handled via the1e-12-scaled guards (Ericson §5.1.9); parallel overlapping segments return one valid minimizing pair. Capsule-capsule signed distance issqrt(result) − (r1 + r2). Scalar, tier-free.- Template Parameters:
T – Scalar type (e.g.
float,double).- Parameters:
p1, q1 – Endpoints of segment 1 (3 elements each).
p2, q2 – Endpoints of segment 2 (3 elements each).
s – Output parameter on segment 1 (in [0, 1]).
t – Output parameter on segment 2 (in [0, 1]).
c1 – Output closest point on segment 1 (3 elements).
c2 – Output closest point on segment 2 (3 elements).
- Returns:
The squared distance
‖c1 − c2‖².
3x3 estimation kit#
Functions
-
template<typename T, bool TRAILING_SYNC = true>
void eig3(const T *A, T *W, T *V)# Symmetric 3x3 eigendecomposition:
A = V·diag(W)·Vᵀ, W ASCENDING.Fixed-sweep serial cyclic Jacobi (
eigh_sweeps<T>()sweeps — the 3x3 sibling ofglass::eigh; deterministic, bit-identical across thread counts and runs).Amust be symmetric; only its stored values are read (no symmetrization). NumPy equivalent:W, V = np.linalg.eigh(A)(up to eigenvector signs).- Template Parameters:
T – Scalar type (e.g.
float,double).TRAILING_SYNC – Emit a trailing
__syncthreads()(default true).
- Parameters:
A – Input symmetric 3x3 (9 elements, column-major).
W – Output eigenvalues, ascending (3 elements).
V – Output eigenvectors (9 elements, column-major; column k ↔ W[k]).
-
template<typename T, bool TRAILING_SYNC = true>
void svd3(const T *A, T *U, T *S, T *V)# General 3x3 SVD:
A = U·diag(S)·Vᵀ, S DESCENDING (σ₁ ≥ σ₂ ≥ σ₃ ≥ 0).Routed through
eig3(AᵀA)with guarded left-vector recovery and deterministic Gram-Schmidt / cross-product completion for rank-deficient inputs (see the file header; note the √ε small-σ precision floor of the AᵀA squaring — prefer f64 for tight small-σ needs).U/Vare orthogonal but may have det −1 (standard SVD semantics);closest_rotationapplies the proper-rotation det fix. NumPy equivalent:U, S, Vt = np.linalg.svd(A)(up to paired column signs).- Template Parameters:
T, TRAILING_SYNC – See
eig3.- Parameters:
A – Input 3x3 (9 elements, column-major; any matrix).
U – Output left singular vectors (9 elements, column-major).
S – Output singular values, descending (3 elements).
V – Output right singular vectors (9 elements, column-major, NOT transposed).
-
template<typename T, bool TRAILING_SYNC = true>
void closest_rotation(const T *A, T *R)# Closest proper rotation to a 3x3 matrix (Frobenius sense):
R = U·diag(1, 1, det(U)·det(V))·Vᵀfromsvd3(A).ONE op, three classic jobs:
Re-orthonormalize a drifted rotation matrix (
A ≈ Rafter integration).The polar decomposition’s rotation factor (
A = R·S, S symmetric PSD when det(A) ≥ 0).The Kabsch / Wahba / Umeyama best-fit rotation: feed the cross covariance
M = Σ b_i·a_iᵀ(centered correspondences, asglass::geraccumulations) andR = argmin_R Σ‖b_i − R·a_i‖². The det fix guaranteesR ∈ SO(3)(det +1) for ANY input including det(A) < 0. Unique when σ₂ + σ₃ > 0 (i.e. rank ≥ 2 and not the degenerate reflection tie); the deterministic completion picks a fixed representative otherwise.
- Template Parameters:
T, TRAILING_SYNC – See
eig3.- Parameters:
A – Input 3x3 (9 elements, column-major).
R – Output rotation (9 elements, column-major, det +1; no aliasing).
-
template<typename T>
void eig3(const T *A, T *W, T *V)# Single-warp symmetric 3x3 eigendecomposition.
Single-thread symmetric 3x3 eigendecomposition.
See
glass::eig3.
-
namespace est_detail#
Functions
-
namespace warp
-
namespace thread
Fused Gauss-Newton / LM step#
Functions
-
template<typename T, uint32_t N>
constexpr std::size_t gn_step_scratch_bytes()# Scratch size in bytes for
warp::gn_step’s normal-matrix buffer.- Template Parameters:
T – Scalar type.
N – Parameter count (columns of J).
- Returns:
Bytes to allocate for
s_A.
-
template<typename T, uint32_t M, uint32_t N, bool REGULARIZE = true, bool CHECK = true, bool REG_DIAG = true>
void gn_step(const T *J, const T *r, T lambda, T *dq, T *s_A, int *s_fail = nullptr)# Single-warp fused GN/LM step: form and solve
(JᵀJ + lambda·shift) dq = Jᵀ r.One 32-lane warp:
s_A = JᵀJ(warp::syrk, lanes spread the N² accumulations),dq = Jᵀr(warp::gemv<TRANSPOSE>), then the flaggedwarp::posvshifts the diagonal (Marquardtlambda·diag(A)whenREG_DIAG, else Levenberglambda·I), factors, solves in place, and reports a non-PD pivot throughs_failwhenCHECK. On returndqholds the step,s_Aholds the Cholesky factor of the shifted matrix (clobbered scratch).lambda = 0withCHECK = trueis plain Gauss-Newton with a rank guard. Full 32 lanes required; independent warps may run distinct problems concurrently.- Template Parameters:
T – Scalar type (use
doublefor ill-conditioned J).M – Rows of
J(residual length; M >= N for a full-rank system).N – Columns of
J(parameter count; A is N x N).REGULARIZE – Apply the lambda shift (default true; false compiles it out).
CHECK – Report a non-PD pivot via
s_fail(default true).REG_DIAG – Shift by
lambda·diag(JᵀJ)(Marquardt, default true) instead oflambda·I(Levenberg).
- Parameters:
J – Input Jacobian (M x N, column-major; read-only).
r – Input residual (M elements; read-only).
lambda – Damping factor (ignored when !REGULARIZE).
dq – Output step (N elements; warp-shared memory).
s_A – Scratch for the N x N normal matrix (warp-shared, N*N elements — see
gn_step_scratch_bytes); clobbered.s_fail – Non-PD flag when CHECK (set to 1 on failure, else 0).
-
namespace warp
Sampling reductions (L1)#
Functions
-
template<typename T>
constexpr std::size_t softmax_scratch_bytes(uint32_t n)# Shared-scratch size in bytes for
softmax/logsumexp.Both stage the scaled inputs / exponentials through an
n-element buffer that the in-place reduction trees then consume.- Template Parameters:
T – Scalar type.
- Parameters:
n – Number of elements.
- Returns:
Bytes to allocate for
s_scratch.
-
template<typename T, bool TRAILING_SYNC = true>
void softmax(uint32_t n, T alpha, const T *x, T *y, T *s_scratch)# Max-shifted softmax:
y_i = exp(αx_i − M) / Σ_j exp(αx_j − M),M = max_j(αx_j).Σ y = 1;α = −λgives the MPPI path-integral weight update on a cost vector. Shift-invariant and overflow-safe by the max subtraction.yMAY aliasx(same-index elementwise writes);s_scratchmust be a distinctn-element buffer. Thread-count invariant (fixed-order reduction trees). NumPy equivalent:scipy.special.softmax(alpha * x).- Template Parameters:
T – Scalar type (e.g.
float,double).TRAILING_SYNC – Emit a trailing
__syncthreads()(default true).
- Parameters:
n – Number of elements.
alpha – Scale on the inputs (temperature; negate for costs).
x – Input vector of length
n.y – Output weights of length
n(may aliasx).s_scratch – Shared scratch of
softmax_scratch_bytes<T>(n)bytes.
-
template<typename T, bool TRAILING_SYNC = true>
void logsumexp(uint32_t n, T alpha, const T *x, T *out, T *s_scratch)# Stable log-sum-exp:
out[0] = M + log(Σ_j exp(αx_j − M)),M = max_j(αx_j).The log-partition of
softmax(α·x)— free energy in path-integral control, the stable normalizer everywhere else. Thread-count invariant; ends on the trailing sync soout[0]is block-visible. NumPy equivalent:scipy.special.logsumexp(alpha * x).- Template Parameters:
T, TRAILING_SYNC – See
softmax.- Parameters:
n – Number of elements.
alpha – Scale on the inputs.
x – Input vector of length
n.out – Output:
out[0]receives the log-sum-exp.s_scratch – Shared scratch of
softmax_scratch_bytes<T>(n)bytes.
-
template<typename T>
void softmax(uint32_t n, T alpha, const T *x, T *y)# Single-warp max-shifted softmax (no scratch).
Single-thread max-shifted softmax (no scratch).
See
glass::softmax.One full 32-lane warp; lanes stride the vector, the max and the sum fold through xor-butterfly shuffles (every lane holds the result — no shared memory, no
__syncthreads).ymay aliasx. Full 32 lanes required.See
glass::softmax.
-
namespace softmax_detail#
-
namespace warp
-
namespace thread
Functions
-
template<typename T>
constexpr std::size_t argreduce_scratch_bytes(uint32_t block_threads)# Shared-scratch size in bytes for
argmax/argmin.One signed key (
T) plus one index (uint32_t) per thread — the same layout (and size) asiamax_scratch_bytes.- Template Parameters:
T – Scalar type.
- Parameters:
block_threads – Number of threads in the launching block.
- Returns:
Bytes to allocate for
s_scratch.
-
template<typename T, bool TRAILING_SYNC = true>
void argmax(uint32_t n, const T *x, uint32_t *out, T *s_scratch)# Index of the maximum element (signed), into
out[0].np.argmaxsemantics with the LOWER-index tie-break at every combine step (thread-count invariant) and NaN skipped (see the header note; all-NaN → 0). Non-destructive. NumPy equivalent:int(np.argmax(x))(NaN-free inputs).- Template Parameters:
T – Scalar type (e.g.
float,double).TRAILING_SYNC – Emit a trailing
__syncthreads()(default true).
- Parameters:
n – Number of elements.
x – Read-only input vector of length
n.out – Output:
out[0]receives the argmax index.s_scratch – Shared scratch of
argreduce_scratch_bytes<T>(blockDim)bytes.
-
template<typename T, bool TRAILING_SYNC = true>
void argmax(uint32_t n, const T *x, uint32_t *out, T *out_val, T *s_scratch)# argmaxalso returning the maximum value inout_val[0].NumPy equivalents:
out[0] = int(np.argmax(x)),out_val[0] = np.max(x)(NaN-free inputs; all-NaN returnsx[0]).- Template Parameters:
T, TRAILING_SYNC – See
argmax.- Parameters:
n, x, s_scratch – See
argmax.out – Output index slot.
out_val – Output value slot.
-
template<typename T, bool TRAILING_SYNC = true>
void argmin(uint32_t n, const T *x, uint32_t *out, T *s_scratch)# Index of the minimum element (signed), into
out[0].np.argminsemantics; tie-break, NaN policy, and invariance asargmax.- Template Parameters:
T, TRAILING_SYNC – See
argmax.- Parameters:
n, x, out, s_scratch – See
argmax.
-
template<typename T, bool TRAILING_SYNC = true>
void argmin(uint32_t n, const T *x, uint32_t *out, T *out_val, T *s_scratch)# argminalso returning the minimum value inout_val[0].NumPy equivalents:
out[0] = int(np.argmin(x)),out_val[0] = np.min(x).- Template Parameters:
T, TRAILING_SYNC – See
argmax.- Parameters:
n, x, out, out_val, s_scratch – See the value-returning
argmax.
-
template<typename T>
constexpr std::size_t argreduce_fast_scratch_bytes(uint32_t block_threads)# Shared-scratch size in bytes for
argmax_fast/argmin_fast.One (key, index) slot per warp — the same layout (and size) as
iamax_fast_scratch_bytes.- Template Parameters:
T – Scalar type.
- Parameters:
block_threads – Number of threads in the launching block.
- Returns:
Bytes to allocate for the
_fastscratch.
-
template<typename T, bool TRAILING_SYNC = true>
void argmax_fast(uint32_t n, const T *x, uint32_t *out, T *s_scratch)# argmax, warp-shuffle variant (in-register warp folds + per-warp scratch combine — theiamax_faststrategy, signed).Bit-identical result to
argmax(same combine, same tie-break/NaN policy); fewer scratch bytes and no serial thread-0 fold — the wide-block fast path. Scratch viaargreduce_fast_scratch_bytes<T>(blockDim). REQUIRES a full-warp block size (a multiple of 32): the shuffle folds use the full 0xffffffff mask (theiamax_fastcontract) — use the defaultargmaxfor partial-warp blocks.- Template Parameters:
T – Scalar type (e.g.
float,double).TRAILING_SYNC – Emit a trailing
__syncthreads()(default true).
- Parameters:
n – Number of elements.
x – Read-only input vector of length
n.out – Output:
out[0]receives the argmax index.s_scratch – Shared scratch of
argreduce_fast_scratch_bytes<T>(blockDim)bytes.
-
template<typename T, bool TRAILING_SYNC = true>
void argmax_fast(uint32_t n, const T *x, uint32_t *out, T *out_val, T *s_scratch)# argmax_fastalso returning the maximum value inout_val[0].- Template Parameters:
T, TRAILING_SYNC – See
argmax_fast.- Parameters:
n, x, s_scratch – See
argmax_fast.out – Output index slot.
out_val – Output value slot.
-
template<typename T, bool TRAILING_SYNC = true>
void argmin_fast(uint32_t n, const T *x, uint32_t *out, T *s_scratch)# argmin, warp-shuffle variant.See
argmax_fast.- Template Parameters:
T, TRAILING_SYNC – See
argmax_fast.- Parameters:
n, x, out, s_scratch – See
argmax_fast.
-
template<typename T, bool TRAILING_SYNC = true>
void argmin_fast(uint32_t n, const T *x, uint32_t *out, T *out_val, T *s_scratch)# argmin_fastalso returning the minimum value inout_val[0].- Template Parameters:
T, TRAILING_SYNC – See
argmax_fast.- Parameters:
n, x, out, out_val, s_scratch – See the value-returning
argmax_fast.
-
template<typename T>
uint32_t argmax_pair(T key, uint32_t idx)# Warp argmax over PER-LANE register (key, index) pairs; winning index returned on every lane.
The register entry point for “each lane evaluated its own candidate” patterns (warp-packed samplers, coarse-search sweeps, best-rollout picks): no array staging, no scratch — the pair folds through
__shfl_down_syncwith the SAME lower-index tie-break and NaN-skip combine as every other argreduction, so results are lane/order independent. Passidx = UINT32_MAXfrom lanes with no candidate (they never win); if ALL lanes are empty the sentinelUINT32_MAXis returned. Full 32-lane warp required (mask0xffffffff).- Template Parameters:
T – Scalar type (e.g.
float,double).- Parameters:
key – This lane’s candidate key.
idx – This lane’s candidate index (
UINT32_MAX= empty lane).
- Returns:
The winning index, identical on every lane.
-
template<typename T>
uint32_t argmax_pair(T key, uint32_t idx, T &win_key)# argmax_pairalso returning the winning key on every lane.- Template Parameters:
T – Scalar type.
- Parameters:
key, idx – See
argmax_pair.win_key – Out: the winning key (valid on every lane; unspecified when all lanes are empty).
- Returns:
The winning index, identical on every lane.
-
template<typename T>
uint32_t argmin_pair(T key, uint32_t idx)# Warp argmin over PER-LANE register (key, index) pairs.
See
argmax_pair(same mechanism, minimum direction).- Template Parameters:
T – Scalar type.
- Parameters:
key, idx – See
argmax_pair.- Returns:
The winning index, identical on every lane.
-
template<typename T>
uint32_t argmin_pair(T key, uint32_t idx, T &win_key)# argmin_pairalso returning the winning key on every lane.- Template Parameters:
T – Scalar type.
- Parameters:
key, idx, win_key – See the value-returning
argmax_pair.- Returns:
The winning index, identical on every lane.
-
namespace argreduce_detail#
Functions
-
template<typename T, bool MINIMUM, bool TRAILING_SYNC, typename Key = IdKey>
void argreduce(uint32_t n, const T *x, uint32_t *out, T *out_val, T *s_scratch)#
-
template<typename T, bool MINIMUM, bool TRAILING_SYNC, typename Key = IdKey>
void argreduce_fast(uint32_t n, const T *x, uint32_t *out, T *out_val, T *s_scratch)#
-
template<typename T, bool MINIMUM, typename Key = IdKey>
uint32_t argreduce_warp(uint32_t n, const T *x)#
-
struct AbsKey#
-
struct IdKey#
-
template<typename T, bool MINIMUM, bool TRAILING_SYNC, typename Key = IdKey>
-
namespace warp
-
namespace thread