numo-narray-alt 0.9.3
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 +7 -0
- data/Gemfile +14 -0
- data/LICENSE +30 -0
- data/README.md +71 -0
- data/Rakefile +24 -0
- data/ext/numo/narray/SFMT-params.h +97 -0
- data/ext/numo/narray/SFMT-params19937.h +48 -0
- data/ext/numo/narray/SFMT.c +602 -0
- data/ext/numo/narray/SFMT.h +147 -0
- data/ext/numo/narray/array.c +575 -0
- data/ext/numo/narray/data.c +958 -0
- data/ext/numo/narray/extconf.rb +84 -0
- data/ext/numo/narray/index.c +1092 -0
- data/ext/numo/narray/kwargs.c +142 -0
- data/ext/numo/narray/math.c +133 -0
- data/ext/numo/narray/narray.c +1976 -0
- data/ext/numo/narray/narray.def +28 -0
- data/ext/numo/narray/ndloop.c +1840 -0
- data/ext/numo/narray/numo/compat.h +23 -0
- data/ext/numo/narray/numo/intern.h +115 -0
- data/ext/numo/narray/numo/narray.h +480 -0
- data/ext/numo/narray/numo/ndloop.h +93 -0
- data/ext/numo/narray/numo/template.h +149 -0
- data/ext/numo/narray/numo/types/bit.h +38 -0
- data/ext/numo/narray/numo/types/complex.h +404 -0
- data/ext/numo/narray/numo/types/complex_macro.h +384 -0
- data/ext/numo/narray/numo/types/dcomplex.h +42 -0
- data/ext/numo/narray/numo/types/dfloat.h +44 -0
- data/ext/numo/narray/numo/types/float_def.h +34 -0
- data/ext/numo/narray/numo/types/float_macro.h +202 -0
- data/ext/numo/narray/numo/types/int16.h +27 -0
- data/ext/numo/narray/numo/types/int32.h +23 -0
- data/ext/numo/narray/numo/types/int64.h +23 -0
- data/ext/numo/narray/numo/types/int8.h +23 -0
- data/ext/numo/narray/numo/types/int_macro.h +66 -0
- data/ext/numo/narray/numo/types/real_accum.h +481 -0
- data/ext/numo/narray/numo/types/robj_macro.h +78 -0
- data/ext/numo/narray/numo/types/robject.h +25 -0
- data/ext/numo/narray/numo/types/scomplex.h +42 -0
- data/ext/numo/narray/numo/types/sfloat.h +45 -0
- data/ext/numo/narray/numo/types/uint16.h +24 -0
- data/ext/numo/narray/numo/types/uint32.h +20 -0
- data/ext/numo/narray/numo/types/uint64.h +20 -0
- data/ext/numo/narray/numo/types/uint8.h +20 -0
- data/ext/numo/narray/numo/types/uint_macro.h +57 -0
- data/ext/numo/narray/numo/types/xint_macro.h +166 -0
- data/ext/numo/narray/rand.c +40 -0
- data/ext/numo/narray/src/t_bit.c +3236 -0
- data/ext/numo/narray/src/t_dcomplex.c +6776 -0
- data/ext/numo/narray/src/t_dfloat.c +9417 -0
- data/ext/numo/narray/src/t_int16.c +5757 -0
- data/ext/numo/narray/src/t_int32.c +5757 -0
- data/ext/numo/narray/src/t_int64.c +5759 -0
- data/ext/numo/narray/src/t_int8.c +5355 -0
- data/ext/numo/narray/src/t_robject.c +5567 -0
- data/ext/numo/narray/src/t_scomplex.c +6731 -0
- data/ext/numo/narray/src/t_sfloat.c +9374 -0
- data/ext/numo/narray/src/t_uint16.c +5753 -0
- data/ext/numo/narray/src/t_uint32.c +5753 -0
- data/ext/numo/narray/src/t_uint64.c +5755 -0
- data/ext/numo/narray/src/t_uint8.c +5351 -0
- data/ext/numo/narray/step.c +266 -0
- data/ext/numo/narray/struct.c +814 -0
- data/lib/numo/narray/extra.rb +1266 -0
- data/lib/numo/narray.rb +4 -0
- metadata +106 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 97dffa7f83cd2acb55f74fead971a6d0d76bdf70b9c1aa17f3e1799bd80cd3cf
|
4
|
+
data.tar.gz: 1bc2bb54d66c86942cffefa80e5ba6bc930453a8b1d4bf6f7925cf82d3964e2a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d5be63d5efb393e5a9830aca9557b0c3433ff9b8ded112447e7f05d1f71da1d8342032316c3697afc640882d00a094fa25d2d8a15cc2e5e6131c4125b7e40a74
|
7
|
+
data.tar.gz: 11f664a3464b58d9ea29e7c34f34b4e03d1280c8f2228546bba3d9420571c6769e3161f6b969d5f04117fa7079308208a1bec0f573c85ae24b91a7864182770f
|
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in narray-devel.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem 'rake', '~> 13.3'
|
9
|
+
gem 'rake-compiler', '~> 1.3'
|
10
|
+
gem 'rubocop', '~> 1.80'
|
11
|
+
gem 'rubocop-performance', '~> 1.26'
|
12
|
+
gem 'rubocop-rake', '~> 0.7.1'
|
13
|
+
gem 'simplecov', '~> 0.22.0'
|
14
|
+
gem 'test-unit', '~> 3.7'
|
data/LICENSE
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
BSD 3-Clause License
|
2
|
+
|
3
|
+
Copyright (c) 1999-2025, Masahiro TANAKA
|
4
|
+
Copyright (c) 2025, Atsushi TATSUMA
|
5
|
+
All rights reserved.
|
6
|
+
|
7
|
+
Redistribution and use in source and binary forms, with or without
|
8
|
+
modification, are permitted provided that the following conditions are met:
|
9
|
+
|
10
|
+
* Redistributions of source code must retain the above copyright notice, this
|
11
|
+
list of conditions and the following disclaimer.
|
12
|
+
|
13
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
14
|
+
this list of conditions and the following disclaimer in the documentation
|
15
|
+
and/or other materials provided with the distribution.
|
16
|
+
|
17
|
+
* Neither the name of the copyright holder nor the names of its
|
18
|
+
contributors may be used to endorse or promote products derived from
|
19
|
+
this software without specific prior written permission.
|
20
|
+
|
21
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
22
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
23
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
24
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
25
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
26
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
27
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
28
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
29
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
30
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# Numo::NArray Alternative
|
2
|
+
|
3
|
+
Numo::NArray Alternative is an experimental project forked from [Numo::NArray](https://github.com/ruby-numo/numo-narray).
|
4
|
+
Its goal is to adopt more modern Ruby features and development practices.
|
5
|
+
The project owner is also the developer of [Rumale](https://github.com/yoshoku/rumale), a machine learning library,
|
6
|
+
and may add new features to this project to support the needs of Rumale.
|
7
|
+
In addition, since Rumale depends on Numo::NArray, namespaces, class names, and method names will be kept unchanged
|
8
|
+
to allow this library to be used as a drop-in replacement.
|
9
|
+
|
10
|
+
The project owner has the utmost respect for Numo::NArray and its creator, Prof. Masahiro Tanaka.
|
11
|
+
This project is in no way intended to adversely affect the development of the original Numo::NArray.
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
```shell
|
16
|
+
$ gem install numo-narray-alt
|
17
|
+
```
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
The same as Numo::NArray.
|
22
|
+
|
23
|
+
```irb
|
24
|
+
irb(main):001> require 'numo/narray'
|
25
|
+
=> true
|
26
|
+
irb(main):002> x = Numo::DFloat[[1, 2, 3], [4, 5, 6]]
|
27
|
+
=>
|
28
|
+
Numo::DFloat#shape=[2,3]
|
29
|
+
...
|
30
|
+
irb(main):003> x.dot(x.transpose)
|
31
|
+
=>
|
32
|
+
Numo::DFloat#shape=[2,2]
|
33
|
+
[[14, 32],
|
34
|
+
[32, 77]]
|
35
|
+
irb(main):004>
|
36
|
+
```
|
37
|
+
|
38
|
+
## Development
|
39
|
+
|
40
|
+
preparation:
|
41
|
+
|
42
|
+
```shell
|
43
|
+
$ git clone https://github.com/yoshoku/numo-narray-alt
|
44
|
+
$ cd numo-narray-alt
|
45
|
+
$ bundle install
|
46
|
+
```
|
47
|
+
|
48
|
+
build and test:
|
49
|
+
|
50
|
+
```
|
51
|
+
$ bundle exec rake compile
|
52
|
+
$ bundle exec rake test
|
53
|
+
```
|
54
|
+
|
55
|
+
linter:
|
56
|
+
|
57
|
+
```shell
|
58
|
+
$ bundle exec rubocop
|
59
|
+
$ clang-format --dry-run --Werror --style=file ext/**/*.h ext/**/*.c
|
60
|
+
```
|
61
|
+
|
62
|
+
## Contributing
|
63
|
+
|
64
|
+
This project is in an early experimental stage.
|
65
|
+
Therefore, we are not accepting any Issues or Pull Requests at this time.
|
66
|
+
Thank you for your understanding.
|
67
|
+
|
68
|
+
## License
|
69
|
+
|
70
|
+
This project was originally forked from [Numo::NArray](https://github.com/ruby-numo/numo-narray).
|
71
|
+
It continues to be licensed under the [BSD-3-Clause License](https://github.com/yoshoku/numo-narray-alt/blob/main/LICENSE).
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
|
5
|
+
task :doc do
|
6
|
+
dir = 'ext/numo/narray'
|
7
|
+
src = %w[array.c data.c index.c math.c narray.c rand.c struct.c]
|
8
|
+
.map { |s| File.join(dir, s) } +
|
9
|
+
[File.join(dir, 't_*.c'), 'lib/numo/narray/extra.rb']
|
10
|
+
sh 'cd ext/numo/narray; ruby extconf.rb; make src'
|
11
|
+
sh "rm -rf yard .yardoc; yard doc -o yard -m markdown -r README.md #{src.join(' ')}"
|
12
|
+
end
|
13
|
+
|
14
|
+
require 'rake/testtask'
|
15
|
+
Rake::TestTask.new(:test) do |t|
|
16
|
+
t.libs << 'test'
|
17
|
+
t.libs << 'lib'
|
18
|
+
t.verbose = false
|
19
|
+
t.warning = false
|
20
|
+
t.test_files = FileList['test/**/*_test.rb']
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'rake/extensiontask'
|
24
|
+
Rake::ExtensionTask.new('numo/narray')
|
@@ -0,0 +1,97 @@
|
|
1
|
+
#ifndef SFMT_PARAMS_H
|
2
|
+
#define SFMT_PARAMS_H
|
3
|
+
|
4
|
+
#if !defined(MEXP)
|
5
|
+
// #ifdef __GNUC__
|
6
|
+
// #warning "MEXP is not defined. I assume MEXP is 19937."
|
7
|
+
// #endif
|
8
|
+
#define MEXP 19937
|
9
|
+
#endif
|
10
|
+
/*-----------------
|
11
|
+
BASIC DEFINITIONS
|
12
|
+
-----------------*/
|
13
|
+
/** Mersenne Exponent. The period of the sequence
|
14
|
+
* is a multiple of 2^MEXP-1.
|
15
|
+
* #define MEXP 19937 */
|
16
|
+
/** SFMT generator has an internal state array of 128-bit integers,
|
17
|
+
* and N is its size. */
|
18
|
+
#define N (MEXP / 128 + 1)
|
19
|
+
/** N32 is the size of internal state array when regarded as an array
|
20
|
+
* of 32-bit integers.*/
|
21
|
+
#define N32 (N * 4)
|
22
|
+
/** N64 is the size of internal state array when regarded as an array
|
23
|
+
* of 64-bit integers.*/
|
24
|
+
#define N64 (N * 2)
|
25
|
+
|
26
|
+
/*----------------------
|
27
|
+
the parameters of SFMT
|
28
|
+
following definitions are in paramsXXXX.h file.
|
29
|
+
----------------------*/
|
30
|
+
/** the pick up position of the array.
|
31
|
+
#define POS1 122
|
32
|
+
*/
|
33
|
+
|
34
|
+
/** the parameter of shift left as four 32-bit registers.
|
35
|
+
#define SL1 18
|
36
|
+
*/
|
37
|
+
|
38
|
+
/** the parameter of shift left as one 128-bit register.
|
39
|
+
* The 128-bit integer is shifted by (SL2 * 8) bits.
|
40
|
+
#define SL2 1
|
41
|
+
*/
|
42
|
+
|
43
|
+
/** the parameter of shift right as four 32-bit registers.
|
44
|
+
#define SR1 11
|
45
|
+
*/
|
46
|
+
|
47
|
+
/** the parameter of shift right as one 128-bit register.
|
48
|
+
* The 128-bit integer is shifted by (SL2 * 8) bits.
|
49
|
+
#define SR2 1
|
50
|
+
*/
|
51
|
+
|
52
|
+
/** A bitmask, used in the recursion. These parameters are introduced
|
53
|
+
* to break symmetry of SIMD.
|
54
|
+
#define MSK1 0xdfffffefU
|
55
|
+
#define MSK2 0xddfecb7fU
|
56
|
+
#define MSK3 0xbffaffffU
|
57
|
+
#define MSK4 0xbffffff6U
|
58
|
+
*/
|
59
|
+
|
60
|
+
/** These definitions are part of a 128-bit period certification vector.
|
61
|
+
#define PARITY1 0x00000001U
|
62
|
+
#define PARITY2 0x00000000U
|
63
|
+
#define PARITY3 0x00000000U
|
64
|
+
#define PARITY4 0xc98e126aU
|
65
|
+
*/
|
66
|
+
|
67
|
+
#if MEXP == 607
|
68
|
+
#include "SFMT-params607.h"
|
69
|
+
#elif MEXP == 1279
|
70
|
+
#include "SFMT-params1279.h"
|
71
|
+
#elif MEXP == 2281
|
72
|
+
#include "SFMT-params2281.h"
|
73
|
+
#elif MEXP == 4253
|
74
|
+
#include "SFMT-params4253.h"
|
75
|
+
#elif MEXP == 11213
|
76
|
+
#include "SFMT-params11213.h"
|
77
|
+
#elif MEXP == 19937
|
78
|
+
#include "SFMT-params19937.h"
|
79
|
+
#elif MEXP == 44497
|
80
|
+
#include "SFMT-params44497.h"
|
81
|
+
#elif MEXP == 86243
|
82
|
+
#include "SFMT-params86243.h"
|
83
|
+
#elif MEXP == 132049
|
84
|
+
#include "SFMT-params132049.h"
|
85
|
+
#elif MEXP == 216091
|
86
|
+
#include "SFMT-params216091.h"
|
87
|
+
#else
|
88
|
+
#ifdef __GNUC__
|
89
|
+
#error "MEXP is not valid."
|
90
|
+
#undef MEXP
|
91
|
+
#else
|
92
|
+
#undef MEXP
|
93
|
+
#endif
|
94
|
+
|
95
|
+
#endif
|
96
|
+
|
97
|
+
#endif /* SFMT_PARAMS_H */
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#ifndef SFMT_PARAMS19937_H
|
2
|
+
#define SFMT_PARAMS19937_H
|
3
|
+
|
4
|
+
#define POS1 122
|
5
|
+
#define SL1 18
|
6
|
+
#define SL2 1
|
7
|
+
#define SR1 11
|
8
|
+
#define SR2 1
|
9
|
+
#define MSK1 0xdfffffefU
|
10
|
+
#define MSK2 0xddfecb7fU
|
11
|
+
#define MSK3 0xbffaffffU
|
12
|
+
#define MSK4 0xbffffff6U
|
13
|
+
#define PARITY1 0x00000001U
|
14
|
+
#define PARITY2 0x00000000U
|
15
|
+
#define PARITY3 0x00000000U
|
16
|
+
#define PARITY4 0x13c9e684U
|
17
|
+
|
18
|
+
/* PARAMETERS FOR ALTIVEC */
|
19
|
+
#if defined(__APPLE__) /* For OSX */
|
20
|
+
#define ALTI_SL1 (vector unsigned int)(SL1, SL1, SL1, SL1)
|
21
|
+
#define ALTI_SR1 (vector unsigned int)(SR1, SR1, SR1, SR1)
|
22
|
+
#define ALTI_MSK (vector unsigned int)(MSK1, MSK2, MSK3, MSK4)
|
23
|
+
#define ALTI_MSK64 (vector unsigned int)(MSK2, MSK1, MSK4, MSK3)
|
24
|
+
#define ALTI_SL2_PERM (vector unsigned char)(1, 2, 3, 23, 5, 6, 7, 0, 9, 10, 11, 4, 13, 14, 15, 8)
|
25
|
+
#define ALTI_SL2_PERM64 (vector unsigned char)(1, 2, 3, 4, 5, 6, 7, 31, 9, 10, 11, 12, 13, 14, 15, 0)
|
26
|
+
#define ALTI_SR2_PERM (vector unsigned char)(7, 0, 1, 2, 11, 4, 5, 6, 15, 8, 9, 10, 17, 12, 13, 14)
|
27
|
+
#define ALTI_SR2_PERM64 (vector unsigned char)(15, 0, 1, 2, 3, 4, 5, 6, 17, 8, 9, 10, 11, 12, 13, 14)
|
28
|
+
#else /* For OTHER OSs(Linux?) */
|
29
|
+
#define ALTI_SL1 \
|
30
|
+
{ SL1, SL1, SL1, SL1 }
|
31
|
+
#define ALTI_SR1 \
|
32
|
+
{ SR1, SR1, SR1, SR1 }
|
33
|
+
#define ALTI_MSK \
|
34
|
+
{ MSK1, MSK2, MSK3, MSK4 }
|
35
|
+
#define ALTI_MSK64 \
|
36
|
+
{ MSK2, MSK1, MSK4, MSK3 }
|
37
|
+
#define ALTI_SL2_PERM \
|
38
|
+
{ 1, 2, 3, 23, 5, 6, 7, 0, 9, 10, 11, 4, 13, 14, 15, 8 }
|
39
|
+
#define ALTI_SL2_PERM64 \
|
40
|
+
{ 1, 2, 3, 4, 5, 6, 7, 31, 9, 10, 11, 12, 13, 14, 15, 0 }
|
41
|
+
#define ALTI_SR2_PERM \
|
42
|
+
{ 7, 0, 1, 2, 11, 4, 5, 6, 15, 8, 9, 10, 17, 12, 13, 14 }
|
43
|
+
#define ALTI_SR2_PERM64 \
|
44
|
+
{ 15, 0, 1, 2, 3, 4, 5, 6, 17, 8, 9, 10, 11, 12, 13, 14 }
|
45
|
+
#endif /* For OSX */
|
46
|
+
#define IDSTR "SFMT-19937:122-18-1-11-1:dfffffef-ddfecb7f-bffaffff-bffffff6"
|
47
|
+
|
48
|
+
#endif /* SFMT_PARAMS19937_H */
|