MCPcopy Create free account
hub / github.com/carsonpo/haystackdb / gemv

Function gemv

src/math/gemv.rs:3–13  ·  view source on GitHub ↗
(matrix: &Vec<[f32; VECTOR_SIZE]>, vector: &[f32; VECTOR_SIZE])

Source from the content-addressed store, hash-verified

1use crate::constants::VECTOR_SIZE;
2
3pub fn gemv(matrix: &Vec<[f32; VECTOR_SIZE]>, vector: &[f32; VECTOR_SIZE]) -> Vec<f32> {
4 let mut result = vec![0f32; VECTOR_SIZE];
5 for (i, row) in matrix.iter().enumerate() {
6 let mut sum = 0f32;
7 for j in 0..VECTOR_SIZE {
8 sum += row[j] * vector[j];
9 }
10 result[i] = sum;
11 }
12 result
13}

Callers 4

criterion_benchmarkFunction · 0.85
test_gemv_identityFunction · 0.85
test_gemv_zeroFunction · 0.85
test_gemv_onesFunction · 0.85

Calls

no outgoing calls

Tested by 3

test_gemv_identityFunction · 0.68
test_gemv_zeroFunction · 0.68
test_gemv_onesFunction · 0.68