MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / sem_target_init_from_src

Function sem_target_init_from_src

src/semantic/semantic.c:832–845  ·  view source on GitHub ↗

Inline helper: initialize a target vector from a sparse/dense source. */

Source from the content-addressed store, hash-verified

830
831/* Inline helper: initialize a target vector from a sparse/dense source. */
832static inline void sem_target_init_from_src(cbm_sem_vec_t *dst, const cbm_sem_src_entry_t *src) {
833 memset(dst, 0, sizeof(*dst));
834 if (src->is_sparse) {
835 for (int k = 0; k < src->nnz; k++) {
836 dst->v[src->indices[k]] = src->values[k];
837 }
838 } else {
839 const int8_t *s = src->dense_int8;
840 const float inv127 = CBM_SEM_UNIT_POS / CBM_SEM_INT8_MAX;
841 for (int d = 0; d < CBM_SEM_DIM; d++) {
842 dst->v[d] = inv127 * (float)s[d];
843 }
844 }
845}
846
847/* Inline helper: add weighted source into target.
848 * Sparse path: ~8 operations, ~48 bytes source memory traffic.

Callers 1

cooccur_worker_sparseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected