C · Metrics

Metrics

#include <usearch/dense_index.h>#include <usearch/geospatial_index.h>#include <usearch/sequence_index.h>#include <usearch/shapes_index.h>#include <usearch/types.h> 3.0.0-rc.1 · 4c3e5023

§ Dense Indexes

A dense index holds fixed-width vectors under one metric, with the dimensions, quantization, connectivity and values_per_key its constructor froze.

API

Types

usearch_dense_index_tVector Search Index over equidimensional dense representations.
dense_index.h:187 ↗
typedef struct usearch_dense_index_handle_t * usearch_dense_index_t;

See also

usearch_dense_metric_tThe dense metric kinds supported out of the box, with SIMD kernels dispatched by the machine's capabilities.
dense_index.h:224 ↗
enum usearch_dense_metric_t

The last two read their vectors as usearch_scalar_u1x8_k bit sets and refuse any other quantization; the first four refuse that one.

Values

usearch_dense_metric_unknown_k0No kind named - an unset field, refused by every constructor.
usearch_dense_metric_inner_k1Sum of elementwise products, unnormalized and scale-sensitive; the only kind the linear-algebra verbs accept, since a product and a softmax both need logits rather than distances.
usearch_dense_metric_angular_k2Cosine distance in [0, 2], zero for identical directions and blind to magnitude, which is precomputed once per vector at insertion rather than per comparison.
usearch_dense_metric_euclidean_k3L2 distance, non-negative and zero only for identical vectors - the scale-sensitive counterpart to angular, where a doubled vector is far from its original rather than identical to it.
usearch_dense_metric_hamming_k4Count of differing bits, so its range is the dimensionality and every bit weighs the same.
usearch_dense_metric_jaccard_k5Differing bits over union bits in [0, 1], ignoring the zeros both vectors share - the kind for sparse sets, where Hamming would call two nearly-empty vectors identical.

Spellings

char const * usearch_dense_metric_name(usearch_dense_metric_t metric);
usearch_dense_metric_t usearch_dense_metric_from_name(
    usearch_bytes_view_t name);
usearch_geospatial_index_tSimilarity Search Index over observations in space & time.
geospatial_index.h:88 ↗
typedef struct usearch_geospatial_index_handle_t * usearch_geospatial_index_t;
usearch_sequence_index_tSimilarity Search Index over variable-length sequences.
sequence_index.h:69 ↗
typedef struct usearch_sequence_index_handle_t * usearch_sequence_index_t;

See also

usearch_sequence_metric_tThe sequence scoring kinds supported out of the box.
sequence_index.h:96 ↗
enum usearch_sequence_metric_t

The edit kinds fill a [|a|+1,|b|+1] table of cell D[i,j], the least cost of turning the prefix of a ending at i into the prefix of b ending at j, carrying one row, so each is quadratic in time. They write c for the substitution cost and g for the gap cost.

Values

usearch_sequence_metric_unknown_k0
usearch_sequence_metric_levenshtein_bytes_k1Levenshtein edit distance over raw bytes.
usearch_sequence_metric_levenshtein_utf8_k2Levenshtein edit distance over UTF-8 code points.
usearch_sequence_metric_needleman_wunsch_k3Global alignment with linear gap costs - Needleman-Wunsch.
usearch_sequence_metric_overlap_k4Window overlap: the share of the larger window set the other side misses.

Spellings

char const * usearch_sequence_metric_name(
    usearch_sequence_metric_t metric);
usearch_sequence_metric_t usearch_sequence_metric_from_name(
    usearch_bytes_view_t name);
usearch_sequence_weights_tThe substitution matrix and gap costs an alignment kind scores with; the Levenshtein kinds score with unit costs and take none.
sequence_index.h:187 ↗
struct usearch_sequence_weights_t

Needleman-Wunsch reads the matrix as similarities s between class codes, the classes ending at the last code scoring anything, at most 32 of them, and its sequences as those codes packed two bits apiece up to four classes and five past, little-endian behind one byte counting the slots the last bytes leave unused. It scores with c(a,b) = (s(a,a) + s(b,b)) / 2 − s(a,b), costs that must not be negative, rounded to integers of at most 15 together with the gap cost, all scaled down by one factor when either passes it.

Fields

substitution_matrixint8_t const *Row-major 256×256 signed scores over byte alphabets.
gapint8_tCost of one unaligned symbol.
usearch_shapes_index_tSimilarity Search Index over 3D point clouds of varying size.
shapes_index.h:116 ↗
typedef struct usearch_shapes_index_handle_t * usearch_shapes_index_t;

See also

usearch_shapes_metric_tHow two shapes compare, with no correspondence between their points.
shapes_index.h:145 ↗
enum usearch_shapes_metric_t

Writes d for the distance between two points, S for one of the eight sign flips diag(±1,±1,±1), and P for a transport plan: a non-negative [|A|,|B|] matrix whose rows sum to 1/|A| and columns to 1/|B|. Both shapes are taken as already centred and turned onto their principal axes, as the index stores them. Scoring Kinds

Values

usearch_shapes_metric_unknown_k0
usearch_shapes_metric_chamfer_k1Mean distance to each point's nearest partner, both directions, halved.
usearch_shapes_metric_hausdorff_k2The worst of all nearest-partner distances, both directions.
usearch_shapes_metric_gromov_wasserstein_k3Transport over each side's internal geometry - the best ranker, and the costliest.
usearch_shapes_metric_wasserstein_procrustes_k4Residual after the best rigid motion and the best matching - Wasserstein-Procrustes.

Spellings

char const * usearch_shapes_metric_name(usearch_shapes_metric_t metric);
usearch_shapes_metric_t usearch_shapes_metric_from_name(
    usearch_bytes_view_t name);
usearch_distance_tDistance or similarity score between two entries, in the metric of the index that produced it.
types.h:152 ↗
typedef double usearch_distance_t;

Wide enough for every modality's scoring range.