numo-liblinear 1.2.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/LICENSE.txt +1 -1
  4. data/README.md +0 -5
  5. data/ext/numo/liblinear/extconf.rb +8 -14
  6. data/ext/numo/liblinear/liblinearext.cpp +215 -0
  7. data/ext/numo/liblinear/liblinearext.hpp +636 -0
  8. data/ext/numo/liblinear/src/COPYRIGHT +31 -0
  9. data/ext/numo/liblinear/{liblinear → src}/blas/blas.h +0 -0
  10. data/ext/numo/liblinear/{liblinear → src}/blas/blasp.h +0 -0
  11. data/ext/numo/liblinear/{liblinear → src}/blas/daxpy.c +0 -0
  12. data/ext/numo/liblinear/{liblinear → src}/blas/ddot.c +0 -0
  13. data/ext/numo/liblinear/{liblinear → src}/blas/dnrm2.c +0 -0
  14. data/ext/numo/liblinear/{liblinear → src}/blas/dscal.c +0 -0
  15. data/ext/numo/liblinear/{liblinear → src}/linear.cpp +0 -0
  16. data/ext/numo/liblinear/{liblinear → src}/linear.h +0 -0
  17. data/ext/numo/liblinear/{liblinear → src}/newton.cpp +0 -0
  18. data/ext/numo/liblinear/{liblinear → src}/newton.h +0 -0
  19. data/lib/numo/liblinear/version.rb +1 -1
  20. metadata +19 -37
  21. data/.github/workflows/build.yml +0 -29
  22. data/.gitignore +0 -20
  23. data/.gitmodules +0 -3
  24. data/.rspec +0 -3
  25. data/CODE_OF_CONDUCT.md +0 -74
  26. data/Gemfile +0 -11
  27. data/Rakefile +0 -15
  28. data/Steepfile +0 -20
  29. data/ext/numo/liblinear/converter.c +0 -133
  30. data/ext/numo/liblinear/converter.h +0 -18
  31. data/ext/numo/liblinear/liblinearext.c +0 -576
  32. data/ext/numo/liblinear/liblinearext.h +0 -17
  33. data/ext/numo/liblinear/model.c +0 -48
  34. data/ext/numo/liblinear/model.h +0 -15
  35. data/ext/numo/liblinear/parameter.c +0 -105
  36. data/ext/numo/liblinear/parameter.h +0 -15
  37. data/ext/numo/liblinear/problem.c +0 -92
  38. data/ext/numo/liblinear/problem.h +0 -12
  39. data/ext/numo/liblinear/solver_type.c +0 -36
  40. data/ext/numo/liblinear/solver_type.h +0 -9
  41. data/numo-liblinear.gemspec +0 -47
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: numo-liblinear
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - yoshoku
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-10 00:00:00.000000000 Z
11
+ date: 2022-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: numo-narray
@@ -35,43 +35,25 @@ extensions:
35
35
  - ext/numo/liblinear/extconf.rb
36
36
  extra_rdoc_files: []
37
37
  files:
38
- - ".github/workflows/build.yml"
39
- - ".gitignore"
40
- - ".gitmodules"
41
- - ".rspec"
42
38
  - CHANGELOG.md
43
- - CODE_OF_CONDUCT.md
44
- - Gemfile
45
39
  - LICENSE.txt
46
40
  - README.md
47
- - Rakefile
48
- - Steepfile
49
- - ext/numo/liblinear/converter.c
50
- - ext/numo/liblinear/converter.h
51
41
  - ext/numo/liblinear/extconf.rb
52
- - ext/numo/liblinear/liblinear/blas/blas.h
53
- - ext/numo/liblinear/liblinear/blas/blasp.h
54
- - ext/numo/liblinear/liblinear/blas/daxpy.c
55
- - ext/numo/liblinear/liblinear/blas/ddot.c
56
- - ext/numo/liblinear/liblinear/blas/dnrm2.c
57
- - ext/numo/liblinear/liblinear/blas/dscal.c
58
- - ext/numo/liblinear/liblinear/linear.cpp
59
- - ext/numo/liblinear/liblinear/linear.h
60
- - ext/numo/liblinear/liblinear/newton.cpp
61
- - ext/numo/liblinear/liblinear/newton.h
62
- - ext/numo/liblinear/liblinearext.c
63
- - ext/numo/liblinear/liblinearext.h
64
- - ext/numo/liblinear/model.c
65
- - ext/numo/liblinear/model.h
66
- - ext/numo/liblinear/parameter.c
67
- - ext/numo/liblinear/parameter.h
68
- - ext/numo/liblinear/problem.c
69
- - ext/numo/liblinear/problem.h
70
- - ext/numo/liblinear/solver_type.c
71
- - ext/numo/liblinear/solver_type.h
42
+ - ext/numo/liblinear/liblinearext.cpp
43
+ - ext/numo/liblinear/liblinearext.hpp
44
+ - ext/numo/liblinear/src/COPYRIGHT
45
+ - ext/numo/liblinear/src/blas/blas.h
46
+ - ext/numo/liblinear/src/blas/blasp.h
47
+ - ext/numo/liblinear/src/blas/daxpy.c
48
+ - ext/numo/liblinear/src/blas/ddot.c
49
+ - ext/numo/liblinear/src/blas/dnrm2.c
50
+ - ext/numo/liblinear/src/blas/dscal.c
51
+ - ext/numo/liblinear/src/linear.cpp
52
+ - ext/numo/liblinear/src/linear.h
53
+ - ext/numo/liblinear/src/newton.cpp
54
+ - ext/numo/liblinear/src/newton.h
72
55
  - lib/numo/liblinear.rb
73
56
  - lib/numo/liblinear/version.rb
74
- - numo-liblinear.gemspec
75
57
  - sig/numo/liblinear.rbs
76
58
  homepage: https://github.com/yoshoku/numo-liblinear
77
59
  licenses:
@@ -80,7 +62,7 @@ metadata:
80
62
  homepage_uri: https://github.com/yoshoku/numo-liblinear
81
63
  source_code_uri: https://github.com/yoshoku/numo-liblinear
82
64
  documentation_uri: https://yoshoku.github.io/numo-liblinear/doc/
83
- post_install_message:
65
+ post_install_message:
84
66
  rdoc_options: []
85
67
  require_paths:
86
68
  - lib
@@ -95,8 +77,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
77
  - !ruby/object:Gem::Version
96
78
  version: '0'
97
79
  requirements: []
98
- rubygems_version: 3.2.21
99
- signing_key:
80
+ rubygems_version: 3.3.3
81
+ signing_key:
100
82
  specification_version: 4
101
83
  summary: Numo::Liblinear is a Ruby gem binding to the LIBLINEAR library. Numo::Liblinear
102
84
  makes to use the LIBLINEAR functions with dataset represented by Numo::NArray.
@@ -1,29 +0,0 @@
1
- name: build
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- build:
7
- runs-on: ubuntu-latest
8
- strategy:
9
- fail-fast: false
10
- matrix:
11
- ruby: [ '2.6', '2.7', '3.0' ]
12
- steps:
13
- - uses: actions/checkout@v2
14
- - name: Checkout submodule
15
- shell: bash
16
- run: |
17
- auth_header="$(git config --local --get http.https://github.com/.extraheader)"
18
- git submodule sync --recursive
19
- git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
20
- - name: Set up Ruby ${{ matrix.ruby }}
21
- uses: ruby/setup-ruby@v1
22
- with:
23
- ruby-version: ${{ matrix.ruby }}
24
- bundler-cache: true
25
- - name: Build and test with Rake
26
- run: |
27
- gem install --no-document bundler
28
- bundle install --jobs 4 --retry 3
29
- bundle exec rake
data/.gitignore DELETED
@@ -1,20 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- /bin/
11
-
12
- # rspec failure tracking
13
- .rspec_status
14
-
15
- *.swp
16
- *.bundle
17
- mkmf.log
18
- tags
19
- .DS_Store
20
- .ruby-version
data/.gitmodules DELETED
@@ -1,3 +0,0 @@
1
- [submodule "ext/numo/liblinear/liblinear"]
2
- path = ext/numo/liblinear/liblinear
3
- url = https://github.com/cjlin1/liblinear
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/CODE_OF_CONDUCT.md DELETED
@@ -1,74 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at yoshoku@outlook.com. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [http://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: http://contributor-covenant.org
74
- [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile DELETED
@@ -1,11 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in numo-liblinear.gemspec
4
- gemspec
5
-
6
- gem 'bundler', '~> 2.0'
7
- gem 'rake', '~> 13.0'
8
- gem 'rake-compiler', '~> 1.0'
9
- gem 'rspec', '~> 3.0'
10
- gem 'rbs', '~> 1.2'
11
- gem 'steep', '~> 0.44'
data/Rakefile DELETED
@@ -1,15 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- require 'rake/extensiontask'
7
-
8
- task :build => :compile
9
-
10
- Rake::ExtensionTask.new('liblinearext') do |ext|
11
- ext.ext_dir = 'ext/numo/liblinear'
12
- ext.lib_dir = 'lib/numo/liblinear'
13
- end
14
-
15
- task :default => [:clobber, :compile, :spec]
data/Steepfile DELETED
@@ -1,20 +0,0 @@
1
- target :lib do
2
- signature "sig", "sig-deps"
3
- #
4
- check "lib" # Directory name
5
- # check "Gemfile" # File name
6
- # check "app/models/**/*.rb" # Glob
7
- # # ignore "lib/templates/*.rb"
8
- #
9
- # # library "pathname", "set" # Standard libraries
10
- # library "numo-narray" # Gems
11
- end
12
-
13
- # target :spec do
14
- # signature "sig", "sig-private"
15
- #
16
- # check "spec"
17
- #
18
- # # library "pathname", "set" # Standard libraries
19
- # # library "rspec"
20
- # end
@@ -1,133 +0,0 @@
1
- #include "converter.h"
2
-
3
- VALUE int_vec_to_nary(int* const arr, int const size)
4
- {
5
- int i;
6
- size_t shape[1] = { size };
7
- VALUE v = rb_narray_new(numo_cInt32, 1, shape);
8
- int32_t* vp = (int32_t*)na_get_pointer_for_write(v);
9
- for (i = 0; i < size; i++) { vp[i] = (int32_t)arr[i]; }
10
- return v;
11
- }
12
-
13
- int* nary_to_int_vec(VALUE vec_val)
14
- {
15
- int i;
16
- int n_elements;
17
- narray_t* vec_nary;
18
- int32_t* vec_pt;
19
- int* vec;
20
-
21
- if (vec_val == Qnil) return NULL;
22
-
23
- GetNArray(vec_val, vec_nary);
24
- n_elements = (int)NA_SHAPE(vec_nary)[0];
25
-
26
- vec = ALLOC_N(int, n_elements);
27
- vec_pt = (int32_t*)na_get_pointer_for_read(vec_val);
28
- for (i = 0; i < n_elements; i++) { vec[i] = (int)vec_pt[i]; }
29
-
30
- RB_GC_GUARD(vec_val);
31
-
32
- return vec;
33
- }
34
-
35
- VALUE dbl_vec_to_nary(double* const arr, int const size)
36
- {
37
- int i;
38
- size_t shape[1] = { size };
39
- VALUE v = rb_narray_new(numo_cDFloat, 1, shape);
40
- double* vp = (double*)na_get_pointer_for_write(v);
41
- for (i = 0; i < size; i++) { vp[i] = arr[i]; }
42
- return v;
43
- }
44
-
45
- double* nary_to_dbl_vec(VALUE vec_val)
46
- {
47
- int n_elements;
48
- narray_t* vec_nary;
49
- double* vec_pt;
50
- double* vec;
51
-
52
- if (vec_val == Qnil) return NULL;
53
-
54
- GetNArray(vec_val, vec_nary);
55
- n_elements = (int)NA_SHAPE(vec_nary)[0];
56
-
57
- vec = ALLOC_N(double, n_elements);
58
- vec_pt = (double*)na_get_pointer_for_read(vec_val);
59
- memcpy(vec, vec_pt, n_elements * sizeof(double));
60
-
61
- RB_GC_GUARD(vec_val);
62
-
63
- return vec;
64
- }
65
-
66
- VALUE dbl_mat_to_nary(double** const mat, int const n_rows, int const n_cols)
67
- {
68
- int i, j;
69
- size_t shape[2] = { n_rows, n_cols };
70
- VALUE v = rb_narray_new(numo_cDFloat, 2, shape);
71
- double* vp = (double*)na_get_pointer_for_write(v);
72
-
73
- for (i = 0; i < n_rows; i++) {
74
- for (j = 0; j < n_cols; j++) {
75
- vp[i * n_cols + j] = mat[i][j];
76
- }
77
- }
78
-
79
- return v;
80
- }
81
-
82
- double** nary_to_dbl_mat(VALUE mat_val)
83
- {
84
- int i, j;
85
- int n_rows, n_cols;
86
- narray_t* mat_nary;
87
- double* mat_pt;
88
- double** mat;
89
-
90
- if (mat_val == Qnil) return NULL;
91
-
92
- GetNArray(mat_val, mat_nary);
93
- n_rows = (int)NA_SHAPE(mat_nary)[0];
94
- n_cols = (int)NA_SHAPE(mat_nary)[1];
95
-
96
- mat_pt = (double*)na_get_pointer_for_read(mat_val);
97
- mat = ALLOC_N(double*, n_rows);
98
- for (i = 0; i < n_rows; i++) {
99
- mat[i] = ALLOC_N(double, n_cols);
100
- for (j = 0; j < n_cols; j++) {
101
- mat[i][j] = mat_pt[i * n_cols + j];
102
- }
103
- }
104
-
105
- RB_GC_GUARD(mat_val);
106
-
107
- return mat;
108
- }
109
-
110
- struct feature_node* dbl_vec_to_node(double* const arr, int const size)
111
- {
112
- int i, j;
113
- int n_nonzero_elements;
114
- struct feature_node* node;
115
-
116
- n_nonzero_elements = 0;
117
- for (i = 0; i < size; i++) {
118
- if (arr[i] != 0.0) n_nonzero_elements++;
119
- }
120
-
121
- node = ALLOC_N(struct feature_node, n_nonzero_elements + 1);
122
- for (i = 0, j = 0; i < size; i++) {
123
- if (arr[i] != 0.0) {
124
- node[j].index = i + 1;
125
- node[j].value = arr[i];
126
- j++;
127
- }
128
- }
129
- node[n_nonzero_elements].index = -1;
130
- node[n_nonzero_elements].value = 0.0;
131
-
132
- return node;
133
- }
@@ -1,18 +0,0 @@
1
- #ifndef NUMO_LIBLINEAR_CONVERTER_H
2
- #define NUMO_LIBLINEAR_CONVERTER_H 1
3
-
4
- #include <string.h>
5
- #include <ruby.h>
6
- #include <linear.h>
7
- #include <numo/narray.h>
8
- #include <numo/template.h>
9
-
10
- VALUE int_vec_to_nary(int* const arr, int const size);
11
- int* nary_to_int_vec(VALUE vec_val);
12
- VALUE dbl_vec_to_nary(double* const arr, int const size);
13
- double* nary_to_dbl_vec(VALUE vec_val);
14
- VALUE dbl_mat_to_nary(double** const mat, int const n_rows, int const n_cols);
15
- double** nary_to_dbl_mat(VALUE mat_val);
16
- struct feature_node* dbl_vec_to_node(double* const arr, int const size);
17
-
18
- #endif /* NUMO_LIBLINEAR_CONVERTER_H */