@SnoopJeDi/

VigilantForthrightPackage

Python

No description

fork
loading
Files
  • main.py
main.py
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
28
29
import numpy as np

def f0(A, x, tl):
    b = min(tl, A.shape[0])
    return A[0:b].dot(x[tl:tl-b:-1])

def f1(A, x, tl):
    """
    Assumptions:
      A is a kernel, shape (Nconv, Npoints)
      x is data, shape (Npoints)
      tl is an integral limit of some sort?
      b is a window width?
    """
    b = min(tl, A.shape[-1])
    xclipped = x[tl:tl-b:-1]
    return (A*xclipped).sum(axis=1)

np.random.seed(0);
B = np.random.random((13, 100))
x = np.random.random(1000)
t = 500
print(f0(B[0], x, t))
old = np.fromiter( ( f0(B[i], x, t) for i in range(B.shape[0])), float )
new = f1(B, x, t)

print(f'old=\n\t{old}\nnew=\n\t{new}\n')
print(f'All entries are close: {np.isclose(old, new).all()}')
print(f'new-old:\n\t{new-old}')