MCPcopy Create free account
hub / github.com/IQEngine/IQEngine / convolve

Function convolve

client/src/utils/fetch-more-data-source.ts:7–31  ·  view source on GitHub ↗
(array, taps)

Source from the content-addressed store, hash-verified

5import { INITIAL_PYTHON_SNIPPET } from '@/utils/constants';
6
7export function convolve(array, taps) {
8 // make sure its an odd number of taps
9 if (taps.length % 2 !== 1) taps.push(0);
10
11 let I = array.filter((element, index) => {
12 return index % 2 === 0;
13 });
14 let Q = array.filter((element, index) => {
15 return index % 2 === 1;
16 });
17
18 let offset = ~~(taps.length / 2);
19 let output = new Float32Array(array.length);
20 for (let i = 0; i < array.length / 2; i++) {
21 let kmin = i >= offset ? 0 : offset - i;
22 let kmax = i + offset < array.length / 2 ? taps.length - 1 : array.length / 2 - 1 - i + offset;
23 output[i * 2] = 0; // I
24 output[i * 2 + 1] = 0; // Q
25 for (let k = kmin; k <= kmax; k++) {
26 output[i * 2] += I[i - offset + k] * taps[k]; // I
27 output[i * 2 + 1] += Q[i - offset + k] * taps[k]; // Q
28 }
29 }
30 return output;
31}
32
33function callPyodide(pyodide, pythonSnippet, samples) {
34 console.debug('Running Python Snippet');

Callers 1

applyProcessingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected