# HG changeset patch # User Chris Cannam # Date 1382698408 -3600 # Node ID 3caae61fa53fd7cec3f56072f16ea1d6c1d71c2f # Parent 6b59109469c4fe871e36529fbbc717254deb4c26 Sparse etc diff -r 6b59109469c4 -r 3caae61fa53f yeti/cqtkernel.yeti --- a/yeti/cqtkernel.yeti Thu Oct 24 18:53:41 2013 +0100 +++ b/yeti/cqtkernel.yeti Fri Oct 25 11:53:28 2013 +0100 @@ -7,7 +7,7 @@ window = load may.signal.window; fft = load may.transform.fft; pl = load may.plot; -complexmatrix = load may.matrix.complex; +cm = load may.matrix.complex; { pow, round, floor, ceil, nextPowerOfTwo } = load may.mathmisc; @@ -82,23 +82,32 @@ println "shift = \(shift)"; + shiftedReals = vec.concat [vec.zeros shift, reals]; + shiftedImags = vec.concat [vec.zeros shift, imags]; + +// println "shiftedReals = \(vec.list shiftedReals)"; +// println "shiftedImags = \(vec.list shiftedImags)"; + specKernel = fftFunc (complex.complexArray (vec.concat [vec.zeros shift, reals]) (vec.concat [vec.zeros shift, imags])); map do c: - if complex.magnitude c < thresh then complex.zero - else complex.scale (1/fftLen) c fi + if complex.magnitude c < thresh then complex.zero else c fi done specKernel; done [1..winNr]; done [1..bins]; -kmat = complexmatrix.newComplexMatrix (ColumnMajor()) (concat kernels); // or row major? -println "density = \(complexmatrix.density kmat)"; -complexmatrix.toSparse kmat; +kmat = cm.toSparse + (cm.scaled (1/fftLen) + (cm.newComplexMatrix (ColumnMajor()) (concat kernels))); // or row major? +println "density = \(cm.density kmat)"; +kmat; + +