def __init__(self): # length of narrow band simulated noise signal L = int(2 * rate/(sensors * spacing/speed) + nts + 1) # Kaiser window kernel to reject out of band noise kernel = window.kaiser(float, 6, 1) # Window-based FIR filter design using above kernel self.fir = fir(kernel, symmetry.none, 2*L, 2, obj_state.save, 0, alg_hint.time) # band-limited noise vectors self.noise = vsip.vector(float, 2*L) self.bl_noise = vsip.vector(float, L) # Generate white gaussian noise self.rand = vsip.random.rand(float, 7, True) # time series indices self.t = generation.ramp(float, 0.,1./rate, nts) self.t_dt = vsip.vector(float, nts) # simulated data matrix in which each row corresponds to a sensor self.data = vsip.matrix(float, sensors, nts) self.d_t = spacing/speed
# # Copyright (c) 2013 Stefan Seefeld # All rights reserved. # # This file is part of OpenVSIP. It is made available under the # license contained in the accompanying LICENSE.BSD file. from vsip import vector from vsip import matrix from vsip.selgen.generation import ramp from vsip.math.matvec import dot, prod import numpy as np from numpy import array as A v1 = ramp(float, 0, 1, 8) v2 = ramp(float, 1, 2, 8) d = dot(v1, v2) assert d == np.dot(A(v1), A(v2)) v1 = vector(array=np.arange(4, dtype=float)) m1 = matrix(array=np.arange(16, dtype=float).reshape(4,4)) m2 = matrix(array=np.arange(16, dtype=float).reshape(4,4)) # vector * matrix v3 = prod(v1, m1) assert (A(v3) == np.tensordot(A(v1), A(m1), (0, 0))).all() # matrix * vector v3 = prod(m1, v1) assert (A(v3) == np.tensordot(A(m1), A(v1), (1, 0))).all() # matrix * matrix m3 = prod(m1, m2)
# Copyright (c) 2013 Stefan Seefeld # All rights reserved. # # This file is part of OpenVSIP. It is made available under the # license contained in the accompanying LICENSE.BSD file. from vsip import vector from vsip import matrix from vsip.selgen.generation import ramp from vsip.math import elementwise as elm from vsip.signal import * from vsip.signal.fftm import * import numpy as np #from matplotlib.pyplot import * v1 = ramp(float, 0, 0.1, 1024) v1 = elm.sin(v1) m1 = matrix(float, 16, 1024) for r in range(16): m1[r,:] = ramp(float, r, 0.1, 1024) fwd_fftm = fftm(float, fwd, 16, 1024, 1., 0, 1, alg_hint.time) inv_fftm = fftm(float, inv, 16, 1024, 1./1024, 0, 1, alg_hint.time) m2 = matrix(complex, 16, 513) fwd_fftm(m1, m2) m3 = matrix(float, 16, 1024) inv_fftm(m2, m3) assert np.isclose(m1, m3).all() #plot(v1) #plot(v3)
# license contained in the accompanying LICENSE.BSD file. import numpy as np from scipy import linalg from vsip import vector, matrix from vsip import random from vsip.selgen import generation as gen from vsip.math import elementwise as elm from vsip.math import reductions as red from vsip.math.solvers import llsqsol #import matplotlib.pyplot as plt # Define 'A' to be a two-column matrix containing Y[X] and X A = matrix(float, 10, 2) X = gen.ramp(float, 0.1, 0.1, 10) A[:,0] = elm.exp(-X) A[:,1] = X c1,c2= 5.0,2.0 Y = c1*elm.exp(-X) + c2*X Z = matrix(float, 10, 1) Z[:,0] = Y + 0.05*red.maxval(Y)[0]*random.rand(float).randn(Y.length()) R = llsqsol(A, Z) c,resid,rank,sigma = linalg.lstsq(A, Z) # Compare results of llsqsol with results from linalg.lstsq assert np.isclose(R, c).all()
# # Copyright (c) 2013 Stefan Seefeld # All rights reserved. # # This file is part of OpenVSIP. It is made available under the # license contained in the accompanying LICENSE.BSD file. from vsip import vector from vsip import matrix from vsip.selgen.generation import ramp from vsip.math.matvec import dot, prod import numpy as np from numpy import array as A v1 = ramp(float, 0, 1, 8) v2 = ramp(float, 1, 2, 8) d = dot(v1, v2) assert d == np.dot(A(v1), A(v2)) v1 = vector(array=np.arange(4, dtype=float)) m1 = matrix(array=np.arange(16, dtype=float).reshape(4, 4)) m2 = matrix(array=np.arange(16, dtype=float).reshape(4, 4)) # vector * matrix v3 = prod(v1, m1) assert (A(v3) == np.tensordot(A(v1), A(m1), (0, 0))).all() # matrix * vector v3 = prod(m1, v1) assert (A(v3) == np.tensordot(A(m1), A(v1), (1, 0))).all() # matrix * matrix m3 = prod(m1, m2) assert (A(m3) == np.tensordot(A(m1), A(m2), (1, 0))).all()
# # Copyright (c) 2013 Stefan Seefeld # All rights reserved. # # This file is part of OpenVSIP. It is made available under the # license contained in the accompanying LICENSE.BSD file. from vsip import vector from vsip import matrix from vsip.selgen.generation import ramp from vsip.math import elementwise as elm from vsip.signal import * from vsip.signal.fft import * import numpy as np #from matplotlib.pyplot import * v1 = ramp(float, 0, 0.1, 1024) v1 = elm.sin(v1) fwd_fft = fft(float, fwd, 1024, 1., 1, alg_hint.time) inv_fft = fft(float, inv, 1024, 1./1024, 1, alg_hint.time) v2 = vector(complex, 513) fwd_fft(v1, v2) v3 = vector(float, 1024) inv_fft(v2, v3) assert np.isclose(v1, v3).all() #plot(v1) #plot(v3) #show()