numo-pocketfft 0.6.0 → 0.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ad2588103f5bbf0f5c72ac5129f843bf7d0851e4af1357ac8d31cb2b1f2a6c2
4
- data.tar.gz: '099615d79db3d7f7de0574b698dc501d18b23b881b5325d700d7eaa373491bc2'
3
+ metadata.gz: 150fc0381172fd37f443ab7dfad5135ca021a349d9329e19e5200505b9ee63c7
4
+ data.tar.gz: 1ce9009fab9dd438b610e71e6961701a42f65468c5cebba244a99a428624d269
5
5
  SHA512:
6
- metadata.gz: d32eef0c2f4152ec800a722acd228630b507c3d175064b71c69082b859943abf4440a73edf3864b8a1b2fcd35ff82ee6cd78dc311566afb48e2d711551947367
7
- data.tar.gz: bece0b9dfcddaa2e99f2de97dc24628d8f578a0a1233e45d71a978173d3fdfdd86a213f841ffabbf42b0817df39add3e9a52baa7a3d134c425bf85b060760369
6
+ metadata.gz: ee6aca46690b7582e170f185182e8559e943aeb2586bb8b56616bca4b4e0e82ac6ca198ee52e9dd5b50b5cf65b94d7fc569dc8d42ec4a965a803342a16cddb8c
7
+ data.tar.gz: ac488a978bbe89ee516856987b8f38cd9643b5857f04ed0f5525c61ae4e59307aa48434ce87a26ae1b433ea7594df8c0f64c28a00e4f043065855b1539602040
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.7.0
2
+
3
+ - relax numo-narray-alt upper bound to < 0.12.0.
4
+
1
5
  # 0.6.0
2
6
 
3
7
  - relax numo-narray-alt version constraint to >= 0.9.9, < 0.11.0.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'mkmf'
2
4
  require 'numo/narray/alt'
3
5
 
@@ -13,7 +15,7 @@ unless have_header('numo/narray.h')
13
15
  exit(1)
14
16
  end
15
17
 
16
- if RUBY_PLATFORM =~ /mswin|cygwin|mingw/
18
+ if RUBY_PLATFORM.match?(/mswin|cygwin|mingw/)
17
19
  $LOAD_PATH.each do |lp|
18
20
  if File.exist?(File.join(lp, 'numo/narray/libnarray.a'))
19
21
  $LDFLAGS = "-L#{lp}/numo/narray #{$LDFLAGS}"
@@ -26,15 +28,15 @@ if RUBY_PLATFORM =~ /mswin|cygwin|mingw/
26
28
  end
27
29
  end
28
30
 
29
- if RUBY_PLATFORM.match?(/darwin/) && Gem::Version.new('3.1.0') <= Gem::Version.new(RUBY_VERSION)
30
- if try_link('int main(void){return 0;}', '-Wl,-undefined,dynamic_lookup')
31
- $LDFLAGS << ' -Wl,-undefined,dynamic_lookup'
32
- end
31
+ if RUBY_PLATFORM.include?('darwin') && Gem::Version.new('3.1.0') <= Gem::Version.new(RUBY_VERSION) && try_link(
32
+ 'int main(void){return 0;}', '-Wl,-undefined,dynamic_lookup'
33
+ )
34
+ $LDFLAGS << ' -Wl,-undefined,dynamic_lookup'
33
35
  end
34
36
 
35
37
  $CFLAGS = "#{$CFLAGS} -std=c99"
36
38
 
37
39
  $srcs = Dir.glob("#{$srcdir}/**/*.c").map { |path| File.basename(path) }
38
- $VPATH << "$(srcdir)/src"
40
+ $VPATH << '$(srcdir)/src'
39
41
 
40
42
  create_makefile('numo/pocketfft/pocketfftext')
@@ -34,7 +34,8 @@ VALUE numo_pocketfft_fft(VALUE x_val, int is_forward) {
34
34
  int n_repeats = (int)(NA_SIZE(x_nary)) / length;
35
35
  for (int i = 0; i < n_repeats; i++) {
36
36
  memcpy(z_pt, x_pt, 2 * length * sizeof(double));
37
- if ((is_forward == 1 ? cfft_forward(plan, z_pt, fct) : cfft_backward(plan, z_pt, fct)) != 0) {
37
+ int scss = is_forward == 1 ? cfft_forward(plan, z_pt, fct) : cfft_backward(plan, z_pt, fct);
38
+ if (scss != 0) {
38
39
  fail = 1;
39
40
  break;
40
41
  }
@@ -60,12 +61,16 @@ VALUE numo_pocketfft_fft(VALUE x_val, int is_forward) {
60
61
  /**
61
62
  * @!visibility private
62
63
  */
63
- static VALUE numo_pocketfft_cfft(VALUE self, VALUE x_val) { return numo_pocketfft_fft(x_val, 1); }
64
+ static VALUE numo_pocketfft_cfft(VALUE self, VALUE x_val) {
65
+ return numo_pocketfft_fft(x_val, 1);
66
+ }
64
67
 
65
68
  /**
66
69
  * @!visibility private
67
70
  */
68
- static VALUE numo_pocketfft_icfft(VALUE self, VALUE x_val) { return numo_pocketfft_fft(x_val, 0); }
71
+ static VALUE numo_pocketfft_icfft(VALUE self, VALUE x_val) {
72
+ return numo_pocketfft_fft(x_val, 0);
73
+ }
69
74
 
70
75
  /**
71
76
  * @!visibility private
@@ -91,8 +96,9 @@ static VALUE numo_pocketfft_rfft(VALUE self, VALUE x_val) {
91
96
  }
92
97
 
93
98
  size_t* z_shape = ALLOCA_N(size_t, n_dims);
94
- for (int i = 0; i < n_dims - 1; i++)
99
+ for (int i = 0; i < n_dims - 1; i++) {
95
100
  z_shape[i] = NA_SHAPE(x_nary)[i];
101
+ }
96
102
  z_shape[n_dims - 1] = length / 2 + 1;
97
103
  VALUE z_val = rb_narray_new(numo_cDComplex, n_dims, z_shape);
98
104
  double* z_pt = (double*)na_get_pointer_for_write(z_val);
@@ -194,7 +200,7 @@ static VALUE numo_pocketfft_irfft(VALUE self, VALUE x_val) {
194
200
  return z_val;
195
201
  }
196
202
 
197
- void Init_pocketfftext() {
203
+ void Init_pocketfftext(void) {
198
204
  rb_require("numo/narray");
199
205
 
200
206
  mNumo = rb_define_module("Numo");
@@ -5,6 +5,6 @@ module Numo
5
5
  # Numo::Pocketfft is the module that has functions for Fourier transform.
6
6
  module Pocketfft
7
7
  # The version of Numo::Pocketfft you are using.
8
- VERSION = '0.6.0'
8
+ VERSION = '0.7.0'
9
9
  end
10
10
  end
@@ -5,7 +5,7 @@ require 'numo/pocketfft/version'
5
5
  require 'numo/pocketfft/pocketfftext'
6
6
 
7
7
  module Numo
8
- module Pocketfft
8
+ module Pocketfft # rubocop:disable Metrics/ModuleLength, Style/Documentation
9
9
  module_function
10
10
 
11
11
  # Compute the 1-dimensional discrete Fourier Transform.
@@ -189,22 +189,26 @@ module Numo
189
189
  # @param b [Numo::DFloat/Numo::DComplex] Second input array with the same number of dimensions as first input array.
190
190
  # @raise [ArgumentError] This error is raised if input arrays are not Numo::NArray, are not the same dimensionality, or are empty.
191
191
  # @return [Numo::DFloat/Numo::DComplex] The discrete linear convolution of 'a' with 'b'.
192
- def fftconvolve(a, b)
193
- raise ArgumentError, 'Expect class of input array to be Numo::NArray.' unless a.is_a?(Numo::NArray) && b.is_a?(Numo::NArray)
192
+ def fftconvolve(a, b) # rubocop:disable Metrics/AbcSize
193
+ unless a.is_a?(Numo::NArray) && b.is_a?(Numo::NArray)
194
+ raise ArgumentError, 'Expect class of input array to be Numo::NArray.'
195
+ end
194
196
  raise ArgumentError, 'Expect input array to be non-empty.' if a.empty? || b.empty?
195
197
  raise ArgumentError, 'Input arrays should have the same dimensionarity' if a.ndim != b.ndim
196
198
 
197
199
  ashp = a.shape
198
200
  bshp = b.shape
199
201
 
200
- return a * b if (ashp + bshp).all? { |el| el == 1 }
202
+ return a * b if (ashp + bshp).all?(1)
201
203
 
202
204
  retshp = Array.new(a.ndim) { |n| ashp[n] + bshp[n] - 1 }
203
205
  a_zp = Numo::DComplex.zeros(*retshp).tap { |arr| arr[*ashp.map { |n| 0...n }] = a }
204
206
  b_zp = Numo::DComplex.zeros(*retshp).tap { |arr| arr[*bshp.map { |n| 0...n }] = b }
205
207
  ret = ifftn(fftn(a_zp) * fftn(b_zp))
206
208
 
207
- return ret if a.is_a?(Numo::DComplex) || a.is_a?(Numo::SComplex) || b.is_a?(Numo::DComplex) || b.is_a?(Numo::SComplex)
209
+ if a.is_a?(Numo::DComplex) || a.is_a?(Numo::SComplex) || b.is_a?(Numo::DComplex) || b.is_a?(Numo::SComplex)
210
+ return ret
211
+ end
208
212
 
209
213
  ret.real
210
214
  end
@@ -226,19 +230,15 @@ module Numo
226
230
  else
227
231
  ext_rfft(a)
228
232
  end
233
+ elsif inverse
234
+ ext_icfft(a)
229
235
  else
230
- if inverse
231
- ext_icfft(a)
232
- else
233
- ext_cfft(a)
234
- end
236
+ ext_cfft(a)
235
237
  end
238
+ elsif inverse
239
+ ext_icfft(a.swapaxes(axis_id, -1)).swapaxes(axis_id, -1).dup
236
240
  else
237
- if inverse
238
- ext_icfft(a.swapaxes(axis_id, -1)).swapaxes(axis_id, -1).dup
239
- else
240
- ext_cfft(a.swapaxes(axis_id, -1)).swapaxes(axis_id, -1).dup
241
- end
241
+ ext_cfft(a.swapaxes(axis_id, -1)).swapaxes(axis_id, -1).dup
242
242
  end
243
243
  end
244
244
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: numo-pocketfft
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - yoshoku
@@ -18,7 +18,7 @@ dependencies:
18
18
  version: 0.9.9
19
19
  - - "<"
20
20
  - !ruby/object:Gem::Version
21
- version: 0.11.0
21
+ version: 0.12.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -28,7 +28,7 @@ dependencies:
28
28
  version: 0.9.9
29
29
  - - "<"
30
30
  - !ruby/object:Gem::Version
31
- version: 0.11.0
31
+ version: 0.12.0
32
32
  description: 'Numo::Pocketfft provides functions for descrete Fourier Transform based
33
33
  on pocketfft.
34
34
 
@@ -59,7 +59,7 @@ metadata:
59
59
  homepage_uri: https://github.com/yoshoku/numo-pocketfft
60
60
  changelog_uri: https://github.com/yoshoku/numo-pocketfft/blob/main/CHANGELOG.md
61
61
  source_code_uri: https://github.com/yoshoku/numo-pocketfft
62
- documentation_uri: https://gemdocs.org/gems/numo-pocketfft/0.6.0/
62
+ documentation_uri: https://gemdocs.org/gems/numo-pocketfft/0.7.0/
63
63
  bug_tracker_uri: https://github.com/yoshoku/numo-pocketfft/issues
64
64
  rubygems_mfa_required: 'true'
65
65
  rdoc_options: []
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
78
  requirements: []
79
- rubygems_version: 4.0.3
79
+ rubygems_version: 4.0.13
80
80
  specification_version: 4
81
81
  summary: Numo::Pocketfft provides functions for descrete Fourier Transform based on
82
82
  pocketfft.