numo-narray-alt 0.10.8 → 0.11.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.
@@ -14,11 +14,6 @@
14
14
 
15
15
  #define m_map(x) m_num_to_data(rb_yield(m_data_to_num(x)))
16
16
 
17
- #ifdef __SSE2__
18
- #include <emmintrin.h>
19
- #define SIMD_ALIGNMENT_SIZE 16
20
- #endif
21
-
22
17
  static ID id_pow;
23
18
  static ID id_left_shift;
24
19
  static ID id_right_shift;
@@ -270,7 +265,7 @@ static VALUE uint16_allocate(VALUE self) {
270
265
  case NARRAY_DATA_T:
271
266
  ptr = NA_DATA_PTR(na);
272
267
  if (na->size > 0 && ptr == NULL) {
273
- ptr = xmalloc2(na->size, sizeof(dtype));
268
+ ptr = xmalloc(sizeof(dtype) * na->size);
274
269
 
275
270
  NA_DATA_PTR(na) = ptr;
276
271
  NA_DATA_OWNED(na) = TRUE;
@@ -14,11 +14,6 @@
14
14
 
15
15
  #define m_map(x) m_num_to_data(rb_yield(m_data_to_num(x)))
16
16
 
17
- #ifdef __SSE2__
18
- #include <emmintrin.h>
19
- #define SIMD_ALIGNMENT_SIZE 16
20
- #endif
21
-
22
17
  static ID id_pow;
23
18
  static ID id_left_shift;
24
19
  static ID id_right_shift;
@@ -270,7 +265,7 @@ static VALUE uint32_allocate(VALUE self) {
270
265
  case NARRAY_DATA_T:
271
266
  ptr = NA_DATA_PTR(na);
272
267
  if (na->size > 0 && ptr == NULL) {
273
- ptr = xmalloc2(na->size, sizeof(dtype));
268
+ ptr = xmalloc(sizeof(dtype) * na->size);
274
269
 
275
270
  NA_DATA_PTR(na) = ptr;
276
271
  NA_DATA_OWNED(na) = TRUE;
@@ -14,11 +14,6 @@
14
14
 
15
15
  #define m_map(x) m_num_to_data(rb_yield(m_data_to_num(x)))
16
16
 
17
- #ifdef __SSE2__
18
- #include <emmintrin.h>
19
- #define SIMD_ALIGNMENT_SIZE 16
20
- #endif
21
-
22
17
  static ID id_pow;
23
18
  static ID id_left_shift;
24
19
  static ID id_right_shift;
@@ -270,7 +265,7 @@ static VALUE uint64_allocate(VALUE self) {
270
265
  case NARRAY_DATA_T:
271
266
  ptr = NA_DATA_PTR(na);
272
267
  if (na->size > 0 && ptr == NULL) {
273
- ptr = xmalloc2(na->size, sizeof(dtype));
268
+ ptr = xmalloc(sizeof(dtype) * na->size);
274
269
 
275
270
  NA_DATA_PTR(na) = ptr;
276
271
  NA_DATA_OWNED(na) = TRUE;
@@ -14,11 +14,6 @@
14
14
 
15
15
  #define m_map(x) m_num_to_data(rb_yield(m_data_to_num(x)))
16
16
 
17
- #ifdef __SSE2__
18
- #include <emmintrin.h>
19
- #define SIMD_ALIGNMENT_SIZE 16
20
- #endif
21
-
22
17
  static ID id_pow;
23
18
  static ID id_left_shift;
24
19
  static ID id_right_shift;
@@ -270,7 +265,7 @@ static VALUE uint8_allocate(VALUE self) {
270
265
  case NARRAY_DATA_T:
271
266
  ptr = NA_DATA_PTR(na);
272
267
  if (na->size > 0 && ptr == NULL) {
273
- ptr = xmalloc2(na->size, sizeof(dtype));
268
+ ptr = xmalloc(sizeof(dtype) * na->size);
274
269
 
275
270
  NA_DATA_PTR(na) = ptr;
276
271
  NA_DATA_OWNED(na) = TRUE;
@@ -137,10 +137,6 @@ module Numo
137
137
  # # [[2, -3, 5],
138
138
  # # [4, 9, 7],
139
139
  # # [2, -1, 6]]
140
- # @example
141
- # a = Numo::NArray.parse('true false nil')
142
- # # => Numo::Bit#shape=[1,3]
143
- # # [[1, 0, 0]]
144
140
 
145
141
  def self.parse(str, split1d: /\s+/, split2d: /;?$|;/,
146
142
  split3d: /\s*\n(\s*\n)+/m)
@@ -155,8 +151,7 @@ module Numo
155
151
 
156
152
  c = []
157
153
  line.split(split1d).each do |item|
158
- item = item.strip
159
- c << parse_token(item) unless item.empty?
154
+ c << eval(item.strip) unless item.empty? # rubocop:disable Security/Eval
160
155
  end
161
156
  b << c unless c.empty?
162
157
  end
@@ -169,42 +164,6 @@ module Numo
169
164
  end
170
165
  end
171
166
 
172
- # Convert one token of {parse} input into a value.
173
- #
174
- # Only the literals that describe an element are accepted: integer, float
175
- # and complex numbers, and +true+, +false+ and +nil+, which {cast} turns
176
- # into a {Numo::Bit}. Anything else -- an expression, a method call, a bare
177
- # word -- raises ArgumentError, so text handed to {parse} is never executed
178
- # as Ruby code.
179
- #
180
- # @param item [String] one whitespace-delimited token, already stripped
181
- # @return [Integer, Float, Complex, true, false, nil] the parsed value
182
- # @raise [ArgumentError] if the token is not one of those literals
183
- def self.parse_token(item)
184
- case item
185
- when 'true' then return true
186
- when 'false' then return false
187
- when 'nil' then return nil
188
- end
189
-
190
- v = Integer(item, exception: false)
191
- return v if v
192
-
193
- v = Float(item, exception: false)
194
- return v if v
195
-
196
- if item.end_with?('i')
197
- begin
198
- return Complex(item)
199
- rescue ArgumentError, TypeError
200
- nil
201
- end
202
- end
203
-
204
- raise ArgumentError, "invalid literal: #{item.inspect}"
205
- end
206
- private_class_method :parse_token
207
-
208
167
  # Iterate over an axis
209
168
  # @example
210
169
  # > a = Numo::DFloat.new(2,2,2).seq
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: numo-narray-alt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.8
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - yoshoku
@@ -214,7 +214,7 @@ licenses:
214
214
  metadata:
215
215
  homepage_uri: https://github.com/yoshoku/numo-narray-alt
216
216
  changelog_uri: https://github.com/yoshoku/numo-narray-alt/blob/main/CHANGELOG.md
217
- documentation_uri: https://gemdocs.org/gems/numo-narray-alt/0.10.8/
217
+ documentation_uri: https://gemdocs.org/gems/numo-narray-alt/0.11.0/
218
218
  rubygems_mfa_required: 'true'
219
219
  post_install_message: |
220
220
  ===
@@ -238,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
238
238
  - !ruby/object:Gem::Version
239
239
  version: '0'
240
240
  requirements: []
241
- rubygems_version: 4.0.20
241
+ rubygems_version: 4.0.13
242
242
  specification_version: 4
243
243
  summary: Numo::NArray Alternative is a project forked from Numo::NArray.
244
244
  test_files: []