def VU_vfrdB(a, rng): N_len = int(a.length) ca = a.otherEmpty.fill(0.0) fftType = {'cvview_d': 'ccfftip_d', 'cvview_f': 'ccfftip_f'}[ca.type] fft = pv.FFT(fftType, N_len, 1, pv.VSIP_FFT_FWD, 0, 0) ra = ca.realview ia = ca.imagview ta = a.cloneview s = ta.stride pv.copy(a, ra) fft.dft(ca) pv.cmagsq(ca, ra) maxv = ra.maxval minv = maxv * rng pv.clip(ra, minv, maxv, minv, maxv, ra) Nlen = int(N_len / 2) if N_len % 2: ta.putlength(Nlen + 1) ra.putlength(Nlen + 1) ta.putoffset(Nlen * s) pv.copy(ra, ta) ra.putlength(Nlen) ta.putlength(Nlen) ta.putoffset(a.offset) ra.putoffset(Nlen + 1) pv.copy(ra, ta) else: pv.copy(ra, ta) ta.putlength(Nlen) a.putlength(Nlen) ta.putoffset(Nlen * s) pv.swap(ta, a) a.putlength(N_len) a.log10 a *= 10.0
def VU_vfrdB(a,rng): N_len=int(a.length) ca=a.otherEmpty.fill(0.0) fftType={'cvview_d':'ccfftip_d','cvview_f':'ccfftip_f'}[ca.type] fft = pv.FFT(fftType,N_len,1,pv.VSIP_FFT_FWD,0,0) ra = ca.realview ia = ca.imagview ta = a.cloneview s = ta.stride pv.copy(a,ra) fft.dft(ca) pv.cmagsq(ca,ra) maxv = ra.maxval minv = maxv * rng pv.clip(ra,minv,maxv,minv,maxv,ra) Nlen = int(N_len/2) if N_len%2: ta.putlength(Nlen+1) ra.putlength(Nlen+1) ta.putoffset(Nlen * s) pv.copy(ra,ta) ra.putlength(Nlen) ta.putlength(Nlen) ta.putoffset(a.offset) ra.putoffset(Nlen+1) pv.copy(ra,ta) else : pv.copy(ra,ta) ta.putlength(Nlen) a.putlength(Nlen) ta.putoffset(Nlen * s) pv.swap(ta,a) a.putlength(N_len) a.log10 a *= 10.0
def bidiag(B): x=B.colview(0) m=B.collength;n=B.rowlength assert m >= n,'For bidiag the input matrix must have a collength >= rowlength' v=x.empty.fill(0.0) for i in range(n-1): x=B.colview(i)[i:] v=v.block.bind(0,1,x.length) pv.copy(x,v) houseVector(v) z = v[0]; re = z.real; im = z.imag; z = re*re + im*im if z > 0.0: re /= z; im = -im/z if im == 0.0: z=re else: z=complex(re,im) v *= z; houseProd(v,B[i:,i:]); pv.copy(v[1:],x[1:]) if(i < n-2): j = i+1; v.putlength(n-j) x=B.rowview(i)[j:] pv.copy(x,v) houseVector(v); v.conj z = v[0]; re = z.real; im = z.imag; z = re*re + im*im if z > 0.0: re /= z; im = -im/z if im == 0.0: z=re else: z=complex(re,im) v[:] *= z; prodHouse(B[i:,j:],v); pv.copy(v[1:],x[1:]) if(m > n): i=n-1 x=B.colview(i)[i:] v=v.block.bind(0,1,x.length) pv.copy(x,v) houseVector(v) z = v[0]; re = z.real; im = z.imag; z = re*re + im*im if z > 0.0: re /= z; im = -im/z if im == 0.0: z=re else: z=complex(re,im) v[:] *= z; houseProd(v,B[i:,i:]); pv.copy(v[1:],x[1:]) return B