Mercurial > hg > constant-q-cpp
diff yeti/cqtkernel.yeti @ 6:3caae61fa53f
Sparse etc
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Fri, 25 Oct 2013 11:53:28 +0100 |
parents | 6b59109469c4 |
children | 3cbf89635f34 |
line wrap: on
line diff
--- 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; + +