numo-narray-alt 0.9.10 → 0.9.12

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.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +0 -1
  3. data/LICENSE +1 -1
  4. data/README.md +7 -0
  5. data/ext/numo/narray/numo/narray.h +2 -2
  6. data/ext/numo/narray/numo/types/robj_macro.h +1 -1
  7. data/ext/numo/narray/numo/types/robject.h +1 -1
  8. data/ext/numo/narray/src/mh/argmax.h +154 -0
  9. data/ext/numo/narray/src/mh/argmin.h +154 -0
  10. data/ext/numo/narray/src/mh/bincount.h +233 -0
  11. data/ext/numo/narray/src/mh/bit/and.h +225 -0
  12. data/ext/numo/narray/src/mh/bit/left_shift.h +225 -0
  13. data/ext/numo/narray/src/mh/bit/not.h +173 -0
  14. data/ext/numo/narray/src/mh/bit/or.h +225 -0
  15. data/ext/numo/narray/src/mh/bit/right_shift.h +225 -0
  16. data/ext/numo/narray/src/mh/bit/xor.h +225 -0
  17. data/ext/numo/narray/src/mh/clip.h +115 -0
  18. data/ext/numo/narray/src/mh/coerce_cast.h +9 -0
  19. data/ext/numo/narray/src/mh/comp/binary_func.h +37 -0
  20. data/ext/numo/narray/src/mh/comp/eq.h +26 -0
  21. data/ext/numo/narray/src/mh/comp/ge.h +26 -0
  22. data/ext/numo/narray/src/mh/comp/gt.h +26 -0
  23. data/ext/numo/narray/src/mh/comp/le.h +26 -0
  24. data/ext/numo/narray/src/mh/comp/lt.h +26 -0
  25. data/ext/numo/narray/src/mh/comp/ne.h +26 -0
  26. data/ext/numo/narray/src/mh/comp/nearly_eq.h +26 -0
  27. data/ext/numo/narray/src/mh/cumprod.h +98 -0
  28. data/ext/numo/narray/src/mh/cumsum.h +98 -0
  29. data/ext/numo/narray/src/mh/divmod.h +142 -0
  30. data/ext/numo/narray/src/mh/eye.h +82 -0
  31. data/ext/numo/narray/src/mh/fill.h +94 -0
  32. data/ext/numo/narray/src/mh/format.h +108 -0
  33. data/ext/numo/narray/src/mh/format_to_a.h +89 -0
  34. data/ext/numo/narray/src/mh/inspect.h +33 -0
  35. data/ext/numo/narray/src/mh/isfinite.h +42 -0
  36. data/ext/numo/narray/src/mh/isinf.h +42 -0
  37. data/ext/numo/narray/src/mh/isnan.h +42 -0
  38. data/ext/numo/narray/src/mh/isneginf.h +42 -0
  39. data/ext/numo/narray/src/mh/isposinf.h +42 -0
  40. data/ext/numo/narray/src/mh/logseq.h +69 -0
  41. data/ext/numo/narray/src/mh/math/acos.h +2 -2
  42. data/ext/numo/narray/src/mh/math/acosh.h +2 -2
  43. data/ext/numo/narray/src/mh/math/asin.h +2 -2
  44. data/ext/numo/narray/src/mh/math/asinh.h +2 -2
  45. data/ext/numo/narray/src/mh/math/atan.h +2 -2
  46. data/ext/numo/narray/src/mh/math/atan2.h +3 -3
  47. data/ext/numo/narray/src/mh/math/atanh.h +2 -2
  48. data/ext/numo/narray/src/mh/math/cbrt.h +2 -2
  49. data/ext/numo/narray/src/mh/math/cos.h +2 -2
  50. data/ext/numo/narray/src/mh/math/cosh.h +2 -2
  51. data/ext/numo/narray/src/mh/math/erf.h +2 -2
  52. data/ext/numo/narray/src/mh/math/erfc.h +2 -2
  53. data/ext/numo/narray/src/mh/math/exp.h +2 -2
  54. data/ext/numo/narray/src/mh/math/exp10.h +2 -2
  55. data/ext/numo/narray/src/mh/math/exp2.h +2 -2
  56. data/ext/numo/narray/src/mh/math/expm1.h +2 -2
  57. data/ext/numo/narray/src/mh/math/frexp.h +3 -3
  58. data/ext/numo/narray/src/mh/math/hypot.h +3 -3
  59. data/ext/numo/narray/src/mh/math/ldexp.h +3 -3
  60. data/ext/numo/narray/src/mh/math/log.h +2 -2
  61. data/ext/numo/narray/src/mh/math/log10.h +2 -2
  62. data/ext/numo/narray/src/mh/math/log1p.h +2 -2
  63. data/ext/numo/narray/src/mh/math/log2.h +2 -2
  64. data/ext/numo/narray/src/mh/math/sin.h +2 -2
  65. data/ext/numo/narray/src/mh/math/sinc.h +2 -2
  66. data/ext/numo/narray/src/mh/math/sinh.h +2 -2
  67. data/ext/numo/narray/src/mh/math/sqrt.h +8 -8
  68. data/ext/numo/narray/src/mh/math/tan.h +2 -2
  69. data/ext/numo/narray/src/mh/math/tanh.h +2 -2
  70. data/ext/numo/narray/src/mh/math/unary_func.h +3 -3
  71. data/ext/numo/narray/src/mh/max.h +69 -0
  72. data/ext/numo/narray/src/mh/max_index.h +184 -0
  73. data/ext/numo/narray/src/mh/maximum.h +116 -0
  74. data/ext/numo/narray/src/mh/min.h +69 -0
  75. data/ext/numo/narray/src/mh/min_index.h +184 -0
  76. data/ext/numo/narray/src/mh/minimum.h +116 -0
  77. data/ext/numo/narray/src/mh/minmax.h +77 -0
  78. data/ext/numo/narray/src/mh/mulsum.h +185 -0
  79. data/ext/numo/narray/src/mh/op/add.h +78 -0
  80. data/ext/numo/narray/src/mh/op/binary_func.h +423 -0
  81. data/ext/numo/narray/src/mh/op/div.h +118 -0
  82. data/ext/numo/narray/src/mh/op/mod.h +108 -0
  83. data/ext/numo/narray/src/mh/op/mul.h +78 -0
  84. data/ext/numo/narray/src/mh/op/sub.h +78 -0
  85. data/ext/numo/narray/src/mh/prod.h +69 -0
  86. data/ext/numo/narray/src/mh/ptp.h +69 -0
  87. data/ext/numo/narray/src/mh/rand.h +315 -0
  88. data/ext/numo/narray/src/mh/round/ceil.h +11 -0
  89. data/ext/numo/narray/src/mh/round/floor.h +11 -0
  90. data/ext/numo/narray/src/mh/round/rint.h +9 -0
  91. data/ext/numo/narray/src/mh/round/round.h +11 -0
  92. data/ext/numo/narray/src/mh/round/trunc.h +11 -0
  93. data/ext/numo/narray/src/mh/round/unary_func.h +127 -0
  94. data/ext/numo/narray/src/mh/seq.h +130 -0
  95. data/ext/numo/narray/src/mh/sum.h +69 -0
  96. data/ext/numo/narray/src/mh/to_a.h +78 -0
  97. data/ext/numo/narray/src/t_bit.c +45 -234
  98. data/ext/numo/narray/src/t_dcomplex.c +608 -2369
  99. data/ext/numo/narray/src/t_dfloat.c +485 -3736
  100. data/ext/numo/narray/src/t_int16.c +743 -3444
  101. data/ext/numo/narray/src/t_int32.c +745 -3445
  102. data/ext/numo/narray/src/t_int64.c +743 -3446
  103. data/ext/numo/narray/src/t_int8.c +678 -3040
  104. data/ext/numo/narray/src/t_robject.c +771 -3548
  105. data/ext/numo/narray/src/t_scomplex.c +607 -2368
  106. data/ext/numo/narray/src/t_sfloat.c +440 -3693
  107. data/ext/numo/narray/src/t_uint16.c +743 -3440
  108. data/ext/numo/narray/src/t_uint32.c +743 -3440
  109. data/ext/numo/narray/src/t_uint64.c +743 -3442
  110. data/ext/numo/narray/src/t_uint8.c +678 -3038
  111. data/lib/numo/narray.rb +2 -3
  112. metadata +62 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: add439c28ff954af644b534f782e947340823412f847c3aadf3c912f8023e497
4
- data.tar.gz: fa84b086865ff372d22c9caa2a3ad02101b74047fd3ad9e237aa1d81ac0bb2a2
3
+ metadata.gz: 90bcb68c4b90224af8196f103f31646f653f9a495ff7b47e24c1f03c3ba8f3d2
4
+ data.tar.gz: f3105f5bd8c5a2ae27a21ac27f05ad7382a2db76a13529639951ecd98459462b
5
5
  SHA512:
6
- metadata.gz: 3b84e09af31d5f8cc7ae36ca7ed04382bdb4d31d03352b448d74ccb2004b7cc2f7e95e46873a84b5b5b9e0bbf1bdf63f22b8133391896300063412599ef73ca4
7
- data.tar.gz: 3f3ee6430bcce41d3c47ac63bc85b4e7d5c122ddead47c389f7f3e7c74eb68dd76bbc32585a1c360b095cc5a74535376d2793d9d6e9df5f86e1e08ea6f68d23f
6
+ metadata.gz: 7e81366c927e13e1da39ab2675d9dd11ba75498ee144570728eaf8f9181b471a83d5b7034fdc6e3ce155cbe080f64444c0f17316f64c854d34e950de7b8398b4
7
+ data.tar.gz: a18a12e36781c4a06f02e2e92835778559e5afa3d3fed7c1b71a257bd7ed91e5523c856db685a1b3c3a527c9dc43f54e229df545a6edfafeaf539c136331ae42
data/Gemfile CHANGED
@@ -15,7 +15,6 @@ gem 'rubocop-minitest', '~> 0.38.2'
15
15
  gem 'rubocop-performance', '~> 1.26'
16
16
  gem 'rubocop-rake', '~> 0.7.1'
17
17
  gem 'simplecov', '~> 0.22.0'
18
- gem 'test-unit', '~> 3.7'
19
18
  gem 'yard', '~> 0.9.37'
20
19
 
21
20
  group :memcheck, optional: true do
data/LICENSE CHANGED
@@ -1,7 +1,7 @@
1
1
  BSD 3-Clause License
2
2
 
3
3
  Copyright (c) 1999-2025, Masahiro TANAKA
4
- Copyright (c) 2025, Atsushi TATSUMA
4
+ Copyright (c) 2025-2026, Atsushi TATSUMA
5
5
  All rights reserved.
6
6
 
7
7
  Redistribution and use in source and binary forms, with or without
data/README.md CHANGED
@@ -43,6 +43,13 @@ Numo::DFloat#shape=[2,2]
43
43
  irb(main):004>
44
44
  ```
45
45
 
46
+ If you want to explicitly load numo-narray-alt, write the require method as follows:
47
+
48
+ ```ruby
49
+ irb(main):001> require 'numo/narray/alt'
50
+ => true
51
+ ```
52
+
46
53
  ## Documentation
47
54
 
48
55
  - [API Documentation on Gemdocs](https://gemdocs.org/gems/numo-narray-alt/)
@@ -13,8 +13,8 @@ extern "C" {
13
13
  #endif
14
14
  #endif
15
15
 
16
- #define NARRAY_VERSION "0.9.10"
17
- #define NARRAY_VERSION_CODE 9100
16
+ #define NARRAY_VERSION "0.9.12"
17
+ #define NARRAY_VERSION_CODE 9120
18
18
 
19
19
  #include <math.h>
20
20
  #include "numo/compat.h"
@@ -22,7 +22,7 @@
22
22
  { \
23
23
  x = rb_funcall(x, id_divmod, 1, y); \
24
24
  a = RARRAY_PTR(x)[0]; \
25
- b = RARRAY_PTR(x)[0]; \
25
+ b = RARRAY_PTR(x)[1]; \
26
26
  }
27
27
  #define m_pow(x, y) rb_funcall(x, id_pow, 1, y)
28
28
  #define m_pow_int(x, y) rb_funcall(x, id_pow, 1, y)
@@ -21,5 +21,5 @@ inline static int robj_nearly_eq(VALUE vx, VALUE vy) {
21
21
 
22
22
  /* generates a random number on [0,1)-real-interval */
23
23
  inline static dtype m_rand(dtype max) {
24
- return DBL2NUM(genrand_res53_mix() * max);
24
+ return DBL2NUM(genrand_res53_mix() * NUM2DBL(max));
25
25
  }
@@ -0,0 +1,154 @@
1
+ #ifndef NUMO_NARRAY_MH_ARGMAX_H
2
+ #define NUMO_NARRAY_MH_ARGMAX_H 1
3
+
4
+ #define DEF_NARRAY_FLT_ARGMAX_METHOD_FUNC(tDType) \
5
+ static void iter_##tDType##_argmax_arg64(na_loop_t* const lp) { \
6
+ size_t n; \
7
+ size_t idx; \
8
+ char* d_ptr; \
9
+ char* o_ptr; \
10
+ ssize_t d_step; \
11
+ \
12
+ INIT_COUNTER(lp, n); \
13
+ INIT_PTR(lp, 0, d_ptr, d_step); \
14
+ \
15
+ idx = f_max_index(n, d_ptr, d_step); \
16
+ \
17
+ o_ptr = NDL_PTR(lp, 1); \
18
+ *(int64_t*)o_ptr = (int64_t)idx; \
19
+ } \
20
+ \
21
+ static void iter_##tDType##_argmax_arg32(na_loop_t* const lp) { \
22
+ size_t n; \
23
+ size_t idx; \
24
+ char* d_ptr; \
25
+ char* o_ptr; \
26
+ ssize_t d_step; \
27
+ \
28
+ INIT_COUNTER(lp, n); \
29
+ INIT_PTR(lp, 0, d_ptr, d_step); \
30
+ \
31
+ idx = f_max_index(n, d_ptr, d_step); \
32
+ \
33
+ o_ptr = NDL_PTR(lp, 1); \
34
+ *(int32_t*)o_ptr = (int32_t)idx; \
35
+ } \
36
+ \
37
+ static void iter_##tDType##_argmax_arg64_nan(na_loop_t* const lp) { \
38
+ size_t n; \
39
+ size_t idx; \
40
+ char* d_ptr; \
41
+ char* o_ptr; \
42
+ ssize_t d_step; \
43
+ \
44
+ INIT_COUNTER(lp, n); \
45
+ INIT_PTR(lp, 0, d_ptr, d_step); \
46
+ \
47
+ idx = f_max_index_nan(n, d_ptr, d_step); \
48
+ \
49
+ o_ptr = NDL_PTR(lp, 1); \
50
+ *(int64_t*)o_ptr = (int64_t)idx; \
51
+ } \
52
+ \
53
+ static void iter_##tDType##_argmax_arg32_nan(na_loop_t* const lp) { \
54
+ size_t n; \
55
+ size_t idx; \
56
+ char* d_ptr; \
57
+ char* o_ptr; \
58
+ ssize_t d_step; \
59
+ \
60
+ INIT_COUNTER(lp, n); \
61
+ INIT_PTR(lp, 0, d_ptr, d_step); \
62
+ \
63
+ idx = f_max_index_nan(n, d_ptr, d_step); \
64
+ \
65
+ o_ptr = NDL_PTR(lp, 1); \
66
+ *(int32_t*)o_ptr = (int32_t)idx; \
67
+ } \
68
+ \
69
+ static VALUE tDType##_argmax(int argc, VALUE* argv, VALUE self) { \
70
+ narray_t* na; \
71
+ VALUE reduce; \
72
+ ndfunc_arg_in_t ain[2] = { { Qnil, 0 }, { sym_reduce, 0 } }; \
73
+ ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } }; \
74
+ ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 1, ain, aout }; \
75
+ \
76
+ GetNArray(self, na); \
77
+ if (na->ndim == 0) { \
78
+ return INT2FIX(0); \
79
+ } \
80
+ \
81
+ if (na->size > (~(u_int32_t)0)) { \
82
+ aout[0].type = numo_cInt64; \
83
+ ndf.func = iter_##tDType##_argmax_arg64; \
84
+ reduce = \
85
+ na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_##tDType##_argmax_arg64_nan); \
86
+ } else { \
87
+ aout[0].type = numo_cInt32; \
88
+ ndf.func = iter_##tDType##_argmax_arg32; \
89
+ reduce = \
90
+ na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_##tDType##_argmax_arg32_nan); \
91
+ } \
92
+ \
93
+ return na_ndloop(&ndf, 2, self, reduce); \
94
+ }
95
+
96
+ #define DEF_NARRAY_INT_ARGMAX_METHOD_FUNC(tDType) \
97
+ static void iter_##tDType##_argmax_arg64(na_loop_t* const lp) { \
98
+ size_t n; \
99
+ size_t idx; \
100
+ char* d_ptr; \
101
+ char* o_ptr; \
102
+ ssize_t d_step; \
103
+ \
104
+ INIT_COUNTER(lp, n); \
105
+ INIT_PTR(lp, 0, d_ptr, d_step); \
106
+ \
107
+ idx = f_max_index(n, d_ptr, d_step); \
108
+ \
109
+ o_ptr = NDL_PTR(lp, 1); \
110
+ *(int64_t*)o_ptr = (int64_t)idx; \
111
+ } \
112
+ \
113
+ static void iter_##tDType##_argmax_arg32(na_loop_t* const lp) { \
114
+ size_t n; \
115
+ size_t idx; \
116
+ char* d_ptr; \
117
+ char* o_ptr; \
118
+ ssize_t d_step; \
119
+ \
120
+ INIT_COUNTER(lp, n); \
121
+ INIT_PTR(lp, 0, d_ptr, d_step); \
122
+ \
123
+ idx = f_max_index(n, d_ptr, d_step); \
124
+ \
125
+ o_ptr = NDL_PTR(lp, 1); \
126
+ *(int32_t*)o_ptr = (int32_t)idx; \
127
+ } \
128
+ \
129
+ static VALUE tDType##_argmax(int argc, VALUE* argv, VALUE self) { \
130
+ narray_t* na; \
131
+ VALUE reduce; \
132
+ ndfunc_arg_in_t ain[2] = { { Qnil, 0 }, { sym_reduce, 0 } }; \
133
+ ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } }; \
134
+ ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 1, ain, aout }; \
135
+ \
136
+ GetNArray(self, na); \
137
+ if (na->ndim == 0) { \
138
+ return INT2FIX(0); \
139
+ } \
140
+ \
141
+ if (na->size > (~(u_int32_t)0)) { \
142
+ aout[0].type = numo_cInt64; \
143
+ ndf.func = iter_##tDType##_argmax_arg64; \
144
+ reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0); \
145
+ } else { \
146
+ aout[0].type = numo_cInt32; \
147
+ ndf.func = iter_##tDType##_argmax_arg32; \
148
+ reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0); \
149
+ } \
150
+ \
151
+ return na_ndloop(&ndf, 2, self, reduce); \
152
+ }
153
+
154
+ #endif /* NUMO_NARRAY_MH_ARGMAX_H */
@@ -0,0 +1,154 @@
1
+ #ifndef NUMO_NARRAY_MH_ARGMIN_H
2
+ #define NUMO_NARRAY_MH_ARGMIN_H 1
3
+
4
+ #define DEF_NARRAY_FLT_ARGMIN_METHOD_FUNC(tDType) \
5
+ static void iter_##tDType##_argmin_arg64(na_loop_t* const lp) { \
6
+ size_t n; \
7
+ size_t idx; \
8
+ char* d_ptr; \
9
+ char* o_ptr; \
10
+ ssize_t d_step; \
11
+ \
12
+ INIT_COUNTER(lp, n); \
13
+ INIT_PTR(lp, 0, d_ptr, d_step); \
14
+ \
15
+ idx = f_min_index(n, d_ptr, d_step); \
16
+ \
17
+ o_ptr = NDL_PTR(lp, 1); \
18
+ *(int64_t*)o_ptr = (int64_t)idx; \
19
+ } \
20
+ \
21
+ static void iter_##tDType##_argmin_arg32(na_loop_t* const lp) { \
22
+ size_t n; \
23
+ size_t idx; \
24
+ char* d_ptr; \
25
+ char* o_ptr; \
26
+ ssize_t d_step; \
27
+ \
28
+ INIT_COUNTER(lp, n); \
29
+ INIT_PTR(lp, 0, d_ptr, d_step); \
30
+ \
31
+ idx = f_min_index(n, d_ptr, d_step); \
32
+ \
33
+ o_ptr = NDL_PTR(lp, 1); \
34
+ *(int32_t*)o_ptr = (int32_t)idx; \
35
+ } \
36
+ \
37
+ static void iter_##tDType##_argmin_arg64_nan(na_loop_t* const lp) { \
38
+ size_t n; \
39
+ size_t idx; \
40
+ char* d_ptr; \
41
+ char* o_ptr; \
42
+ ssize_t d_step; \
43
+ \
44
+ INIT_COUNTER(lp, n); \
45
+ INIT_PTR(lp, 0, d_ptr, d_step); \
46
+ \
47
+ idx = f_min_index_nan(n, d_ptr, d_step); \
48
+ \
49
+ o_ptr = NDL_PTR(lp, 1); \
50
+ *(int64_t*)o_ptr = (int64_t)idx; \
51
+ } \
52
+ \
53
+ static void iter_##tDType##_argmin_arg32_nan(na_loop_t* const lp) { \
54
+ size_t n; \
55
+ size_t idx; \
56
+ char* d_ptr; \
57
+ char* o_ptr; \
58
+ ssize_t d_step; \
59
+ \
60
+ INIT_COUNTER(lp, n); \
61
+ INIT_PTR(lp, 0, d_ptr, d_step); \
62
+ \
63
+ idx = f_min_index_nan(n, d_ptr, d_step); \
64
+ \
65
+ o_ptr = NDL_PTR(lp, 1); \
66
+ *(int32_t*)o_ptr = (int32_t)idx; \
67
+ } \
68
+ \
69
+ static VALUE tDType##_argmin(int argc, VALUE* argv, VALUE self) { \
70
+ narray_t* na; \
71
+ VALUE reduce; \
72
+ ndfunc_arg_in_t ain[2] = { { Qnil, 0 }, { sym_reduce, 0 } }; \
73
+ ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } }; \
74
+ ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 1, ain, aout }; \
75
+ \
76
+ GetNArray(self, na); \
77
+ if (na->ndim == 0) { \
78
+ return INT2FIX(0); \
79
+ } \
80
+ \
81
+ if (na->size > (~(u_int32_t)0)) { \
82
+ aout[0].type = numo_cInt64; \
83
+ ndf.func = iter_##tDType##_argmin_arg64; \
84
+ reduce = \
85
+ na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_##tDType##_argmin_arg64_nan); \
86
+ } else { \
87
+ aout[0].type = numo_cInt32; \
88
+ ndf.func = iter_##tDType##_argmin_arg32; \
89
+ reduce = \
90
+ na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_##tDType##_argmin_arg32_nan); \
91
+ } \
92
+ \
93
+ return na_ndloop(&ndf, 2, self, reduce); \
94
+ }
95
+
96
+ #define DEF_NARRAY_INT_ARGMIN_METHOD_FUNC(tDType) \
97
+ static void iter_##tDType##_argmin_arg64(na_loop_t* const lp) { \
98
+ size_t n; \
99
+ size_t idx; \
100
+ char* d_ptr; \
101
+ char* o_ptr; \
102
+ ssize_t d_step; \
103
+ \
104
+ INIT_COUNTER(lp, n); \
105
+ INIT_PTR(lp, 0, d_ptr, d_step); \
106
+ \
107
+ idx = f_min_index(n, d_ptr, d_step); \
108
+ \
109
+ o_ptr = NDL_PTR(lp, 1); \
110
+ *(int64_t*)o_ptr = (int64_t)idx; \
111
+ } \
112
+ \
113
+ static void iter_##tDType##_argmin_arg32(na_loop_t* const lp) { \
114
+ size_t n; \
115
+ size_t idx; \
116
+ char* d_ptr; \
117
+ char* o_ptr; \
118
+ ssize_t d_step; \
119
+ \
120
+ INIT_COUNTER(lp, n); \
121
+ INIT_PTR(lp, 0, d_ptr, d_step); \
122
+ \
123
+ idx = f_min_index(n, d_ptr, d_step); \
124
+ \
125
+ o_ptr = NDL_PTR(lp, 1); \
126
+ *(int32_t*)o_ptr = (int32_t)idx; \
127
+ } \
128
+ \
129
+ static VALUE tDType##_argmin(int argc, VALUE* argv, VALUE self) { \
130
+ narray_t* na; \
131
+ VALUE reduce; \
132
+ ndfunc_arg_in_t ain[2] = { { Qnil, 0 }, { sym_reduce, 0 } }; \
133
+ ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } }; \
134
+ ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 1, ain, aout }; \
135
+ \
136
+ GetNArray(self, na); \
137
+ if (na->ndim == 0) { \
138
+ return INT2FIX(0); \
139
+ } \
140
+ \
141
+ if (na->size > (~(u_int32_t)0)) { \
142
+ aout[0].type = numo_cInt64; \
143
+ ndf.func = iter_##tDType##_argmin_arg64; \
144
+ reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0); \
145
+ } else { \
146
+ aout[0].type = numo_cInt32; \
147
+ ndf.func = iter_##tDType##_argmin_arg32; \
148
+ reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0); \
149
+ } \
150
+ \
151
+ return na_ndloop(&ndf, 2, self, reduce); \
152
+ }
153
+
154
+ #endif /* NUMO_NARRAY_MH_ARGMIN_H */