sied (sied v0.2.7)
View Sourcesied - SIMD operations for Erlang
High-performance vectorized operations using SIMD instructions via Rust NIF with simdeez. Provides runtime SIMD detection and automatic dispatch to SSE2, SSE4.1, AVX2, or NEON instructions.
Summary
Functions
Compute absolute value of an f32 vector
Compute absolute value of an f64 vector
Element-wise addition of two f32 vectors
Element-wise addition of two f64 vectors
Batch cosine similarity: one f32 query against many f32 vectors.
Batch cosine similarity: one f64 query against many f64 vectors.
Cosine similarity between two f32 vectors: dot(A,B) / (|A| * |B|). Returns a value in [-1.0, 1.0].
Cosine similarity between two f64 vectors.
Element-wise division of two f32 vectors
Element-wise division of two f64 vectors
Compute dot product of Query against every vector in Vecs. Returns {ok, [Score]} in input order. One NIF call for the whole batch.
Dot product of a query f32 binary against a list of f32 binaries. Binaries are little-endian IEEE 754 f32 (4 bytes per element). Avoids Erlang float-list marshalling — use with kvex f32-binary storage.
Compute dot product of Query against every f64 vector in Vecs.
Compute dot product of two f32 vectors Computes the scalar product: sum(A[i] * B[i])
Compute dot product of two f64 vectors Computes the scalar product: sum(A[i] * B[i])
Dot-product scoring of selected vectors from a flat f32 binary. indices: list produced by hamming_topk_flat. Returns {ok, [{Score, Idx}]} sorted by descending score.
Batch hamming distance between a query binary and a list of binaries. Returns {ok, [Distance]} where lower distance means more similar. Uses u64 POPCNT for speed. Intended for the first phase of two-phase ANN search: hamming_distance_batch → filter top-N → dot_product_batch.
Hamming top-K from a flat binary buffer (all vectors concatenated). Returns {ok, [Idx]} — the indices of the top_k closest vectors, sorted ascending by Hamming distance. O(N) partition + O(K log K) sort, no per-element Erlang overhead.
L2 (Euclidean) norm of an f32 vector
L2 (Euclidean) norm of an f64 vector
L2-normalize a batch of f32 vectors.
L2-normalize a batch of f64 vectors.
L2-normalize an f32 vector to unit length. Returns the original vector if its norm is zero.
L2-normalize an f64 vector to unit length.
Element-wise maximum of two f32 vectors
Element-wise maximum of two f64 vectors
Find maximum value in an f32 vector
Find maximum value in an f64 vector
Compute arithmetic mean of an f32 vector
Compute arithmetic mean of an f64 vector
Element-wise minimum of two f32 vectors
Element-wise minimum of two f64 vectors
Find minimum value in an f32 vector
Find minimum value in an f64 vector
Element-wise multiplication of two f32 vectors
Element-wise multiplication of two f64 vectors
Negate an f32 vector (multiply by -1)
Negate an f64 vector (multiply by -1)
Compute square root of an f32 vector
Compute square root of an f64 vector
Compute standard deviation of an f32 vector
Compute standard deviation of an f64 vector
Element-wise subtraction of two f32 vectors
Element-wise subtraction of two f64 vectors
Compute sum of all elements in an f32 vector
Compute sum of all elements in an f64 vector
1-bit quantize an f32 vector. Each element becomes 1 if above mean, else 0. Returns a packed binary: 128 dims → 16 bytes. Use hamming_distance_batch/2 to search over quantized vectors.
Like to_binary_f32/1 but accepts a little-endian f32 binary instead of a float list. Zero-copy path when the vector is already stored as a binary (e.g. in kvex ETS).
Compute variance of an f32 vector
Compute variance of an f64 vector
Functions
Compute absolute value of an f32 vector
Compute absolute value of an f64 vector
Element-wise addition of two f32 vectors
Element-wise addition of two f64 vectors
Batch cosine similarity: one f32 query against many f32 vectors.
Batch cosine similarity: one f64 query against many f64 vectors.
Cosine similarity between two f32 vectors: dot(A,B) / (|A| * |B|). Returns a value in [-1.0, 1.0].
Cosine similarity between two f64 vectors.
Element-wise division of two f32 vectors
Element-wise division of two f64 vectors
Compute dot product of Query against every vector in Vecs. Returns {ok, [Score]} in input order. One NIF call for the whole batch.
Dot product of a query f32 binary against a list of f32 binaries. Binaries are little-endian IEEE 754 f32 (4 bytes per element). Avoids Erlang float-list marshalling — use with kvex f32-binary storage.
Compute dot product of Query against every f64 vector in Vecs.
Compute dot product of two f32 vectors Computes the scalar product: sum(A[i] * B[i])
Compute dot product of two f64 vectors Computes the scalar product: sum(A[i] * B[i])
-spec dot_product_topk_flat(binary(), binary(), pos_integer(), [non_neg_integer()]) -> {ok, [{float(), non_neg_integer()}]} | {error, term()}.
Dot-product scoring of selected vectors from a flat f32 binary. indices: list produced by hamming_topk_flat. Returns {ok, [{Score, Idx}]} sorted by descending score.
-spec hamming_distance_batch(binary(), [binary()]) -> {ok, [non_neg_integer()]} | {error, term()}.
Batch hamming distance between a query binary and a list of binaries. Returns {ok, [Distance]} where lower distance means more similar. Uses u64 POPCNT for speed. Intended for the first phase of two-phase ANN search: hamming_distance_batch → filter top-N → dot_product_batch.
-spec hamming_topk_flat(binary(), binary(), pos_integer(), pos_integer()) -> {ok, [non_neg_integer()]} | {error, term()}.
Hamming top-K from a flat binary buffer (all vectors concatenated). Returns {ok, [Idx]} — the indices of the top_k closest vectors, sorted ascending by Hamming distance. O(N) partition + O(K log K) sort, no per-element Erlang overhead.
L2 (Euclidean) norm of an f32 vector
L2 (Euclidean) norm of an f64 vector
L2-normalize a batch of f32 vectors.
L2-normalize a batch of f64 vectors.
L2-normalize an f32 vector to unit length. Returns the original vector if its norm is zero.
L2-normalize an f64 vector to unit length.
Element-wise maximum of two f32 vectors
Element-wise maximum of two f64 vectors
Find maximum value in an f32 vector
Find maximum value in an f64 vector
Compute arithmetic mean of an f32 vector
Compute arithmetic mean of an f64 vector
Element-wise minimum of two f32 vectors
Element-wise minimum of two f64 vectors
Find minimum value in an f32 vector
Find minimum value in an f64 vector
Element-wise multiplication of two f32 vectors
Element-wise multiplication of two f64 vectors
Negate an f32 vector (multiply by -1)
Negate an f64 vector (multiply by -1)
Compute square root of an f32 vector
Compute square root of an f64 vector
Compute standard deviation of an f32 vector
Compute standard deviation of an f64 vector
Element-wise subtraction of two f32 vectors
Element-wise subtraction of two f64 vectors
Compute sum of all elements in an f32 vector
Compute sum of all elements in an f64 vector
1-bit quantize an f32 vector. Each element becomes 1 if above mean, else 0. Returns a packed binary: 128 dims → 16 bytes. Use hamming_distance_batch/2 to search over quantized vectors.
Like to_binary_f32/1 but accepts a little-endian f32 binary instead of a float list. Zero-copy path when the vector is already stored as a binary (e.g. in kvex ETS).
Compute variance of an f32 vector
Compute variance of an f64 vector