Home
last modified time | relevance | path

Searched refs:np (Results 1 – 25 of 66) sorted by relevance

123

/cmsis-dsp-latest/PythonWrapper/examples/
Dtestdsp.py2 import numpy as np namespace
7 r = dsp.arm_add_f32(np.array([1.,2,3]),np.array([4.,5,7]))
41 r = dsp.arm_negate_q7(np.array([0x80,0x81,0x82]))
86 return(np.int32(0x7FFFFFFF))
88 return(np.int32(0x80000000))
90 return(np.int32(x))
92 q31satV=np.vectorize(q31sat)
95 return(q31satV(np.round(x * (1<<31))))
99 return(np.int16(0x7FFF))
101 return(np.int16(0x8000))
[all …]
Dtestdsp5.py2 import numpy as np namespace
10 ar=np.zeros(np.array(a.shape) * 2)
19 a=np.array([1.,-3.,4.,0.,-10.,8.])
46 a=np.array([1.,-3.,4.,0.5,-10.,8.])
74 a=np.zeros((12,3))
75 w=np.array([[2.0] * 12])[0]
92 scaled= np.dot(a.T , w)
94 ref=scaled/np.sum(w)
97 points = np.array(a).reshape(12*3)
111 s = np.random.randn(nb)
[all …]
Dtestdsp6.py2 import numpy as np namespace
46 x = np.arange(0, 2*np.pi+np.pi/4, np.pi/4)
47 y = np.sin(x)
48 xnew = np.arange(0, 2*np.pi+np.pi/16, np.pi/16)
68 x1 = [1.5, 1] + ballRadius * np.random.randn(NBVECS,VECDIM)
69 x2 = [-1.5, 1] + ballRadius * np.random.randn(NBVECS,VECDIM)
70 x3 = [0, -3] + ballRadius * np.random.randn(NBVECS,VECDIM)
73 X_train=np.concatenate((x1,x2,x3))
76 Y_train=np.concatenate((np.zeros(NBVECS),np.ones(NBVECS),2*np.ones(NBVECS)))
95 theta=list(np.reshape(gnb.theta_,np.size(gnb.theta_)))
[all …]
Dexample.py2 import numpy as np namespace
9 return(np.int32(0x7FFFFFFF))
11 return(np.int32(0x80000000))
13 return(np.int32(x))
15 q31satV=np.vectorize(q31sat)
18 return(q31satV(np.round(x * (1<<31))))
26 sig = np.fromfile(f, dtype=np.int16)
32 p0 = np.exp(1j*0.05) * 0.98
33 p1 = np.exp(1j*0.25) * 0.9
34 p2 = np.exp(1j*0.45) * 0.97
[all …]
Dexample_1_5.py4 import numpy as np namespace
14 v=np.hstack([[1],x[1:]])
24 v = np.zeros(len(x))
26 if np.sign(alpha) <= 0:
50 a=np.random.randn(VECDIM)
51 a = a / np.max(np.abs(a))
58 print(np.isclose(betaRef,betaF32,1e-6,1e-6))
59 print(np.isclose(vRef,vF32,1e-6,1e-6))
63 print(np.isclose(betaRef,betaF64,1e-6,1e-6))
64 print(np.isclose(vRef,vF64,1e-6,1e-6))
[all …]
Dtestdsp2.py2 import numpy as np namespace
25 ar=np.zeros(np.array(a.shape) * [1,2])
34 return(a/np.max(np.abs(a)))
37 result = np.correlate(x, x, mode='full')
42 a=np.array([1.,-3.,4.,0.,-10.,8.])
71 a=np.array([1.,-3.,4.,0.5,-10.,8.])
103 a=np.array([1.,-3.,4.,0.5,-10.,8.])
130 a=np.array([[1.,2,3,4],[5,6,7,8],[9,10,11,12]])
131 b=np.array([-2,-1,3,4])
133 c = np.dot(a,b)
[all …]
Dexample_1_11.py4 import numpy as np namespace
27 refWin1=np.array([[1, 1, 1, 0, 0],
36 [0, 0, 0, 0, 0]], dtype=np.int8)
38 dtwWindow=np.zeros((10,5),dtype=np.int8)
46 refWin2=np.array([[1, 1, 0, 0, 0],
55 [0, 0, 0, 0, 1]], dtype=np.int8)
57 dtwWindow=np.zeros((10,5),dtype=np.int8)
69 query=np.array([ 0.08387197, 0.68082274, 1.06756417, 0.88914541, 0.42513398, -0.3259053,
72 template=np.array([ 1.00000000e+00, 7.96326711e-04, -9.99998732e-01, -2.38897811e-03,
75 cols=np.array([1,2,3])
[all …]
Dexample_1_4.py4 import numpy as np namespace
29 x = np.cos(angles)
30 y = np.sin(angles)
35 ref=np.array([np.arctan2(yv,xv) for (yv,xv) in vals])/math.pi*180
39 resf32=np.array([dsp.arm_atan2_f32(yv,xv)[1] for (yv,xv) in vals])/math.pi*180
41 print(np.isclose(ref,resf32,1e-6,1e-6))
48 resq31=4*f.Q31toF32(np.array([dsp.arm_atan2_q31(yv,xv)[1] for (yv,xv) in valsQ31]))/math.pi*180
50 print(np.isclose(ref,resq31,1e-8,1e-8))
57 resq15=4*f.Q15toF32(np.array([dsp.arm_atan2_q15(yv,xv)[1] for (yv,xv) in valsQ15]))/math.pi*180
59 print(np.isclose(ref,resq15,1e-3,1e-3))
[all …]
/cmsis-dsp-latest/cmsisdsp/
Dfixedpoint.py1 import numpy as np namespace
5 return(np.int32(0x7FFFFFFF))
7 return(np.int32(0x80000000))
9 return(np.int32(x))
11 q31satV=np.vectorize(q31sat)
23 return(q31satV(np.round(np.array(x) * (1<<31))))
27 return(np.int16(0x7FFF))
29 return(np.int16(0x8000))
31 return(np.int16(x))
33 q15satV=np.vectorize(q15sat)
[all …]
Dmfcc.py1 import numpy as np namespace
14 return 1127.0 * np.log(1.0 + freq / 700.0)
26 return 700.0 * (np.exp(mels / 1127.0) - 1.0)
48 filters = np.zeros((numOfMelFilters,int(FFTSize/2+1)))
49 zeros = np.zeros(int(FFTSize // 2 ))
54 mels = np.linspace(fmin_mel, fmax_mel, num=numOfMelFilters+2)
57 linearfreqs = np.linspace( 0, fs/2.0, int(FFTSize // 2 + 1) )
72 filters[n, :] = np.hstack([0,np.maximum(zeros,np.minimum(upper,lower))])
106 result = np.zeros((numOfDctOutputs,numOfMelFilters))
107 s=(np.linspace(1,numOfMelFilters,numOfMelFilters) - 0.5)/numOfMelFilters
[all …]
Ddatatype.py2 import numpy as np namespace
35 return(f.toQ31(np.array(samples)))
37 return(f.toQ15(np.array(samples)))
39 return(f.toQ7(np.array(samples)))
41 return(np.array(samples).astype(dtype=np.float64))
43 return(np.array(samples).astype(dtype=np.float32))
45 return(np.array(samples).astype(dtype=np.float16))
/cmsis-dsp-latest/Testing/PatternGeneration/
DFastMath.py2 import numpy as np namespace
7 import numpy as np namespace
10 return(np.round(1.0*x * (1<<31)))
13 return(np.round(1.0*x * (1<<15)))
16 return(np.round(1.0*x * (1<<7)))
81 vals=np.linspace(np.float_power(2,-15),1.0,num=125)
83 vals=np.linspace(np.float_power(2,-10),1.0,num=125)
85 vals=np.linspace(np.float_power(2,-31),1.0,num=125)
88 ref=np.log(vals)
106 a1=np.array([0,math.pi/4,math.pi/2,3*math.pi/4,math.pi,5*math.pi/4,3*math.pi/2,2*math.pi-1e-6])
[all …]
DInterpolate.py2 import numpy as np namespace
12 return(np.array([[p[1],p[0]] for p in np.array(np.meshgrid(y,x)).T.reshape(-1,2)]))
18 x = np.linspace(0, NBSAMPLES, num=NBSAMPLES+1, endpoint=True)
19 y = np.cos(-x**2/(NBSAMPLES - 1))
22 data=np.hstack((data,np.array(data[-1]+1.5)))
40 x = np.arange(-3.14, 3.14, 1.0)
41 y = np.arange(-3.14, 3.14, 0.8)
42 xx, yy = np.meshgrid(x, y)
43 z = np.sin(xx**2+yy**2)
48 matrixSize=[np.size(x),np.size(y)]
[all …]
DMatrix.py2 import numpy as np namespace
17 tmp = np.copy(a[j,:])
18 a[j,:] = np.copy(a[k,:])
23 tmp = np.copy(a[:,j])
24 a[:,j] = np.copy(a[:,k])
30 ma = np.copy(src)
34 piv=np.zeros(len(ma),dtype=int)
42 d=np.diagonal(ma)
43 j = np.argmax(d[k:]) + k
50 v = np.copy(ma[k+1:,k])
[all …]
DBIQUAD.py2 import numpy as np namespace
22 samples=np.random.randn(NBSAMPLES)
23 coefs=np.random.randn(NUMSTAGES*5)
35 coefs=np.reshape(np.hstack((np.insert(sos[:,:3],1,0.0,axis=1),-sos[:,4:])),n*6)
37 coefs=np.reshape(np.hstack((sos[:,:3],-sos[:,4:])),n*5)
53 phase = np.random.rand()*2.0 * math.pi
54 z = np.exp(1j*phase)
56 phase = np.random.rand()*2.0 * math.pi
57 amplitude = np.random.rand()*0.7
58 p = np.exp(1j*phase) * amplitude
[all …]
DQR.py1 import numpy as np namespace
8 r=np.random.randn(rows)
9 r = Tools.normalize(r)[np.newaxis]
10 c=np.random.randn(cols)
11 c = Tools.normalize(c)[np.newaxis]
14 a = np.random.randn(rows,rows)
15 b = np.random.randn(cols,cols)
18 d = np.zeros((rows,cols))
20 diag = np.ones(diagDim)
22 np.fill_diagonal(d,diag)
[all …]
DStats.py5 import numpy as np namespace
21 v = np.random.rand(vecDim)
22 v = v / np.sum(v)
26 inputs = np.array(inputs)
27 outputs = np.array(outputs)
28 dims = np.array(dims)
41 v = np.random.rand(vecDim)
42 v = v / np.sum(v)
46 inputs = np.array(inputs)
47 outputs = np.array(outputs)
[all …]
DBayes.py5 import numpy as np namespace
48 v = np.random.randn(vecDim)
50 c = np.random.choice(range(0,nbClasses))
51 c0 = np.zeros(vecDim)
52 c1 = np.copy(c0)
85 params += list(np.reshape(gb.theta_,np.size(gb.theta_)))
86 params += list(np.reshape(gb.sigma_,np.size(gb.sigma_)))
87 params += list(np.reshape(gb.class_prior_,np.size(gb.class_prior_)))
123 inputs = np.array(inputs)
124 params = np.array(params)
[all …]
DSupport.py5 import numpy as np namespace
21 va = np.random.rand(DIM)
22 vb = np.random.rand(DIM)
27 e = np.sum(va[0:nbiters].T * vb[0:nbiters]) / np.sum(vb[0:nbiters])
31 e = np.sum(va[0:nbiters].T * vb[0:nbiters]) / np.sum(vb[0:nbiters])
35 e = np.sum(va[0:nbiters].T * vb[0:nbiters]) / np.sum(vb[0:nbiters])
38 inputs=np.array(inputs)
39 weights=np.array(weights)
40 output=np.array(output)
61 b = np.zeros(vecDim)
[all …]
DTransform.py2 import numpy as np namespace
18 return(a.reshape(np.size(a)).view(dtype=np.float64))
21 return(np.random.randn(nb))
26 time = np.arange(0,nb)
27 return(np.sin(2 * np.pi * f * time/nb))
34 return(np.concatenate((np.zeros(n), r*np.ones(n))))
38 ifft = np.copy(fft)
40 fft = np.array([x/2**scaling[j] for x in fft])
50 rfft=np.insert(rfft, 1, rfft[-1])
52 rifft = np.copy(rfft)
[all …]
DMFCC.py29 import numpy as np namespace
46 return 1127.0 * np.log(1.0 + freq / 700.0)
49 return 700.0 * (np.exp(mels / 1127.0) - 1.0)
53 filters = np.zeros((numOfMelFilters,int(FFTSize/2+1)))
54 zeros = np.zeros(int(FFTSize // 2 ))
59 mels = np.linspace(fmin_mel, fmax_mel, num=numOfMelFilters+2)
62 linearfreqs = np.linspace( 0, fs/2.0, int(FFTSize // 2 + 1) )
73 filters[n, :] = np.hstack([0,np.maximum(zeros,np.minimum(upper,lower))])
80 result = np.zeros((numOfDctOutputs,numOfMelFilters))
81 s=(np.linspace(1,numOfMelFilters,numOfMelFilters) - 0.5)/numOfMelFilters
[all …]
DSVM.py6 import numpy as np namespace
25 C0 = np.zeros((1,VECDIM))
26 C1 = np.copy(C0)
39 v = np.random.randn(1,VECDIM)
47 c = np.random.choice([0,1])
60 c0 = np.zeros((1,vecdim))
61 c1 = np.copy(c0)
64 v = np.random.randn(1,vecdim)
66 c = np.random.choice([0,1])
79 v = np.random.randn(1,VECDIM)
[all …]
DComplexMaths.py2 import numpy as np namespace
11 data = np.random.randn(2*nb)
13 data_comp = data.view(dtype=np.complex128)
18 return(a.reshape(np.size(a)).view(dtype=np.float64))
25 data3=np.random.randn(NBSAMPLES)
33 ref = np.conj(data1)
37 ref = np.array(np.dot(data1[0:nb],data2[0:nb]))
48 ref = np.array(np.dot(data1[0:nb] ,data2[0:nb]))
59 ref = np.array(np.dot(data1[0:nb] ,data2[0:nb]))
69 ref = np.absolute(data1)
[all …]
/cmsis-dsp-latest/Examples/ARM/arm_bayes_example/
Dtrain.py3 import numpy as np namespace
17 x1 = [1.5, 1] + ballRadius * np.random.randn(NBVECS,VECDIM)
18 x2 = [-1.5, 1] + ballRadius * np.random.randn(NBVECS,VECDIM)
19 x3 = [0, -3] + ballRadius * np.random.randn(NBVECS,VECDIM)
22 X_train=np.concatenate((x1,x2,x3))
25 Y_train=np.concatenate((np.zeros(NBVECS),np.ones(NBVECS),2*np.ones(NBVECS)))
44 print("Theta = ",list(np.reshape(gnb.theta_,np.size(gnb.theta_))))
47 print("Sigma = ",list(np.reshape(gnb.sigma_,np.size(gnb.sigma_))))
50 print("Prior = ",list(np.reshape(gnb.class_prior_,np.size(gnb.class_prior_))))
/cmsis-dsp-latest/Examples/ARM/arm_svm_example/
Dtrain.py3 import numpy as np namespace
18 x = ballRadius * np.random.randn(NBVECS,2)
21 angle = 2.0*math.pi * np.random.randn(1,NBVECS)
22 radius = 3.0+0.1*np.random.randn(1,NBVECS)
24 xa = np.zeros((NBVECS,2))
25 xa[:,0]=radius*np.cos(angle)
26 xa[:,1]=radius*np.sin(angle)
29 X_train=np.concatenate((x,xa))
33 Y_train=np.concatenate((np.zeros(NBVECS),np.ones(NBVECS)))
46 test1=np.array([0.4,0.1])
[all …]

123