Mercurial > hg > constant-q-cpp
comparison 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 |
comparison
equal
deleted
inserted
replaced
5:6b59109469c4 | 6:3caae61fa53f |
---|---|
5 bf = load may.vector.blockfuncs; | 5 bf = load may.vector.blockfuncs; |
6 complex = load may.complex; | 6 complex = load may.complex; |
7 window = load may.signal.window; | 7 window = load may.signal.window; |
8 fft = load may.transform.fft; | 8 fft = load may.transform.fft; |
9 pl = load may.plot; | 9 pl = load may.plot; |
10 complexmatrix = load may.matrix.complex; | 10 cm = load may.matrix.complex; |
11 | 11 |
12 { pow, round, floor, ceil, nextPowerOfTwo } = load may.mathmisc; | 12 { pow, round, floor, ceil, nextPowerOfTwo } = load may.mathmisc; |
13 | 13 |
14 fs = 48000; | 14 fs = 48000; |
15 | 15 |
80 | 80 |
81 shift = atomOffset + ((i-1) * atomHop); | 81 shift = atomOffset + ((i-1) * atomHop); |
82 | 82 |
83 println "shift = \(shift)"; | 83 println "shift = \(shift)"; |
84 | 84 |
85 shiftedReals = vec.concat [vec.zeros shift, reals]; | |
86 shiftedImags = vec.concat [vec.zeros shift, imags]; | |
87 | |
88 // println "shiftedReals = \(vec.list shiftedReals)"; | |
89 // println "shiftedImags = \(vec.list shiftedImags)"; | |
90 | |
85 specKernel = fftFunc | 91 specKernel = fftFunc |
86 (complex.complexArray | 92 (complex.complexArray |
87 (vec.concat [vec.zeros shift, reals]) | 93 (vec.concat [vec.zeros shift, reals]) |
88 (vec.concat [vec.zeros shift, imags])); | 94 (vec.concat [vec.zeros shift, imags])); |
89 | 95 |
90 map do c: | 96 map do c: |
91 if complex.magnitude c < thresh then complex.zero | 97 if complex.magnitude c < thresh then complex.zero else c fi |
92 else complex.scale (1/fftLen) c fi | |
93 done specKernel; | 98 done specKernel; |
94 | 99 |
95 done [1..winNr]; | 100 done [1..winNr]; |
96 | 101 |
97 done [1..bins]; | 102 done [1..bins]; |
98 | 103 |
99 kmat = complexmatrix.newComplexMatrix (ColumnMajor()) (concat kernels); // or row major? | 104 kmat = cm.toSparse |
100 println "density = \(complexmatrix.density kmat)"; | 105 (cm.scaled (1/fftLen) |
101 complexmatrix.toSparse kmat; | 106 (cm.newComplexMatrix (ColumnMajor()) (concat kernels))); // or row major? |
107 | |
108 println "density = \(cm.density kmat)"; | |
109 | |
110 kmat; | |
102 | 111 |
103 | 112 |
104 | 113 |