numo-narray-alt 0.9.6 → 0.9.7

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: 819274f9f9bc411b8276d69966bcba8aa94bc6d61f73920f653411729e4ef247
4
- data.tar.gz: c4ccb23dd013573cd80bd8ab73398fd1a67adf6018a8bd55eebff776a69df6d8
3
+ metadata.gz: ffcad1596b46a28e6ce8338ce16c2b047adaec57516e701aaca0f7b2ec4d0718
4
+ data.tar.gz: 402d148b66a7628720f66e60b0158dead80ae9abdc11bc3ac6aae38a6613d31a
5
5
  SHA512:
6
- metadata.gz: 35056f83d76f4c565f45b97ee8c9c992e6e3f3d77bd63b4ad7102d26631e4fbd82caaec87cb188bd2b23baf9785068923c6e54c441a6c188492526c848e2d0c0
7
- data.tar.gz: 78f1154e6e77b6d9848b5a8c1e8d5818b7daeb891f5f476950eff003d7045022f7f57b0518c51c192756bd9b140e5bef737236d168b9918fe2610365388ac2f4
6
+ metadata.gz: 59d49a385d2bc6dcd40d08ab3f812e33cc9cbd022e2e155d71ca17ec7ef780b5c59416618ac52f2b0fc2d3196bd331166a4613265b661b3705b7ff2ed49f50f5
7
+ data.tar.gz: 1e1bf70db42ee70e66aa4bfbbf2b1f5a1f76f3c06207919c5ce5d3dbadb2d28c276d9688325c33dbac9b9cbfe67d392c1ce394306c1ff5c64ea5b81ad44990de
data/README.md CHANGED
@@ -77,6 +77,13 @@ $ bundle exec rubocop
77
77
  $ clang-format --dry-run --Werror --style=file ext/**/*.h ext/**/*.c
78
78
  ```
79
79
 
80
+ This project follows [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).
81
+ Please run `npm install` to set up husky and commitlint for commit message validation:
82
+
83
+ ```shell
84
+ $ npm install
85
+ ```
86
+
80
87
  ## Contributing
81
88
 
82
89
  Bug reports and pull requests are welcome on GitHub at https://github.com/yoshoku/numo-narray-alt.
@@ -30,22 +30,14 @@
30
30
  #define ALTI_SR2_PERM64 \
31
31
  (vector unsigned char)(15, 0, 1, 2, 3, 4, 5, 6, 17, 8, 9, 10, 11, 12, 13, 14)
32
32
  #else /* For OTHER OSs(Linux?) */
33
- #define ALTI_SL1 \
34
- { SL1, SL1, SL1, SL1 }
35
- #define ALTI_SR1 \
36
- { SR1, SR1, SR1, SR1 }
37
- #define ALTI_MSK \
38
- { MSK1, MSK2, MSK3, MSK4 }
39
- #define ALTI_MSK64 \
40
- { MSK2, MSK1, MSK4, MSK3 }
41
- #define ALTI_SL2_PERM \
42
- { 1, 2, 3, 23, 5, 6, 7, 0, 9, 10, 11, 4, 13, 14, 15, 8 }
43
- #define ALTI_SL2_PERM64 \
44
- { 1, 2, 3, 4, 5, 6, 7, 31, 9, 10, 11, 12, 13, 14, 15, 0 }
45
- #define ALTI_SR2_PERM \
46
- { 7, 0, 1, 2, 11, 4, 5, 6, 15, 8, 9, 10, 17, 12, 13, 14 }
47
- #define ALTI_SR2_PERM64 \
48
- { 15, 0, 1, 2, 3, 4, 5, 6, 17, 8, 9, 10, 11, 12, 13, 14 }
33
+ #define ALTI_SL1 { SL1, SL1, SL1, SL1 }
34
+ #define ALTI_SR1 { SR1, SR1, SR1, SR1 }
35
+ #define ALTI_MSK { MSK1, MSK2, MSK3, MSK4 }
36
+ #define ALTI_MSK64 { MSK2, MSK1, MSK4, MSK3 }
37
+ #define ALTI_SL2_PERM { 1, 2, 3, 23, 5, 6, 7, 0, 9, 10, 11, 4, 13, 14, 15, 8 }
38
+ #define ALTI_SL2_PERM64 { 1, 2, 3, 4, 5, 6, 7, 31, 9, 10, 11, 12, 13, 14, 15, 0 }
39
+ #define ALTI_SR2_PERM { 7, 0, 1, 2, 11, 4, 5, 6, 15, 8, 9, 10, 17, 12, 13, 14 }
40
+ #define ALTI_SR2_PERM64 { 15, 0, 1, 2, 3, 4, 5, 6, 17, 8, 9, 10, 11, 12, 13, 14 }
49
41
  #endif /* For OSX */
50
42
  #define IDSTR "SFMT-19937:122-18-1-11-1:dfffffef-ddfecb7f-bffaffff-bffffff6"
51
43
 
@@ -13,8 +13,8 @@ extern "C" {
13
13
  #endif
14
14
  #endif
15
15
 
16
- #define NARRAY_VERSION "0.9.6"
17
- #define NARRAY_VERSION_CODE 960
16
+ #define NARRAY_VERSION "0.9.7"
17
+ #define NARRAY_VERSION_CODE 970
18
18
 
19
19
  #include <math.h>
20
20
  #include "numo/compat.h"
@@ -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.6
4
+ version: 0.9.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - yoshoku
@@ -93,7 +93,7 @@ metadata:
93
93
  homepage_uri: https://github.com/yoshoku/numo-narray-alt
94
94
  source_code_uri: https://github.com/yoshoku/numo-narray-alt
95
95
  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.6/
96
+ documentation_uri: https://gemdocs.org/gems/numo-narray-alt/0.9.7/
97
97
  rubygems_mfa_required: 'true'
98
98
  rdoc_options: []
99
99
  require_paths: