diff options
| author | Onur Gündüz <ogunduz@gmail.com> | 2026-06-20 20:10:56 +0200 |
|---|---|---|
| committer | Onur Gündüz <ogunduz@gmail.com> | 2026-06-21 05:57:19 +0200 |
| commit | 6b969d25ce136eaf695222bd1a10bff1ecac0220 (patch) | |
| tree | c23afb50c28b9deaddae5c6526a74ee11cf2d865 /src/vec.c | |
| parent | d4bdb8dae753462f621507d5fc3582e0e53da35c (diff) | |
| download | ffwd-6b969d25ce136eaf695222bd1a10bff1ecac0220.tar.gz ffwd-6b969d25ce136eaf695222bd1a10bff1ecac0220.zip | |
all: split Makefile and reorg library/tools
Diffstat (limited to '')
| -rw-r--r-- | libffwd/vec.c (renamed from src/vec.c) | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/vec.c b/libffwd/vec.c index cea1576..f848be0 100644 --- a/src/vec.c +++ b/libffwd/vec.c @@ -1,4 +1,4 @@ -#include "embed.h" +#include "ffwd.h" #include <math.h> @@ -10,7 +10,7 @@ * similarity. They touch no model or tensor internals, only the public API. * ======================================================================== */ -int embed_l2_normalize(float *vec, int dim) { +int ffwd_l2_normalize(float *vec, int dim) { if (!vec || dim <= 0) return -1; @@ -27,7 +27,7 @@ int embed_l2_normalize(float *vec, int dim) { return 0; } -float embed_cosine_similarity(const float *a, const float *b, int dim) { +float ffwd_cosine_similarity(const float *a, const float *b, int dim) { if (!a || !b || dim <= 0) return 0.0f; @@ -42,8 +42,8 @@ float embed_cosine_similarity(const float *a, const float *b, int dim) { norm_b_sq += bv * bv; } - if (!(norm_a_sq > 0.0f) || !(norm_b_sq > 0.0f) || !isfinite(norm_a_sq) || - !isfinite(norm_b_sq) || !isfinite(dot)) + if (!(norm_a_sq > 0.0f) || !(norm_b_sq > 0.0f) || !isfinite(norm_a_sq) || !isfinite(norm_b_sq) || + !isfinite(dot)) return 0.0f; double denom = sqrt((double)norm_a_sq) * sqrt((double)norm_b_sq); |
