numo-narray 0.9.1.0 → 0.9.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,8 +13,8 @@ extern "C" {
13
13
  #endif
14
14
  #endif
15
15
 
16
- #define NARRAY_VERSION "0.9.1.0"
17
- #define NARRAY_VERSION_CODE 910
16
+ #define NARRAY_VERSION "0.9.1.1"
17
+ #define NARRAY_VERSION_CODE 911
18
18
 
19
19
  #include <math.h>
20
20
  #include "numo/compat.h"
@@ -439,3 +439,48 @@ static inline dtype f_ptp(size_t n, char *p, ssize_t stride)
439
439
  f_minmax(n,p,stride,&min,&max);
440
440
  return m_sub(max,min);
441
441
  }
442
+
443
+
444
+ static inline dtype f_maximum(dtype x, dtype y)
445
+ {
446
+ if (m_ge(x,y)) {
447
+ return x;
448
+ }
449
+ if (not_nan(y)) {
450
+ return y;
451
+ }
452
+ return x;
453
+ }
454
+
455
+ static inline dtype f_maximum_nan(dtype x, dtype y)
456
+ {
457
+ if (m_ge(x,y)) {
458
+ return x;
459
+ }
460
+ if (!not_nan(x)) {
461
+ return x;
462
+ }
463
+ return y;
464
+ }
465
+
466
+ static inline dtype f_minimum(dtype x, dtype y)
467
+ {
468
+ if (m_le(x,y)) {
469
+ return x;
470
+ }
471
+ if (not_nan(y)) {
472
+ return y;
473
+ }
474
+ return x;
475
+ }
476
+
477
+ static inline dtype f_minimum_nan(dtype x, dtype y)
478
+ {
479
+ if (m_le(x,y)) {
480
+ return x;
481
+ }
482
+ if (!not_nan(x)) {
483
+ return x;
484
+ }
485
+ return y;
486
+ }
@@ -171,3 +171,19 @@ static inline double f_seq(double x, double y, double c)
171
171
  {
172
172
  return x + y * c;
173
173
  }
174
+
175
+ static inline dtype f_maximum(dtype x, dtype y)
176
+ {
177
+ if (m_ge(x,y)) {
178
+ return x;
179
+ }
180
+ return y;
181
+ }
182
+
183
+ static inline dtype f_minimum(dtype x, dtype y)
184
+ {
185
+ if (m_le(x,y)) {
186
+ return x;
187
+ }
188
+ return y;
189
+ }
data/numo-narray.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.email = ["masa16.tanaka@gmail.com"]
19
19
  spec.description = %q{Numo::NArray - New NArray class library in Ruby/Numo.}
20
20
  spec.summary = %q{alpha release of Numo::NArray - New NArray class library in Ruby/Numo (NUmerical MOdule)}
21
- spec.homepage = "https://github.com/ruby-numo/narray"
21
+ spec.homepage = "https://github.com/ruby-numo/numo-narray"
22
22
  spec.license = "BSD-3-Clause"
23
23
  spec.required_ruby_version = '~> 2.1'
24
24
 
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
30
30
 
31
31
  spec.add_development_dependency "bundler", "~> 1.3"
32
32
  spec.add_development_dependency "rake", "~> 0"
33
- spec.add_development_dependency "rspec", "~> 3"
33
+ spec.add_development_dependency "test-unit"
34
34
  spec.add_development_dependency 'rake-compiler', "~> 1.0", ">= 1.0.1"
35
35
  spec.add_development_dependency "rake-compiler-dock", "~> 0"
36
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: numo-narray
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1.0
4
+ version: 0.9.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro TANAKA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-28 00:00:00.000000000 Z
11
+ date: 2018-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -39,19 +39,19 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rspec
42
+ name: test-unit
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '3'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '3'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake-compiler
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -120,6 +120,7 @@ files:
120
120
  - ext/numo/narray/gen/def/uint32.rb
121
121
  - ext/numo/narray/gen/def/uint64.rb
122
122
  - ext/numo/narray/gen/def/uint8.rb
123
+ - ext/numo/narray/gen/erbln.rb
123
124
  - ext/numo/narray/gen/erbpp2.rb
124
125
  - ext/numo/narray/gen/narray_def.rb
125
126
  - ext/numo/narray/gen/spec.rb
@@ -144,6 +145,7 @@ files:
144
145
  - ext/numo/narray/gen/tmpl/cum.c
145
146
  - ext/numo/narray/gen/tmpl/each.c
146
147
  - ext/numo/narray/gen/tmpl/each_with_index.c
148
+ - ext/numo/narray/gen/tmpl/ewcomp.c
147
149
  - ext/numo/narray/gen/tmpl/extract.c
148
150
  - ext/numo/narray/gen/tmpl/extract_data.c
149
151
  - ext/numo/narray/gen/tmpl/eye.c
@@ -239,15 +241,10 @@ files:
239
241
  - ext/numo/narray/rand.c
240
242
  - ext/numo/narray/step.c
241
243
  - ext/numo/narray/struct.c
242
- - lib/erbpp.rb
243
- - lib/erbpp/line_number.rb
244
- - lib/erbpp/narray_def.rb
245
244
  - lib/numo/narray.rb
246
245
  - lib/numo/narray/extra.rb
247
246
  - numo-narray.gemspec
248
- - spec/bit_spec.rb
249
- - spec/narray_spec.rb
250
- homepage: https://github.com/ruby-numo/narray
247
+ homepage: https://github.com/ruby-numo/numo-narray
251
248
  licenses:
252
249
  - BSD-3-Clause
253
250
  metadata: {}
@@ -272,6 +269,4 @@ signing_key:
272
269
  specification_version: 4
273
270
  summary: alpha release of Numo::NArray - New NArray class library in Ruby/Numo (NUmerical
274
271
  MOdule)
275
- test_files:
276
- - spec/bit_spec.rb
277
- - spec/narray_spec.rb
272
+ test_files: []
data/lib/erbpp.rb DELETED
@@ -1,294 +0,0 @@
1
- require "erb"
2
-
3
- class ErbPP
4
- ATTRS = []
5
-
6
- class ParamNotSetError < StandardError; end
7
-
8
- def self.define_attrs(attrs)
9
- attrs.each do |attr|
10
- ivar = ("@"+attr).to_sym
11
- define_method(attr){|*a| attr_method(ivar,*a)}
12
- end
13
- end
14
-
15
- def attr_method(ivar,arg=nil)
16
- if arg.nil?
17
- instance_variable_get(ivar)
18
- else
19
- instance_variable_set(ivar,arg)
20
- end
21
- end
22
-
23
- def initialize(parent,erb_path,opts={})
24
- parents.push(parent) if parent
25
- @erb_path = erb_path
26
- @tmpl = @erb_path
27
-
28
- @opts = opts
29
- if @opts.class != Hash
30
- raise ArgumentError, "option is not Hash"
31
- end
32
-
33
- @opts.each do |k,v|
34
- ivar = ("@"+k.to_s).to_sym
35
- instance_variable_set(ivar,v)
36
- end
37
- end
38
-
39
- def load_erb
40
- safe_level = nil
41
- trim_mode = '%<>'
42
- @erb = ERB.new(File.read(@erb_path),safe_level,trim_mode)
43
- @erb.filename = @erb_path
44
- end
45
-
46
- def parents
47
- @parents ||= []
48
- end
49
-
50
- def search_method_in_parents(_meth_id)
51
- parents.each do |x|
52
- if x.has_attr? _meth_id
53
- return x
54
- end
55
- end
56
- parents.each do |x|
57
- if f = x.search_method_in_parents(_meth_id)
58
- return f
59
- end
60
- end
61
- nil
62
- end
63
-
64
- def attrs
65
- self.class::ATTRS
66
- end
67
-
68
- def has_attr?(_meth_id)
69
- respond_to?(_meth_id) or attrs.include?(_meth_id.to_s)
70
- end
71
-
72
- def check_params(*params)
73
- params.each do |x|
74
- val = send(x)
75
- if !val # || val.empty?
76
- raise ParamNotSetError,"parameter #{x.to_s} is not set"
77
- end
78
- end
79
- end
80
-
81
- alias method_missing_alias method_missing
82
-
83
- def method_missing(_meth_id, *args, &block)
84
- ivar = "@"+_meth_id.to_s
85
- if args.empty? and instance_variable_defined?(ivar)
86
- parm = instance_variable_get(ivar)
87
- if parm.nil?
88
- raise ParamNotSetError,"parameter #{_meth_id.to_s} is not set"
89
- end
90
- parm
91
- elsif args.size == 1 and attrs.include?(_meth_id.to_s)
92
- instance_variable_set(ivar,args.first)
93
- elsif x = search_method_in_parents(_meth_id)
94
- x.send(_meth_id, *args, &block)
95
- else
96
- method_missing_alias(_meth_id, *args)
97
- end
98
- end
99
-
100
- def run
101
- load_erb unless @erb
102
- @erb.run(binding)
103
- end
104
-
105
- def result
106
- load_erb unless @erb
107
- @erb.result(binding)
108
- end
109
- end
110
-
111
- # ----------------------------------------------------------------------
112
-
113
- class IdVar
114
- DEFS = []
115
-
116
- def id_decl
117
- "static ID #{@id_var};"
118
- end
119
-
120
- def id_assign
121
- "#{@id_var} = rb_intern(\"#{@name}\");"
122
- end
123
-
124
- def initialize(parent,name,var=nil)
125
- @name = name
126
- var = name if var.nil?
127
- @id_var = "id_"+var.gsub(/\?/,"_p").gsub(/\!/,"_bang")
128
- DEFS.push(self)
129
- end
130
-
131
- def self.declaration
132
- DEFS.map do |x|
133
- x.id_decl
134
- end
135
- end
136
-
137
- def self.assignment
138
- DEFS.map do |x|
139
- x.id_assign
140
- end
141
- end
142
- end
143
-
144
- # ----------------------------------------------------------------------
145
-
146
- class Function < ErbPP
147
- DEFS = []
148
-
149
- attrs = %w[
150
- singleton
151
- meth
152
- n_arg
153
- ]
154
- define_attrs attrs
155
-
156
- def id_op
157
- if op.size == 1
158
- "'#{op}'"
159
- else
160
- "id_#{method}"
161
- end
162
- end
163
-
164
- def method
165
- meth.gsub(/\?/,"_p").gsub(/\!/,"_bang")
166
- end
167
-
168
- def initialize(parent,tmpl,**opts)
169
- super
170
- @aliases = opts[:aliases] || []
171
- parent.tmpl_dirs.each do |d|
172
- @erb_path = File.join(d, tmpl+".c")
173
- break if File.exist?(@erb_path)
174
- end
175
- DEFS.push(self)
176
- end
177
-
178
- def c_method
179
- "#{m_prefix}#{method}"
180
- end
181
-
182
- def c_iter
183
- begin
184
- t = "_"+type_name
185
- rescue
186
- t = ""
187
- end
188
- "iter#{t}_#{method}"
189
- end
190
- alias c_iterator c_iter
191
-
192
- def c_func
193
- s = singleton ? "_s" : ""
194
- begin
195
- t = "_"+type_name
196
- rescue
197
- t = ""
198
- end
199
- "numo#{t}#{s}_#{method}"
200
- end
201
- alias c_function c_func
202
- alias c_instance_method c_func
203
-
204
- def op_map
205
- @op || meth
206
- end
207
-
208
- def code
209
- result + "\n\n"
210
- end
211
-
212
- def definition
213
- return nil if n_arg <= -9
214
- s = singleton ? "_singleton" : ""
215
- check_params(:mod_var, :op_map, :c_func, :n_arg)
216
- m = op_map
217
- a = ["rb_define#{s}_method(#{mod_var}, \"#{m}\", #{c_func}, #{n_arg});"]
218
- @aliases.map{|x| a << "rb_define_alias(#{mod_var}, \"#{x}\", \"#{m}\");"}
219
- a
220
- end
221
-
222
- def self.codes
223
- a = []
224
- DEFS.each do |i|
225
- x = i.code
226
- a.push(x) if x
227
- end
228
- a
229
- end
230
-
231
- def self.definitions
232
- a = []
233
- DEFS.each do |i|
234
- case x = i.definition
235
- when Array
236
- a.concat(x)
237
- when String
238
- a.push(x)
239
- else
240
- raise "unknown definition: #{x}" if x
241
- end
242
- end
243
- a
244
- end
245
- end
246
-
247
- class ModuleFunction < Function
248
- def definition
249
- m = op_map
250
- "rb_define_module_function(#{mod_var}, \"#{m}\", #{c_func}, #{n_arg});"
251
- end
252
- end
253
-
254
- class NodefFunction < Function
255
- def definition
256
- nil
257
- end
258
- end
259
-
260
- class Alias < ErbPP
261
- def initialize(parent, dst, src)
262
- super(parent,nil)
263
- @dst = dst
264
- @src = src
265
- Function::DEFS.push(self)
266
- end
267
-
268
- def code
269
- nil
270
- end
271
-
272
- def definition
273
- "rb_define_alias(#{mod_var}, \"#{dst}\", \"#{src}\");"
274
- end
275
- end
276
-
277
- class Const < ErbPP
278
- def initialize(parent,name,value,desc)
279
- super(parent,nil)
280
- @name = name
281
- @value = value
282
- @desc = desc
283
- Function::DEFS.push(self)
284
- end
285
-
286
- def code
287
- nil
288
- end
289
-
290
- def definition
291
- "/*"+desc+"*/\n "+
292
- "rb_define_const(#{mod_var},\"#{name}\",#{value});"
293
- end
294
- end