Skip to content

Commit

Permalink
Merge pull request #26 from SciNim/ci_fix
Browse files Browse the repository at this point in the history
fix ci
  • Loading branch information
Clonkk authored Jun 30, 2021
2 parents f7fcf61 + f933ea2 commit 4d56656
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 24 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,15 @@ jobs:
run: nimble gendoc
env:
LD_LIBRARY_PATH: ${PWD}/third_party/lib
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
- name: Commit files
run: |
echo ${{ github.ref }}
git add -f docs
git commit -m "CI: Automated build push" -a | exit 0
- name: Force push to destination branch
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs
branch: gh-pages
force: true
directory: ./docs
53 changes: 32 additions & 21 deletions fftw3.nim
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,40 @@
### Examples

#### C-Binding low-level example

## .. code-block:: nim
## const N = 3
## var input: array[1..N, cdouble] = [0.0, 2.0, 6.0]
## var output: array[1..N, cdouble]
## let bufIn = cast[ptr UncheckedArray[cdouble]](add(input[0]))
## let bufOut = cast[ptr UncheckedArray[cdouble]](add(output[0]))
## let plan = fftw_plan_r2r_1d(N, bufIn, FFTW_REDFT00, FFTW_ESTIMATE)
## fftw_execute(plan)
## let expectedResult: array[1..N, cdouble] = [10.0, -6.0, 2.0]
## for i in low(output)..high(output):
## assert abs(output[i] - expectedResult[i]) < 1.0e-14
runnableExamples:
import fftw3
const N = 3
var input: array[N, cdouble] = [0.0, 2.0, 6.0]
var output: array[N, cdouble]
let bufIn = cast[ptr UncheckedArray[cdouble]](addr(input[0]))
let bufOut = cast[ptr UncheckedArray[cdouble]](addr(output[0]))
let plan = fftw_plan_r2r_1d(N, bufIn, bufOut, fftw_r2r_kind.FFTW_REDFT00, FFTW_ESTIMATE)
fftw_execute(plan)
let expectedResult: array[N, cdouble] = [10.0, -6.0, 2.0]
for i in low(output)..high(output):
assert abs(output[i] - expectedResult[i]) < 1.0e-14

#### Arraymancer API example

## .. code-block:: nim
## var input : Tensor[Complex64] = # Insert data in your input Tensor...
## # Allocate output Tensor
## var output = newTensor[Complex64](input.shape.toSeq)
## # Create a plan
## var plan : fftw_plan = fftw_plan_dft(input, output, FFTW_FORWARD, FFTW_ESTIMATE)
## # Execute plan in-place
## fftw_execute(plan)
runnableExamples:
import arraymancer
import fftw3
import sequtils

var
input : Tensor[Complex64] = newTensor[Complex64](@[10, 10, 10])
reInput = randomTensor[float64](10, 10, 100.0)
imInput = randomTensor[float64](10, 10, 100.0)

for i, x in input.menumerate:
x.re = reInput.atContiguousIndex(i)
x.im = imInput.atContiguousIndex(i)

# Allocate output Tensor
var output = newTensor[Complex64](input.shape.toSeq)
# Create a plan
var plan : fftw_plan = fftw_plan_dft(input, output, FFTW_FORWARD, FFTW_ESTIMATE)
# Execute plan in-place
fftw_execute(plan)

### Planner flags

Expand Down

0 comments on commit 4d56656

Please sign in to comment.