pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/scijs/ndarray-fft/commit/e5023894b6c19f242f940db322e7fb10d6119c85

et" href="https://github.githubassets.com/assets/global-d18f184ea1a06a2c.css" /> now works for ndarrays that are powers of two, but bluestein is still… · scijs/ndarray-fft@e502389 · GitHub
Skip to content

Commit e502389

Browse files
committed
now works for ndarrays that are powers of two, but bluestein is still broken
1 parent 9541744 commit e502389

3 files changed

Lines changed: 18 additions & 5 deletions

File tree

fft.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,20 @@ function ndfft(dir, x, y) {
1818
size *= shape[i]
1919
pad = Math.max(pad, fftm.scratchMemory(shape[i]))
2020
}
21-
pad = Math.max(2 * size, pad)
2221

23-
var buffer = scratch(2 * size + pad, "double")
22+
var buffer = scratch(4 * size + pad, "double")
2423
var x1 = ndarray(buffer, shape.slice(0), stride, 0)
2524
, y1 = ndarray(buffer, shape.slice(0), stride.slice(0), size)
2625
, x2 = ndarray(buffer, shape.slice(0), stride.slice(0), 2*size)
27-
, x3 = ndarray(buffer, shape.slice(0), stride.slice(0), 3*size)
26+
, y2 = ndarray(buffer, shape.slice(0), stride.slice(0), 3*size)
2827
, tmp, n, s1, s2
28+
, scratch_ptr = 4 * size
2929

3030
//Copy into x1/y1
3131
ops.assign(x1, x)
3232
ops.assign(y1, y)
3333
for(i=d-1; i>=0; --i) {
34-
fftm(dir, size/shape[i], shape[i], buffer, x1.offset, y1.offset, x2.offset)
34+
fftm(dir, size/shape[i], shape[i], buffer, x1.offset, y1.offset, scratch_ptr)
3535
if(i === 0) {
3636
break
3737
}
@@ -49,6 +49,9 @@ function ndfft(dir, x, y) {
4949
n *= shape[j]
5050
}
5151

52+
console.log(x1.stride, y1.stride, x1.shape)
53+
console.log(x2.stride, y2.stride, y1.shape)
54+
5255
//Transpose
5356
ops.assign(x2, x1)
5457
ops.assign(y2, y1)
@@ -61,6 +64,9 @@ function ndfft(dir, x, y) {
6164
y1 = y2
6265
y2 = tmp
6366
}
67+
68+
console.log(x.stride, "<-", x1.stride, x.get(0,5), x1.get(0, 5))
69+
6470
//Copy result back into x
6571
ops.assign(x, x1)
6672
ops.assign(y, y1)

lib/fft-matrix.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ function fftBluestein(dir, nrows, ncols, buffer, x_ptr, y_ptr, scratch_ptr) {
150150
fftRadix2(1, 1, m, buffer, cft_ptr, sft_ptr)
151151

152152
//Compute scale factor
153-
if(dir === -1) {
153+
if(dir < 0) {
154154
w = 1.0 / ncols
155155
} else {
156156
w = 1.0

test/test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ require("tap").test("ndarray-fft", function(t) {
6363
}
6464
}
6565

66+
/*
6667
test_spike(1)
6768
test_spike(2)
6869
test_spike(4)
@@ -76,6 +77,12 @@ require("tap").test("ndarray-fft", function(t) {
7677
test_spike(15)
7778
test_spike(17)
7879
80+
for(var i=1; i<100; ++i) {
81+
test_random([i])
82+
}
83+
*/
84+
85+
test_random([10, 8])
7986

8087
t.end()
8188
})

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy