1 ;; functions that are somehow related to the fouriertransform
5 (def-generator (fftshift (rank type
))
7 (declare ((simple-array ,long-type
,rank
) in
)
8 (values (simple-array ,long-type
,rank
) &optional
))
9 (let ((out (make-array (array-dimensions in
)
10 :element-type
',long-type
)))
12 (1 `(destructuring-bind (x)
14 (let ((xx (floor x
2)))
16 (let ((ii (mod (+ i xx
) x
)))
19 (2 `(destructuring-bind (y x
)
21 (let ((xx (floor x
2))
23 (do-region ((j i
) (y x
))
24 (let ((ii (mod (+ i xx
) x
))
25 (jj (mod (+ j yy
) y
)))
28 (3 `(destructuring-bind (z y x
)
30 (let ((xx (floor x
2))
33 (do-region ((k j i
) (z y x
))
34 (let ((ii (mod (+ i xx
) x
))
36 (kk (mod (+ k zz
) z
)))
37 (setf (aref out k j i
)
38 (aref in kk jj ii
))))))))
42 (def-fftshift-rk-type 3 sf
)
44 (defmacro def-fftshift-functions
(ranks types
)
45 (let* ((specifics nil
)
47 (name (format-symbol "fftshift")))
48 (loop for rank in ranks do
49 (loop for type in types do
50 (let ((def-name (format-symbol "def-~a-rank-type" name
))
51 (specific-name (format-symbol "~a-~a-~a" name rank type
)))
52 (push `(,def-name
,rank
,type
) specifics
)
53 (push `((simple-array ,(get-long-type type
) ,rank
)
56 (store-new-function name
)
61 (t (error "The given type can't be handled with a generic ~a function." ',name
)))))))
63 (def-fftshift-functions (1 2 3) (cdf csf
))
66 (let* ((ls '(1 2 3 4 5 6 7 8 9))
67 (a (make-array (length ls
)
68 :element-type
'(complex single-float
)
69 :initial-contents
(mapcar
70 #'(lambda (z) (coerce z
71 '(complex single-float
)))
77 (let ((a (make-array (list 128 128 128)
78 :element-type
'(complex single-float
))))