include/vecmat/soa3.h file

Minimal 3-vector geometry on structure-of-arrays views.

A view is three borrowed component pointers; vector i is (x[i], y[i], z[i]). The view carries no size, ownership, padding, or SIMD width. Each component array has unit stride and needs only natural alignment. Component arrays must not overlap each other.

Every call batches independent vectors, unlike the single-vector vec3_dot / vec3_cross. n <= 0 is a no-op and reads nothing; null pointers are then allowed. For n > 0 every pointer must be non-null and address n elements. No allocation.

The views hold selected-width pointers, so use them only with the TU's width (VECMAT_USE_F64 or not).

Accuracy is an absolute bound, not a ULP claim: for normal finite intermediates the error is at most 16 eps × the sum of the absolute intermediate terms (for distances, the terms after the subtraction). Cancellation can make the relative error unbounded.

Classes

struct vm_soa3
Writable borrowed SoA view of 3-vectors.
struct vm_csoa3
Read-only borrowed SoA view of 3-vectors.

Typedefs

using vm_soa3 = struct vm_soa3
Writable borrowed SoA view of 3-vectors.
using vm_csoa3 = struct vm_csoa3
Read-only borrowed SoA view of 3-vectors.

Functions

void vm_soa3_dot(vm_float_t* res, vm_csoa3 a, vm_csoa3 b, int n)
res[i] = a[i] · b[i].
void vm_soa3_cross(vm_soa3 res, vm_csoa3 a, vm_csoa3 b, int n)
res[i] = a[i] × b[i].
void vm_soa3_length_squared(vm_float_t* res, vm_csoa3 a, int n)
res[i] = |a[i]|².
void vm_soa3_distance_squared(vm_float_t* res, vm_csoa3 a, vm_csoa3 b, int n)
res[i] = |a[i] - b[i]|².

Function documentation

void vm_soa3_dot(vm_float_t* res, vm_csoa3 a, vm_csoa3 b, int n)

res[i] = a[i] · b[i].

Parameters
res Output; length n.
a Left vectors; length n.
b Right vectors; length n. May exactly alias a.
n

Evaluated as (ax*bx + ay*by) + az*bz, unfused. a may exactly alias b. res must not overlap any input component.

void vm_soa3_cross(vm_soa3 res, vm_csoa3 a, vm_csoa3 b, int n)

res[i] = a[i] × b[i].

Parameters
res Output vectors; length n. May exactly equal a or b.
a Left vectors; length n.
b Right vectors; length n.
n

Each component is p*q - r*s, unfused. All six input components of vector i are loaded before any store, so res may exactly equal the a or b view (same three pointers). A partial overlap, or a res component that aliases a different input component, is caller error.

void vm_soa3_length_squared(vm_float_t* res, vm_csoa3 a, int n)

res[i] = |a[i]|².

Parameters
res Output; length n.
a Vectors; length n.
n

Evaluated as (x*x + y*y) + z*z, unfused. res must not overlap any input component.

void vm_soa3_distance_squared(vm_float_t* res, vm_csoa3 a, vm_csoa3 b, int n)

res[i] = |a[i] - b[i]|².

Parameters
res Output; length n.
a First vectors; length n.
b Second vectors; length n. May exactly alias a.
n

Each axis difference is rounded once, then squared and summed as in vm_soa3_length_squared. a may exactly alias b. res must not overlap any input component.