aboutsummaryrefslogtreecommitdiff
path: root/liblangdet/generic.c
blob: 729c6108b261fb4141d39c9a4b44e5dd7bd2e89b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
 * Architecture-generic hot kernels / non-SIMD fallback.
 */

#include "impl.h"

float dot_f32_generic(const float *a, const float *b, int n) {
    float sum = 0.0f;
    for (int i = 0; i < n; i++)
        sum += a[i] * b[i];
    return sum;
}

void vec_scale_inplace_generic(float *dst, float scale, int n) {
    for (int i = 0; i < n; i++)
        dst[i] *= scale;
}

void vec_axpy_inplace_generic(float *dst, const float *src, float alpha, int n) {
    for (int i = 0; i < n; i++)
        dst[i] += alpha * src[i];
}

void vec_scale_add_generic(float *dst, const float *src, float correction, int n) {
    for (int i = 0; i < n; i++)
        dst[i] = dst[i] * correction + src[i];
}