numo-pocketfft 0.5.1 → 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: 7086fd0601883662019b1c7cbab7a043709f580fdffc2083e37ebfbe72202886
4
- data.tar.gz: f922f4c433dc636e1932dc65ed24d25a62f5ad8b450aea64d9f256775aa41b83
3
+ metadata.gz: 150fc0381172fd37f443ab7dfad5135ca021a349d9329e19e5200505b9ee63c7
4
+ data.tar.gz: 1ce9009fab9dd438b610e71e6961701a42f65468c5cebba244a99a428624d269
5
5
  SHA512:
6
- metadata.gz: a2e3eedc4cc59e31dcc59ffcfe653d95c9db6c1f41d9d3e76b60a7f3a7009a97f2c9c9721d0d83b8f10a74386427d1c79b19955023fbd5b25810bee2943efaa9
7
- data.tar.gz: 4216f83ed2bdb87a5f5e48844b20f21d60cc2652bff23dfa27af81316ef32e7feaddee66ffeeaeca48f41290906d6927923a1114026171a573c8a807924c549b
6
+ metadata.gz: ee6aca46690b7582e170f185182e8559e943aeb2586bb8b56616bca4b4e0e82ac6ca198ee52e9dd5b50b5cf65b94d7fc569dc8d42ec4a965a803342a16cddb8c
7
+ data.tar.gz: ac488a978bbe89ee516856987b8f38cd9643b5857f04ed0f5525c61ae4e59307aa48434ce87a26ae1b433ea7594df8c0f64c28a00e4f043065855b1539602040
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # 0.7.0
2
+
3
+ - relax numo-narray-alt upper bound to < 0.12.0.
4
+
5
+ # 0.6.0
6
+
7
+ - relax numo-narray-alt version constraint to >= 0.9.9, < 0.11.0.
8
+
1
9
  # 0.5.1
2
10
 
3
11
  - Set the required version of numo-narray-alt to 0.9.9 or higher.
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2019-2025 Atsushi Tatsuma
1
+ Copyright (c) 2019-2026 Atsushi Tatsuma
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without
@@ -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.5.1'
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.5.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - yoshoku
@@ -13,16 +13,22 @@ dependencies:
13
13
  name: numo-narray-alt
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
- - - "~>"
16
+ - - ">="
17
17
  - !ruby/object:Gem::Version
18
18
  version: 0.9.9
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: 0.12.0
19
22
  type: :runtime
20
23
  prerelease: false
21
24
  version_requirements: !ruby/object:Gem::Requirement
22
25
  requirements:
23
- - - "~>"
26
+ - - ">="
24
27
  - !ruby/object:Gem::Version
25
28
  version: 0.9.9
29
+ - - "<"
30
+ - !ruby/object:Gem::Version
31
+ version: 0.12.0
26
32
  description: 'Numo::Pocketfft provides functions for descrete Fourier Transform based
27
33
  on pocketfft.
28
34
 
@@ -53,7 +59,7 @@ metadata:
53
59
  homepage_uri: https://github.com/yoshoku/numo-pocketfft
54
60
  changelog_uri: https://github.com/yoshoku/numo-pocketfft/blob/main/CHANGELOG.md
55
61
  source_code_uri: https://github.com/yoshoku/numo-pocketfft
56
- documentation_uri: https://gemdocs.org/gems/numo-pocketfft/0.5.1/
62
+ documentation_uri: https://gemdocs.org/gems/numo-pocketfft/0.7.0/
57
63
  bug_tracker_uri: https://github.com/yoshoku/numo-pocketfft/issues
58
64
  rubygems_mfa_required: 'true'
59
65
  rdoc_options: []
@@ -70,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
76
  - !ruby/object:Gem::Version
71
77
  version: '0'
72
78
  requirements: []
73
- rubygems_version: 3.6.9
79
+ rubygems_version: 4.0.13
74
80
  specification_version: 4
75
81
  summary: Numo::Pocketfft provides functions for descrete Fourier Transform based on
76
82
  pocketfft.