numo-pocketfft 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +20 -0
- data/.gitmodules +4 -0
- data/.rspec +3 -0
- data/.travis.yml +13 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +27 -0
- data/README.md +76 -0
- data/Rakefile +16 -0
- data/ext/numo/pocketfft/extconf.rb +39 -0
- data/ext/numo/pocketfft/pocketfft/.gitlab-ci.yml +12 -0
- data/ext/numo/pocketfft/pocketfft/LICENSE.md +25 -0
- data/ext/numo/pocketfft/pocketfft/README.md +55 -0
- data/ext/numo/pocketfft/pocketfft/TESTING +6 -0
- data/ext/numo/pocketfft/pocketfft/ffttest.c +96 -0
- data/ext/numo/pocketfft/pocketfft/pocketfft.c +2190 -0
- data/ext/numo/pocketfft/pocketfft/pocketfft.h +34 -0
- data/ext/numo/pocketfft/pocketfftext.c +214 -0
- data/ext/numo/pocketfft/pocketfftext.h +13 -0
- data/lib/numo/pocketfft.rb +149 -0
- data/lib/numo/pocketfft/version.rb +10 -0
- data/numo-pocketfft.gemspec +47 -0
- metadata +158 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bddf2fdda35fb2a8308fabe55a365945282cec74
|
4
|
+
data.tar.gz: 34d970a1a6a45a667fbd57f648cd7e0dde85bf6e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ae9396b7f766a993efbb49ae837b684e8b3ab17b1728ec41798dbadb2954b30faf9bc0232e4b0c07faec2bea938e8f6cf02f5597771e79bbe9318cb2b56ec57c
|
7
|
+
data.tar.gz: 53c4212c75ffc3ce9e6b876eb4ec194fc1a7f2ada7796992675c539b08f703c250a4308cc83fa5f7a33f029965d602cba66a70cd6ce1c0d1c71f778ddaeea9e9
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.gitignore
ADDED
data/.gitmodules
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at yoshoku@outlook.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
Copyright (c) 2019 Atsushi Tatsuma
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
* Redistributions of source code must retain the above copyright notice, this
|
8
|
+
list of conditions and the following disclaimer.
|
9
|
+
|
10
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
this list of conditions and the following disclaimer in the documentation
|
12
|
+
and/or other materials provided with the distribution.
|
13
|
+
|
14
|
+
* Neither the name of the copyright holder nor the names of its
|
15
|
+
contributors may be used to endorse or promote products derived from
|
16
|
+
this software without specific prior written permission.
|
17
|
+
|
18
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
19
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
20
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
21
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
22
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
23
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
24
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
25
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
26
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
27
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# Numo::Pocketfft
|
2
|
+
|
3
|
+
[](https://travis-ci.org/yoshoku/numo-pocketfft)
|
4
|
+
[](https://coveralls.io/github/yoshoku/numo-pocketfft?branch=master)
|
5
|
+
[](https://github.com/yoshoku/numo-liblinear/blob/master/LICENSE.txt)
|
6
|
+
|
7
|
+
Numo::Pocketfft provides functions for performing descrete Fourier Transform with
|
8
|
+
[Numo::NArray](https://github.com/ruby-numo/numo-narray) by using
|
9
|
+
[pocketfft](https://gitlab.mpcdf.mpg.de/mtr/pocketfft) as backgroud library.
|
10
|
+
|
11
|
+
Note: There are other useful Ruby gems perform descrete Fourier Transform with Numo::NArray:
|
12
|
+
[Numo::FFTW](https://github.com/ruby-numo/numo-fftw) and [Numo::FFTE](https://github.com/ruby-numo/numo-ffte) by Masahiro Tanaka.
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
Numo::Pocketfft bundles pocketfft codes, so there is no need to install the library in advance.
|
17
|
+
Add this line to your application's Gemfile:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
gem 'numo-pocketfft'
|
21
|
+
```
|
22
|
+
|
23
|
+
And then execute:
|
24
|
+
|
25
|
+
$ bundle
|
26
|
+
|
27
|
+
Or install it yourself as:
|
28
|
+
|
29
|
+
$ gem install numo-pocketfft
|
30
|
+
|
31
|
+
## Usage
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
require 'numo/narray'
|
35
|
+
require 'numo/pocketfft'
|
36
|
+
|
37
|
+
a = Numo::DFloat[1, 1, 1, 1]
|
38
|
+
# => Numo::DFloat#shape=[4]
|
39
|
+
# [1, 1, 1, 1]
|
40
|
+
|
41
|
+
b = Numo::Pocketfft.rfft(a)
|
42
|
+
# => Numo::DComplex#shape=[3]
|
43
|
+
# [4+0i, 0+0i, 0+0i]
|
44
|
+
|
45
|
+
Numo::Pocketfft.irfft(b)
|
46
|
+
# => Numo::DFloat#shape=[4]
|
47
|
+
# [1, 1, 1, 1]
|
48
|
+
|
49
|
+
c = Numo::DFloat.new(2, 2).rand + Complex::I * Numo::DFloat.new(2, 2).rand
|
50
|
+
# => Numo::DComplex#shape=[2,2]
|
51
|
+
# [[0.0617545+0.116041i, 0.373067+0.344032i],
|
52
|
+
# [0.794815+0.539948i, 0.201042+0.737815i]]
|
53
|
+
|
54
|
+
Numo::Pocketfft.ifft2(Numo::Pocketfft.fft2(c))
|
55
|
+
#=> Numo::DComplex#shape=[2,2]
|
56
|
+
#[[0.0617545+0.116041i, 0.373067+0.344032i],
|
57
|
+
# [0.794815+0.539948i, 0.201042+0.737815i]]
|
58
|
+
```
|
59
|
+
|
60
|
+
## Development
|
61
|
+
|
62
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
63
|
+
|
64
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
65
|
+
|
66
|
+
## Contributing
|
67
|
+
|
68
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/yoshoku/numo-pocketfft. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
69
|
+
|
70
|
+
## License
|
71
|
+
|
72
|
+
The gem is available as open source under the terms of the [BSD-3-Clause License](https://opensource.org/licenses/BSD-3-Clause).
|
73
|
+
|
74
|
+
## Code of Conduct
|
75
|
+
|
76
|
+
Everyone interacting in the Numo::Pocketfft project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/yoshoku/numo-pocketfft/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
5
|
+
|
6
|
+
require 'rake/extensiontask'
|
7
|
+
|
8
|
+
task :build => :compile
|
9
|
+
|
10
|
+
Rake::ExtensionTask.new('pocketfftext') do |ext|
|
11
|
+
ext.ext_dir = 'ext/numo/pocketfft'
|
12
|
+
ext.lib_dir = 'lib/numo/pocketfft'
|
13
|
+
end
|
14
|
+
|
15
|
+
task :default => [:clobber, :compile, :spec]
|
16
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'mkmf'
|
2
|
+
require 'numo/narray'
|
3
|
+
|
4
|
+
$LOAD_PATH.each do |lp|
|
5
|
+
if File.exist?(File.join(lp, 'numo/numo/narray.h'))
|
6
|
+
$INCFLAGS = "-I#{lp}/numo #{$INCFLAGS}"
|
7
|
+
break
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
unless have_header('numo/narray.h')
|
12
|
+
puts 'numo/narray.h not found.'
|
13
|
+
exit(1)
|
14
|
+
end
|
15
|
+
|
16
|
+
if RUBY_PLATFORM =~ /mswin|cygwin|mingw/
|
17
|
+
$LOAD_PATH.each do |lp|
|
18
|
+
if File.exist?(File.join(lp, 'numo/libnarray.a'))
|
19
|
+
$LDFLAGS = "-L#{lp}/numo #{$LDFLAGS}"
|
20
|
+
break
|
21
|
+
end
|
22
|
+
end
|
23
|
+
unless have_library('narray', 'nary_new')
|
24
|
+
puts 'libnarray.a not found.'
|
25
|
+
exit(1)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
$CFLAGS = "#{$CFLAGS} -std=c99"
|
30
|
+
|
31
|
+
$srcs = Dir.glob("#{$srcdir}/*.c").map { |path| File.basename(path) }
|
32
|
+
$srcs << 'pocketfft.c'
|
33
|
+
Dir.glob("#{$srcdir}/*/") do |path|
|
34
|
+
dir = File.basename(path)
|
35
|
+
$INCFLAGS << " -I$(srcdir)/#{dir}"
|
36
|
+
$VPATH << "$(srcdir)/#{dir}"
|
37
|
+
end
|
38
|
+
|
39
|
+
create_makefile('numo/pocketfft/pocketfftext')
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Copyright (C) 2010-2019 Max-Planck-Society
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification,
|
5
|
+
are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
* Redistributions of source code must retain the above copyright notice, this
|
8
|
+
list of conditions and the following disclaimer.
|
9
|
+
* Redistributions in binary form must reproduce the above copyright notice, this
|
10
|
+
list of conditions and the following disclaimer in the documentation and/or
|
11
|
+
other materials provided with the distribution.
|
12
|
+
* Neither the name of the copyright holder nor the names of its contributors may
|
13
|
+
be used to endorse or promote products derived from this software without
|
14
|
+
specific prior written permission.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
17
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
19
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
20
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
21
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
22
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
23
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
24
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
25
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@@ -0,0 +1,55 @@
|
|
1
|
+
PocketFFT
|
2
|
+
---------
|
3
|
+
|
4
|
+
This is a heavily modified implementation of FFTPack [1,2], with the following
|
5
|
+
advantages:
|
6
|
+
|
7
|
+
- strictly C99 compliant
|
8
|
+
- more accurate twiddle factor computation
|
9
|
+
- very fast plan generation
|
10
|
+
- worst case complexity for transform sizes with large prime factors is
|
11
|
+
`N*log(N)`, because Bluestein's algorithm [3] is used for these cases.
|
12
|
+
|
13
|
+
License
|
14
|
+
-------
|
15
|
+
|
16
|
+
3-clause BSD (see LICENSE.md)
|
17
|
+
|
18
|
+
|
19
|
+
Some code details
|
20
|
+
-----------------
|
21
|
+
|
22
|
+
Twiddle factor computation:
|
23
|
+
|
24
|
+
- making use of symmetries to reduce number of sin/cos evaluations
|
25
|
+
- all angles are reduced to the range `[0; pi/4]` for higher accuracy
|
26
|
+
- an adapted implementation of `sincospi()` is used, which actually computes
|
27
|
+
`sin(x)` and `(cos(x)-1)`.
|
28
|
+
- if `n` sin/cos pairs are required, the adjusted `sincospi()` is only called
|
29
|
+
`2*sqrt(n)` times; the remaining values are obtained by evaluating the
|
30
|
+
angle addition theorems in a numerically accurate way.
|
31
|
+
|
32
|
+
Parallel invocation:
|
33
|
+
|
34
|
+
- Plans only contain read-only data; all temporary arrays are allocated and
|
35
|
+
deallocated during an individual FFT execution. This means that a single plan
|
36
|
+
can be used in several threads at the same time.
|
37
|
+
|
38
|
+
Efficient codelets are available for the factors:
|
39
|
+
|
40
|
+
- 2, 3, 4, 5, 7, 11 for complex-valued FFTs
|
41
|
+
- 2, 3, 4, 5 for real-valued FFTs
|
42
|
+
|
43
|
+
Larger prime factors are handled by somewhat less efficient, generic routines.
|
44
|
+
|
45
|
+
For lengths with very large prime factors, Bluestein's algorithm is used, and
|
46
|
+
instead of an FFT of length `n`, a convolution of length `n2 >= 2*n-1`
|
47
|
+
is performed, where `n2` is chosen to be highly composite.
|
48
|
+
|
49
|
+
|
50
|
+
[1] Swarztrauber, P. 1982, Vectorizing the Fast Fourier Transforms
|
51
|
+
(New York: Academic Press), 51
|
52
|
+
|
53
|
+
[2] https://www.netlib.org/fftpack/
|
54
|
+
|
55
|
+
[3] https://en.wikipedia.org/wiki/Chirp_Z-transform
|
@@ -0,0 +1,96 @@
|
|
1
|
+
/*
|
2
|
+
* This file is part of pocketfft.
|
3
|
+
* Licensed under a 3-clause BSD style license - see LICENSE.md
|
4
|
+
*/
|
5
|
+
|
6
|
+
/*
|
7
|
+
* Test codes for pocketfft.
|
8
|
+
*
|
9
|
+
* Copyright (C) 2004-2018 Max-Planck-Society
|
10
|
+
* \author Martin Reinecke
|
11
|
+
*/
|
12
|
+
|
13
|
+
#include <stdio.h>
|
14
|
+
#include <stdlib.h>
|
15
|
+
#include <math.h>
|
16
|
+
#include <string.h>
|
17
|
+
#include "pocketfft.h"
|
18
|
+
|
19
|
+
#define maxlen 8192
|
20
|
+
|
21
|
+
static void fill_random (double *data, size_t length)
|
22
|
+
{
|
23
|
+
for (size_t m=0; m<length; ++m)
|
24
|
+
data[m] = rand()/(RAND_MAX+1.0)-0.5;
|
25
|
+
}
|
26
|
+
|
27
|
+
static double errcalc (double *data, double *odata, size_t length)
|
28
|
+
{
|
29
|
+
double sum = 0, errsum = 0;
|
30
|
+
for (size_t m=0; m<length; ++m)
|
31
|
+
{
|
32
|
+
errsum += (data[m]-odata[m])*(data[m]-odata[m]);
|
33
|
+
sum += odata[m]*odata[m];
|
34
|
+
}
|
35
|
+
return sqrt(errsum/sum);
|
36
|
+
}
|
37
|
+
|
38
|
+
static int test_real(void)
|
39
|
+
{
|
40
|
+
double data[maxlen], odata[maxlen];
|
41
|
+
const double epsilon=2e-15;
|
42
|
+
int ret = 0;
|
43
|
+
fill_random (odata, maxlen);
|
44
|
+
double errsum=0;
|
45
|
+
for (int length=1; length<=maxlen; ++length)
|
46
|
+
{
|
47
|
+
memcpy (data,odata,length*sizeof(double));
|
48
|
+
rfft_plan plan = make_rfft_plan (length);
|
49
|
+
rfft_forward (plan, data, 1.);
|
50
|
+
rfft_backward (plan, data, 1./length);
|
51
|
+
destroy_rfft_plan (plan);
|
52
|
+
double err = errcalc (data, odata, length);
|
53
|
+
if (err>epsilon)
|
54
|
+
{
|
55
|
+
printf("problem at real length %i: %e\n",length,err);
|
56
|
+
ret = 1;
|
57
|
+
}
|
58
|
+
errsum+=err;
|
59
|
+
}
|
60
|
+
printf("errsum: %e\n",errsum);
|
61
|
+
return ret;
|
62
|
+
}
|
63
|
+
|
64
|
+
static int test_complex(void)
|
65
|
+
{
|
66
|
+
double data[2*maxlen], odata[2*maxlen];
|
67
|
+
fill_random (odata, 2*maxlen);
|
68
|
+
const double epsilon=2e-15;
|
69
|
+
int ret = 0;
|
70
|
+
double errsum=0;
|
71
|
+
for (int length=1; length<=maxlen; ++length)
|
72
|
+
{
|
73
|
+
memcpy (data,odata,2*length*sizeof(double));
|
74
|
+
cfft_plan plan = make_cfft_plan (length);
|
75
|
+
cfft_forward(plan, data, 1.);
|
76
|
+
cfft_backward(plan, data, 1./length);
|
77
|
+
destroy_cfft_plan (plan);
|
78
|
+
double err = errcalc (data, odata, 2*length);
|
79
|
+
if (err>epsilon)
|
80
|
+
{
|
81
|
+
printf("problem at complex length %i: %e\n",length,err);
|
82
|
+
ret = 1;
|
83
|
+
}
|
84
|
+
errsum+=err;
|
85
|
+
}
|
86
|
+
printf("errsum: %e\n",errsum);
|
87
|
+
return ret;
|
88
|
+
}
|
89
|
+
|
90
|
+
int main(void)
|
91
|
+
{
|
92
|
+
int ret = 0;
|
93
|
+
ret = test_real();
|
94
|
+
ret += test_complex();
|
95
|
+
return ret;
|
96
|
+
}
|