.TH "ttypt/sepal.h" 3 "sepal" \" -*- nroff -*- .ad l .nh .SH NAME ttypt/sepal.h \- libsepal — the meaning (semantic) axis\&. .SH SYNOPSIS .br .PP \fR#include \fP .br \fR#include \fP .br \fR#include \fP .br .SS "Data Structures" .in +1c .ti -1c .RI "struct \fBsepal_hit\fP" .br .ti -1c .RI "struct \fBsepal_rank_ctx\fP" .br .in -1c .SS "Macros" .in +1c .ti -1c .RI "#define \fBSEPAL_VEC_MAX\fP 2048" .br .ti -1c .RI "#define \fBSEPAL_EXACT_DIM\fP 256" .br .ti -1c .RI "#define \fBSEPAL_M_DEFAULT\fP 10" .br .in -1c .SS "Typedefs" .in +1c .ti -1c .RI "typedef struct sepal_vecstore \fBsepal_vecstore_t\fP" .br .ti -1c .RI "typedef struct \fBsepal_hit\fP \fBsepal_hit_t\fP" .br .in -1c .SS "Functions" .in +1c .ti -1c .RI "int \fBsepal_put\fP (\fBsepal_vecstore_t\fP *vs, rec_ref_t ref, const float *v, size_t full_dim)" .br .ti -1c .RI "int \fBsepal_del\fP (\fBsepal_vecstore_t\fP *vs, rec_ref_t ref)" .br .ti -1c .RI "size_t \fBsepal_get\fP (\fBsepal_vecstore_t\fP *vs, rec_ref_t ref, float *out, size_t max)" .br .ti -1c .RI "size_t \fBsepal_dim\fP (\fBsepal_vecstore_t\fP *vs, rec_ref_t ref)" .br .ti -1c .RI "size_t \fBsepal_full_dim\fP (\fBsepal_vecstore_t\fP *vs, rec_ref_t ref)" .br .ti -1c .RI "size_t \fBsepal_n\fP (const \fBsepal_vecstore_t\fP *vs)" .br .ti -1c .RI "int \fBsepal_index_validate\fP (const \fBsepal_vecstore_t\fP *vs)" .br .ti -1c .RI "float \fBsepal_cosine\fP (const float *a, const float *b, size_t n)" .br .ti -1c .RI "int \fBsepal_sketch\fP (const float *v, size_t n, uint64_t *words, size_t nwords)" .br .ti -1c .RI "int \fBsepal_fill_approx\fP (\fBsepal_vecstore_t\fP *vs, const float *q, size_t qdim, size_t m, float min_sim, rec_set_t *out)" .br .ti -1c .RI "int \fBsepal_rank\fP (struct \fBsepal_rank_ctx\fP *ctx, rec_ref_t ref, float *score)" .br .ti -1c .RI "size_t \fBsepal_blob_len\fP (const uint8_t *blob, size_t avail)" .br .ti -1c .RI "int \fBsepal_blob_hdr\fP (const uint8_t *blob, size_t avail, sepal_blob_hdr_t *hdr)" .br .ti -1c .RI "size_t \fBsepal_blob_put\fP (uint8_t *buf, size_t avail, const float *v, size_t full_dim, size_t dim)" .br .in -1c .SH "Detailed Description" .PP libsepal — the meaning (semantic) axis\&. A dim-tagged vector store with a two-stage ANN pipeline: Hamming prefilter over a sign-bit sketch (top-m) followed by exact cosine rerank (top-k)\&. Built on the corm persistent map and the recall kernel (rec\&.h)\&. Follows the same standard as libjoint / libislet / liblemma (mk stack, ttypt headers)\&. .PP DESIGN CONTRACT .IP "\(bu" 2 Refs are caller-opaque rec_ref_t (u32): the caller passes them at put time and owns ref<->schema mapping\&. The store never maps refs\&. .IP "\(bu" 2 Per-blob dims: every vector stores its own exact-stage dim (the "matryoshka" prefix) = min(full_dim, SEPAL_EXACT_DIM)\&. Vectors already <= SEPAL_EXACT_DIM dims are stored untruncated\&. .IP "\(bu" 2 sepal_get NEVER truncates: asking for more dims than stored is fine (returns the stored count); asking for fewer returns 0 (mismatch)\&. .IP "\(bu" 2 Search is pure two-stage ANN\&. Exact brute force is the test-side reference and is NOT provided by the library (exactness is a kernel property, not a sepal feature)\&. .PP .SH "Macro Definition Documentation" .PP .SS "#define SEPAL_EXACT_DIM 256" Matryoshka default: exact-stage dim cap (per-blob dim, not store config)\&. .SS "#define SEPAL_M_DEFAULT 10" m knob default: 10x k when m==0 (capped at the store size)\&. .SS "#define SEPAL_VEC_MAX 2048" Max full dimensionality accepted at put (any dim is truncated to this)\&. .SH "Typedef Documentation" .PP .SS "typedef struct \fBsepal_hit\fP \fBsepal_hit_t\fP" A search hit: (ref, cosine score)\&. .SS "typedef struct sepal_vecstore \fBsepal_vecstore_t\fP" Opaque vector store handle (corm-backed; memory-only when opened NULL)\&. .SH "Function Documentation" .PP .SS "int sepal_blob_hdr (const uint8_t * blob, size_t avail, sepal_blob_hdr_t * hdr)" Parse the VEC1 header; 0 ok, -1 invalid/truncated\&. .SS "size_t sepal_blob_len (const uint8_t * blob, size_t avail)" Byte length of a valid VEC1 blob; 0 when invalid (bad magic/version, inconsistent fields) or truncated (declared length > avail)\&. .SS "size_t sepal_blob_put (uint8_t * buf, size_t avail, const float * v, size_t full_dim, size_t dim)" Encode a vector as a VEC1 blob (sketch over full_dim, norm of the truncated prefix dim = min(full_dim, SEPAL_EXACT_DIM))\&. Writes at most avail bytes; returns the byte length written, or 0 on error (bad dims or avail too small)\&. dim must be <= SEPAL_EXACT_DIM and <= full_dim\&. .SS "float sepal_cosine (const float * a, const float * b, size_t n)" Column-normalized cosine similarity (mm_cosine semantics); 0 when either vector has zero norm\&. .SS "int sepal_del (\fBsepal_vecstore_t\fP * vs, rec_ref_t ref)" Delete a ref; 0 if present, -1 if absent\&. .SS "size_t sepal_dim (\fBsepal_vecstore_t\fP * vs, rec_ref_t ref)" Stored exact-stage dim of ref (0 if absent)\&. .SS "int sepal_fill_approx (\fBsepal_vecstore_t\fP * vs, const float * q, size_t qdim, size_t m, float min_sim, rec_set_t * out)" Approximate set fill (kernel form): streams the top-m Hamming refs into out, seals it, then declares it approximate via rec_set_set_approx() with owed bound = (m >= n ? 1\&.0 : (float)m / n) — the oversampling heuristic (caller may override after the call; the setter exists)\&. Additive: on entry out may already hold refs (result is their union, sealed)\&. 0 on success; -1 on NULL args / bad dims\&. .SS "size_t sepal_full_dim (\fBsepal_vecstore_t\fP * vs, rec_ref_t ref)" Full (sketch) dim of ref (0 if absent)\&. .SS "size_t sepal_get (\fBsepal_vecstore_t\fP * vs, rec_ref_t ref, float * out, size_t max)" Copy the stored exact-dim floats into out (space for >= dim)\&. Returns the stored exact dim (>0)\&. Returns 0 on missing ref, or when max < stored dim (mismatch — never truncates, per the design contract)\&. .SS "int sepal_index_validate (const \fBsepal_vecstore_t\fP * vs)" Consistency check of the internal search index (T2): 0 when the flat sketch table, its refs, and the store's count agree; nonzero otherwise\&. NULL store is valid (returns 0)\&. Cheap; meant for tests and diagnostics\&. .SS "size_t sepal_n (const \fBsepal_vecstore_t\fP * vs)" Number of vectors in the store\&. .SS "int sepal_put (\fBsepal_vecstore_t\fP * vs, rec_ref_t ref, const float * v, size_t full_dim)" Store vector v (full_dim floats); dim stored = min(full_dim, SEPAL_EXACT_DIM)\&. full_dim must be in [1, SEPAL_VEC_MAX]; -1 on error\&. Re-putting a ref replaces its blob\&. .SS "int sepal_rank (struct \fBsepal_rank_ctx\fP * ctx, rec_ref_t ref, float * score)" Exact cosine rerank of one ref\&. 0 on success (score written, >= min_sim); nonzero when ref is missing, dims mismatch, or score < min_sim (score is left untouched on failure)\&. .SS "int sepal_sketch (const float * v, size_t n, uint64_t * words, size_t nwords)" Sign-bit sketch: nwords must be >= ceil(n/64) (else -1)\&. words[w] bit b is the sign bit (IEEE bit 31) of v[w*64 + b], for dims w*64+b < n; the bits past n in the last word are zeroed\&. Returns 0 on success\&. .SH "Author" .PP Generated automatically by Doxygen for sepal from the source code\&.