Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Selwyn Simsek
gsll
Commits
0c6a73da
Commit
0c6a73da
authored
Nov 30, 2009
by
Liam M. Healy
Browse files
Merge branch 'master' of
ssh://repo.or.cz/srv/git/gsll
parents
0912e504
976eac7b
Changes
3
Hide whitespace changes
Inline
Sidebyside
documentation/index.html
View file @
0c6a73da
...
...
@@ 407,6 +407,19 @@ GSL doesn't have them.
<li><code>
invertmatrix
</code>
finds the inverse of a matrix and uses
GSL's LU decomposition functions.
</li>
<li>
IEEE floating point number analysis.
</li>
<li><code>
fftfrequencyvector
</code>
returns a vector where the sample
frequencies are contained. If you perform an FFT on a vector of a given size
and :samplesize, this vector will contain the sample frequencies in order.
If the :shifted keyword is T, then the frequencies are ordered in ascending
order.
</li>
<li><code>
fftshift
</code>
returns a copy of a vector where the zero
frequency has been shifted to the center; the frequency components will be
sorted according to their frequency, in ascending order. Optionally, a
:stride can be provided.
</li>
<li><code>
fftinverseshift
</code>
performs the inverse action of fftshift;
the zero and positive frequency components are shifted to the beginning,
so that the resulting vector is suitable for an inverse FFT. Optionally, a
:stride can be provided.
</li>
</ul>
<h2>
Status
</h2>
...
...
fastfouriertransforms/extras.lisp
0 → 100644
View file @
0c6a73da
;; Extras for FFT.
;; Sumant Oemrawsingh, Wed Nov 25 2009  22:03
(
inpackage
:gsll
)
(
defun
fftfrequencystep
(
size
&optional
(
samplespacing
1
))
"Return the frequency step for the FFT of a vector with the given size and
assuming the given sample spacing."
(
/
(
*
size
samplespacing
)))
(
defun
ffthighestfrequency
(
size
&optional
(
samplespacing
1
))
"Return the highest frequency for the FFT of a vector with the given size and
assuming the given sample spacing."
(
if
(
evenp
size
)
(
values
(
/
samplespacing
2
)
(
/
size
2
))
(

(
/
samplespacing
2
)
(
/
(
fftfrequencystep
size
samplespacing
)
2
))))
(
defun
fftfrequencysplit
(
size
)
"Return the index where the highest frequency component is located in a
vector of the given size, after applying an FFT. The second value that is
returned, is the most negative frequency divided by the sample frequency
step."
(
if
(
evenp
size
)
(
let
((
n
(
/
size
2
)))
(
values
n
(

1
n
)))
(
let
((
n
(
/
(

size
1
)
2
)))
(
values
n
(

n
)))))
(
export
'fftfrequencyvector
)
(
defun
fftfrequencyvector
(
elementtype
size
&key
(
samplespacing
1
)
shifted
)
"Make and return a vector that contains the sample frequencies of an FFT
that has been applied to a vector with the given size and :samplespacing.
If :shifted is T, then the vector will contain the sample frequencies after
FFTSHIFT has been applied to the result of an FFT."
(
let*
((
df
(
fftfrequencystep
size
samplespacing
))
posf
negf
)
(
multiplevaluebind
(
maxfindex
minfindex
)
(
fftfrequencysplit
size
)
(
setf
posf
(
loop
for
i
from
0
to
maxfindex
collect
(
coerce
(
*
i
df
)
elementtype
))
negf
(
loop
for
i
from
minfindex
below
0
collect
(
coerce
(
*
i
df
)
elementtype
)))
(
makemarray
elementtype
:initialcontents
(
if
shifted
(
nconc
negf
posf
)
(
nconc
posf
negf
))))))
(
export
'fftshift
)
(
defun
fftshift
(
vector
&key
(
stride
1
))
"Return a copy of a vector that is the result of an FFT, with the zero and
positive frequencies shifted to the center and end, so that the data is
suitable for e.g. plotting."
(
let*
((
size
(
size
vector
))
(
n
(
floor
size
stride
))
(
shifted
(
copy
vector
))
(
split
(
fftfrequencysplit
n
))
(
zeropos
(
if
(
evenp
n
)
(

split
1
)
split
)))
;; Positive frequencies
(
loop
for
i
from
zeropos
to
(

n
1
)
do
(
setf
(
maref
shifted
(
*
i
stride
))
(
maref
vector
(
*
(

i
zeropos
)
stride
))))
;; Negative frequencies
(
loop
for
i
from
(
+
split
1
)
to
(

n
1
)
do
(
setf
(
maref
shifted
(
*
(

i
split
1
)
stride
))
(
maref
vector
(
*
i
stride
))))
shifted
))
(
export
'fftinverseshift
)
(
defun
fftinverseshift
(
vector
&key
(
stride
1
))
"Return a copy of a vector where the zero and positive frequency components
are shifted to the beginning, i.e. ordered so that it is suitable for an
inverse FFT."
(
let*
((
size
(
size
vector
))
(
n
(
floor
size
stride
))
(
invshifted
(
copy
vector
))
(
split
(
fftfrequencysplit
n
))
(
zeropos
(
if
(
evenp
n
)
(

split
1
)
split
)))
;; Positive frequencies
(
loop
for
i
from
zeropos
to
(

n
1
)
do
(
setf
(
maref
invshifted
(
*
(

i
zeropos
)
stride
))
(
maref
vector
(
*
i
stride
))))
;; Negative frequencies
(
loop
for
i
from
(
+
split
1
)
to
(

n
1
)
do
(
setf
(
maref
invshifted
(
*
i
stride
))
(
maref
vector
(
*
(

i
split
1
)
stride
))))
invshifted
))
gsll.asd
View file @
0c6a73da
...
...
@@ 143,6 +143,7 @@
(
:file
"selectdirection"
)
(
:file
"unpack"
)
(
:file
"discrete"
)
(
:file
"extras"
)
(
:file
"example"
)))
(
:module
random
:dependson
(
init
data
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment