Skip to content

Commit

Permalink
add fft example
Browse files Browse the repository at this point in the history
  • Loading branch information
briangu committed Dec 19, 2023
1 parent 7fe50fd commit 0c45779
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions examples/math/fft.kg
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
:" use NumPy for FFT "
.pyf("numpy";"fft")

:" Example simple signal "
signal::[0.0 1.0 0.0 -1.0]

result::.pyc([fft "fft"];,signal;:{})

:" Display the FFT result "
.d("FFT Result: ");.p(result)
10 changes: 10 additions & 0 deletions examples/math/fft.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import numpy as np

# Create a simple signal
signal = np.array([0.0, 1.0, 0.0, -1.0])

# Apply FFT to the signal
fft_result = np.fft.fft(signal)

# Display the FFT result
print("FFT Result:", fft_result)

0 comments on commit 0c45779

Please sign in to comment.