numo-narray-alt 0.9.6 → 0.9.8
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 +4 -4
- data/README.md +31 -10
- data/ext/numo/narray/SFMT-params19937.h +8 -16
- data/ext/numo/narray/numo/narray.h +2 -2
- data/ext/numo/narray/numo/types/complex.h +2 -2
- data/ext/numo/narray/src/mh/math/acos.h +9 -0
- data/ext/numo/narray/src/mh/math/acosh.h +9 -0
- data/ext/numo/narray/src/mh/math/asin.h +9 -0
- data/ext/numo/narray/src/mh/math/asinh.h +9 -0
- data/ext/numo/narray/src/mh/math/atan.h +9 -0
- data/ext/numo/narray/src/mh/math/atan2.h +29 -0
- data/ext/numo/narray/src/mh/math/atanh.h +9 -0
- data/ext/numo/narray/src/mh/math/cbrt.h +9 -0
- data/ext/numo/narray/src/mh/math/cos.h +9 -0
- data/ext/numo/narray/src/mh/math/cosh.h +9 -0
- data/ext/numo/narray/src/mh/math/erf.h +9 -0
- data/ext/numo/narray/src/mh/math/erfc.h +9 -0
- data/ext/numo/narray/src/mh/math/exp.h +9 -0
- data/ext/numo/narray/src/mh/math/exp10.h +9 -0
- data/ext/numo/narray/src/mh/math/exp2.h +9 -0
- data/ext/numo/narray/src/mh/math/expm1.h +9 -0
- data/ext/numo/narray/src/mh/math/frexp.h +30 -0
- data/ext/numo/narray/src/mh/math/hypot.h +29 -0
- data/ext/numo/narray/src/mh/math/ldexp.h +29 -0
- data/ext/numo/narray/src/mh/math/log.h +9 -0
- data/ext/numo/narray/src/mh/math/log10.h +9 -0
- data/ext/numo/narray/src/mh/math/log1p.h +9 -0
- data/ext/numo/narray/src/mh/math/log2.h +9 -0
- data/ext/numo/narray/src/mh/math/sin.h +9 -0
- data/ext/numo/narray/src/mh/math/sinc.h +9 -0
- data/ext/numo/narray/src/mh/math/sinh.h +9 -0
- data/ext/numo/narray/src/mh/math/sqrt.h +203 -0
- data/ext/numo/narray/src/mh/math/tan.h +9 -0
- data/ext/numo/narray/src/mh/math/tanh.h +9 -0
- data/ext/numo/narray/src/mh/math/unary_func.h +70 -0
- data/ext/numo/narray/src/mh/mean.h +1 -8
- data/ext/numo/narray/src/mh/rms.h +1 -8
- data/ext/numo/narray/src/mh/stddev.h +1 -8
- data/ext/numo/narray/src/mh/var.h +1 -8
- data/ext/numo/narray/src/t_dcomplex.c +236 -1707
- data/ext/numo/narray/src/t_dfloat.c +66 -1952
- data/ext/numo/narray/src/t_robject.c +4 -4
- data/ext/numo/narray/src/t_scomplex.c +236 -1707
- data/ext/numo/narray/src/t_sfloat.c +66 -1952
- data/lib/numo/narray/extra.rb +77 -0
- metadata +33 -3
data/lib/numo/narray/extra.rb
CHANGED
|
@@ -1045,6 +1045,83 @@ module Numo
|
|
|
1045
1045
|
a
|
|
1046
1046
|
end
|
|
1047
1047
|
|
|
1048
|
+
# Returns an index array of sort result.
|
|
1049
|
+
#
|
|
1050
|
+
# @example
|
|
1051
|
+
# require 'numo/narray'
|
|
1052
|
+
#
|
|
1053
|
+
# a = Numo::DFloat[[0.1, 0.7],
|
|
1054
|
+
# [0.4, 0.2],
|
|
1055
|
+
# [0.2, 0.5]]
|
|
1056
|
+
# pp a.argsort
|
|
1057
|
+
# # =>
|
|
1058
|
+
# # Numo::Int32#shape=[3,2]
|
|
1059
|
+
# # [[0, 1],
|
|
1060
|
+
# # [1, 0],
|
|
1061
|
+
# # [0, 1]]
|
|
1062
|
+
# pp a.argsort(axis: 0)
|
|
1063
|
+
# # =>
|
|
1064
|
+
# # Numo::Int32#shape=[3,2]
|
|
1065
|
+
# # [[0, 1],
|
|
1066
|
+
# # [2, 2],
|
|
1067
|
+
# # [1, 0]]
|
|
1068
|
+
# pp a.argsort(axis: 1)
|
|
1069
|
+
# # =>
|
|
1070
|
+
# # Numo::Int32#shape=[3,2]
|
|
1071
|
+
# # [[0, 1],
|
|
1072
|
+
# # [1, 0],
|
|
1073
|
+
# # [0, 1]]
|
|
1074
|
+
# pp a.argsort(axis: nil)
|
|
1075
|
+
# # =>
|
|
1076
|
+
# # Numo::Int32#shape=[6]
|
|
1077
|
+
# # [0, 3, 4, 2, 5, 1]
|
|
1078
|
+
#
|
|
1079
|
+
# @overload argsort(axis: -1)
|
|
1080
|
+
# @param axis [Integer, nil] Axis along which to sort. Default is -1 (the last axis).
|
|
1081
|
+
# If `nil` is given, the array is flattened before sorting.
|
|
1082
|
+
# @return [Numo::Int32] An array of indices that would sort the array.
|
|
1083
|
+
def argsort(axis_ = 'none', axis: -1)
|
|
1084
|
+
raise NotImplementedError, "argsort is not implemented for #{self.class}" unless respond_to?(:sort_index)
|
|
1085
|
+
|
|
1086
|
+
axis = axis_ unless axis_ == 'none'
|
|
1087
|
+
|
|
1088
|
+
return flatten.sort_index if axis.nil?
|
|
1089
|
+
|
|
1090
|
+
axis = ndim + axis if axis.negative?
|
|
1091
|
+
raise Numo::NArray::DimensionError, 'dimension is out of range' if axis.negative? || axis >= ndim
|
|
1092
|
+
|
|
1093
|
+
case ndim
|
|
1094
|
+
when 1
|
|
1095
|
+
sort_index
|
|
1096
|
+
when 2
|
|
1097
|
+
case axis
|
|
1098
|
+
when 0
|
|
1099
|
+
indices = transpose.sort_index(1)
|
|
1100
|
+
indices.transpose - indices.min(1)
|
|
1101
|
+
when 1
|
|
1102
|
+
indices = sort_index(1)
|
|
1103
|
+
indices - indices.min(1).expand_dims(1)
|
|
1104
|
+
end
|
|
1105
|
+
else
|
|
1106
|
+
res = Numo::Int32.zeros(*shape)
|
|
1107
|
+
slicer = Array.new(ndim)
|
|
1108
|
+
slicer[axis] = true
|
|
1109
|
+
other_axes = Array.new(ndim) { |i| i } - [axis]
|
|
1110
|
+
axis_ids = other_axes.map do |d|
|
|
1111
|
+
Array.new(shape[d]) { |i| i }
|
|
1112
|
+
end
|
|
1113
|
+
axis_ids.inject(:product).each do |indices|
|
|
1114
|
+
indices = indices.flatten
|
|
1115
|
+
other_axes.each_with_index do |d, i|
|
|
1116
|
+
slicer[d] = indices[i]
|
|
1117
|
+
end
|
|
1118
|
+
sorted_indices = self[*slicer].sort_index
|
|
1119
|
+
res[*slicer] = sorted_indices - sorted_indices.min
|
|
1120
|
+
end
|
|
1121
|
+
res
|
|
1122
|
+
end
|
|
1123
|
+
end
|
|
1124
|
+
|
|
1048
1125
|
# Return the sum along diagonals of the array.
|
|
1049
1126
|
#
|
|
1050
1127
|
# If 2-D array, computes the summation along its diagonal with the
|
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.9.
|
|
4
|
+
version: 0.9.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- yoshoku
|
|
@@ -63,6 +63,36 @@ files:
|
|
|
63
63
|
- ext/numo/narray/numo/types/uint_macro.h
|
|
64
64
|
- ext/numo/narray/numo/types/xint_macro.h
|
|
65
65
|
- ext/numo/narray/rand.c
|
|
66
|
+
- ext/numo/narray/src/mh/math/acos.h
|
|
67
|
+
- ext/numo/narray/src/mh/math/acosh.h
|
|
68
|
+
- ext/numo/narray/src/mh/math/asin.h
|
|
69
|
+
- ext/numo/narray/src/mh/math/asinh.h
|
|
70
|
+
- ext/numo/narray/src/mh/math/atan.h
|
|
71
|
+
- ext/numo/narray/src/mh/math/atan2.h
|
|
72
|
+
- ext/numo/narray/src/mh/math/atanh.h
|
|
73
|
+
- ext/numo/narray/src/mh/math/cbrt.h
|
|
74
|
+
- ext/numo/narray/src/mh/math/cos.h
|
|
75
|
+
- ext/numo/narray/src/mh/math/cosh.h
|
|
76
|
+
- ext/numo/narray/src/mh/math/erf.h
|
|
77
|
+
- ext/numo/narray/src/mh/math/erfc.h
|
|
78
|
+
- ext/numo/narray/src/mh/math/exp.h
|
|
79
|
+
- ext/numo/narray/src/mh/math/exp10.h
|
|
80
|
+
- ext/numo/narray/src/mh/math/exp2.h
|
|
81
|
+
- ext/numo/narray/src/mh/math/expm1.h
|
|
82
|
+
- ext/numo/narray/src/mh/math/frexp.h
|
|
83
|
+
- ext/numo/narray/src/mh/math/hypot.h
|
|
84
|
+
- ext/numo/narray/src/mh/math/ldexp.h
|
|
85
|
+
- ext/numo/narray/src/mh/math/log.h
|
|
86
|
+
- ext/numo/narray/src/mh/math/log10.h
|
|
87
|
+
- ext/numo/narray/src/mh/math/log1p.h
|
|
88
|
+
- ext/numo/narray/src/mh/math/log2.h
|
|
89
|
+
- ext/numo/narray/src/mh/math/sin.h
|
|
90
|
+
- ext/numo/narray/src/mh/math/sinc.h
|
|
91
|
+
- ext/numo/narray/src/mh/math/sinh.h
|
|
92
|
+
- ext/numo/narray/src/mh/math/sqrt.h
|
|
93
|
+
- ext/numo/narray/src/mh/math/tan.h
|
|
94
|
+
- ext/numo/narray/src/mh/math/tanh.h
|
|
95
|
+
- ext/numo/narray/src/mh/math/unary_func.h
|
|
66
96
|
- ext/numo/narray/src/mh/mean.h
|
|
67
97
|
- ext/numo/narray/src/mh/rms.h
|
|
68
98
|
- ext/numo/narray/src/mh/stddev.h
|
|
@@ -93,7 +123,7 @@ metadata:
|
|
|
93
123
|
homepage_uri: https://github.com/yoshoku/numo-narray-alt
|
|
94
124
|
source_code_uri: https://github.com/yoshoku/numo-narray-alt
|
|
95
125
|
changelog_uri: https://github.com/yoshoku/numo-narray-alt/blob/main/CHANGELOG.md
|
|
96
|
-
documentation_uri: https://gemdocs.org/gems/numo-narray-alt/0.9.
|
|
126
|
+
documentation_uri: https://gemdocs.org/gems/numo-narray-alt/0.9.8/
|
|
97
127
|
rubygems_mfa_required: 'true'
|
|
98
128
|
rdoc_options: []
|
|
99
129
|
require_paths:
|
|
@@ -109,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
109
139
|
- !ruby/object:Gem::Version
|
|
110
140
|
version: '0'
|
|
111
141
|
requirements: []
|
|
112
|
-
rubygems_version: 3.
|
|
142
|
+
rubygems_version: 3.7.2
|
|
113
143
|
specification_version: 4
|
|
114
144
|
summary: Numo::NArray Alternative is an experimental project forked from Numo::NArray.
|
|
115
145
|
test_files: []
|