numo-libsvm 2.2.0 → 3.0.0

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: 1e4eb5d7c2a7e1bde6c1987e2f235d66954715d13c894b732f45686c944f632b
4
- data.tar.gz: 1a2839e141f0160328aaae9cbd7e2b85f4bf500f880dbbc94599c2568fb04e27
3
+ metadata.gz: 10d7ba229178a10bee36cd31ffd005984fa007b5f63dbd4b282b300f3820f02f
4
+ data.tar.gz: 713c171d6bd151846b31e27a586db5db0b70f7bb98cfda4c08da39a044056260
5
5
  SHA512:
6
- metadata.gz: 7f115624dc61595a4bc6298c055e4a0a3bbecd12aad2645b8c2869fd62d036f0d874a6884ec351b589f4acb315ff09d58dc6e4a0df71cd992bc9cf8d96e07ab8
7
- data.tar.gz: cd04639c40579d3f1aa2ba88ddf62e1510cd7d1b7f224acd04866eaf075bede38063ecb84b018cc3f0bcd7831f6a5c26149f8221abbe31b6d50d4e06a24268ef
6
+ metadata.gz: 69fb57aedba1d02c522d42504be52bea1540973f33af4ef06e4310bca9be75ab954ec7f77c0c565f0b5c3e82fa74469848fb2c74a9c5dbb500fc003d54445e76
7
+ data.tar.gz: 99abcc664b6f62d7ebf9993e8c3ee2a97ca3546407c97184d115c806b79671fc16d4db2c7675caaf11cb8fe39edca8c4ec5405f0d834e1f697282dab3f1248d0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ # [[3.0.0](https://github.com/yoshoku/numo-libsvm/compare/v2.3.0...v3.0.0)] - 2025-10-01
2
+
3
+ **Breaking chage**
4
+
5
+ - Change dependency from numo-narray to [numo-narray-alt](https://github.com/yoshoku/numo-narray-alt).
6
+
7
+ # 2.3.0
8
+ - Update bundled LIBSVM to 3.35.
9
+
1
10
  # 2.2.0
2
11
  - Update bundled LIBSVM to 3.31.
3
12
 
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2019-2023 Atsushi Tatsuma
1
+ Copyright (c) 2019-2025 Atsushi Tatsuma
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without
data/README.md CHANGED
@@ -15,6 +15,8 @@ Note: There are other useful Ruby gems binding to LIBSVM:
15
15
  [libsvm-ruby-swig](https://github.com/tomz/libsvm-ruby-swig) by Tom Zeng,
16
16
  and [jrb-libsvm](https://github.com/andreaseger/jrb-libsvm) by Andreas Eger.
17
17
 
18
+ Note: Since v3.0.0, this library uses [Numo::NArray Alternative](https://github.com/yoshoku/numo-narray-alt) instead of Numo::NArray as a dependency.
19
+
18
20
  ## Installation
19
21
  Numo::Libsvm bundles LIBSVM. There is no need to install LIBSVM in advance.
20
22
 
@@ -26,7 +26,18 @@ if RUBY_PLATFORM.match?(/darwin/) && Gem::Version.new('3.1.0') <= Gem::Version.n
26
26
  end
27
27
  end
28
28
 
29
- abort 'libstdc++ is not found.' unless have_library('stdc++')
29
+ have_libcpp = false
30
+ if RUBY_PLATFORM.include?('darwin')
31
+ if have_library('c++')
32
+ have_libcpp = true
33
+ else
34
+ warn 'libc++ is not found.'
35
+ end
36
+ end
37
+
38
+ if !have_libcpp && !RUBY_PLATFORM.include?('mswin')
39
+ warn 'libstdc++ is not found.' unless have_library('stdc++')
40
+ end
30
41
 
31
42
  $srcs = Dir.glob("#{$srcdir}/**/*.cpp").map { |path| File.basename(path) }
32
43
  $INCFLAGS << " -I$(srcdir)/src"
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2019-2023 Atsushi Tatsuma
2
+ * Copyright (c) 2019-2024 Atsushi Tatsuma
3
3
  * All rights reserved.
4
4
  *
5
5
  * Redistribution and use in source and binary forms, with or without
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2019-2023 Atsushi Tatsuma
2
+ * Copyright (c) 2019-2024 Atsushi Tatsuma
3
3
  * All rights reserved.
4
4
  *
5
5
  * Redistribution and use in source and binary forms, with or without
@@ -54,7 +54,7 @@ static void info(const char *fmt,...)
54
54
  char buf[BUFSIZ];
55
55
  va_list ap;
56
56
  va_start(ap,fmt);
57
- vsprintf(buf,fmt,ap);
57
+ vsnprintf(buf,BUFSIZ,fmt,ap);
58
58
  va_end(ap);
59
59
  (*svm_print_string)(buf);
60
60
  }
@@ -71,7 +71,7 @@ static void info(const char *fmt,...) {}
71
71
  class Cache
72
72
  {
73
73
  public:
74
- Cache(int l,long int size);
74
+ Cache(int l,size_t size);
75
75
  ~Cache();
76
76
 
77
77
  // request data [0,len)
@@ -81,7 +81,7 @@ public:
81
81
  void swap_index(int i, int j);
82
82
  private:
83
83
  int l;
84
- long int size;
84
+ size_t size;
85
85
  struct head_t
86
86
  {
87
87
  head_t *prev, *next; // a circular list
@@ -95,12 +95,12 @@ private:
95
95
  void lru_insert(head_t *h);
96
96
  };
97
97
 
98
- Cache::Cache(int l_,long int size_):l(l_),size(size_)
98
+ Cache::Cache(int l_,size_t size_):l(l_),size(size_)
99
99
  {
100
100
  head = (head_t *)calloc(l,sizeof(head_t)); // initialized to 0
101
101
  size /= sizeof(Qfloat);
102
- size -= l * sizeof(head_t) / sizeof(Qfloat);
103
- size = max(size, 2 * (long int) l); // cache must be large enough for two columns
102
+ size_t header_size = l * sizeof(head_t) / sizeof(Qfloat);
103
+ size = max(size, 2 * (size_t) l + header_size) - header_size; // cache must be large enough for two columns
104
104
  lru_head.next = lru_head.prev = &lru_head;
105
105
  }
106
106
 
@@ -136,7 +136,7 @@ int Cache::get_data(const int index, Qfloat **data, int len)
136
136
  if(more > 0)
137
137
  {
138
138
  // free old space
139
- while(size < more)
139
+ while(size < (size_t)more)
140
140
  {
141
141
  head_t *old = lru_head.next;
142
142
  lru_delete(old);
@@ -148,7 +148,7 @@ int Cache::get_data(const int index, Qfloat **data, int len)
148
148
 
149
149
  // allocate new space
150
150
  h->data = (Qfloat *)realloc(h->data,sizeof(Qfloat)*len);
151
- size -= more;
151
+ size -= more; // previous while loop guarantees size >= more and subtraction of size_t variable will not underflow
152
152
  swap(h->len,len);
153
153
  }
154
154
 
@@ -1274,7 +1274,7 @@ public:
1274
1274
  :Kernel(prob.l, prob.x, param)
1275
1275
  {
1276
1276
  clone(y,y_,prob.l);
1277
- cache = new Cache(prob.l,(long int)(param.cache_size*(1<<20)));
1277
+ cache = new Cache(prob.l,(size_t)(param.cache_size*(1<<20)));
1278
1278
  QD = new double[prob.l];
1279
1279
  for(int i=0;i<prob.l;i++)
1280
1280
  QD[i] = (this->*kernel_function)(i,i);
@@ -1326,7 +1326,7 @@ public:
1326
1326
  ONE_CLASS_Q(const svm_problem& prob, const svm_parameter& param)
1327
1327
  :Kernel(prob.l, prob.x, param)
1328
1328
  {
1329
- cache = new Cache(prob.l,(long int)(param.cache_size*(1<<20)));
1329
+ cache = new Cache(prob.l,(size_t)(param.cache_size*(1<<20)));
1330
1330
  QD = new double[prob.l];
1331
1331
  for(int i=0;i<prob.l;i++)
1332
1332
  QD[i] = (this->*kernel_function)(i,i);
@@ -1373,7 +1373,7 @@ public:
1373
1373
  :Kernel(prob.l, prob.x, param)
1374
1374
  {
1375
1375
  l = prob.l;
1376
- cache = new Cache(l,(long int)(param.cache_size*(1<<20)));
1376
+ cache = new Cache(l,(size_t)(param.cache_size*(1<<20)));
1377
1377
  QD = new double[2*l];
1378
1378
  sign = new schar[2*l];
1379
1379
  index = new int[2*l];
@@ -1,7 +1,7 @@
1
1
  #ifndef _LIBSVM_H
2
2
  #define _LIBSVM_H
3
3
 
4
- #define LIBSVM_VERSION 331
4
+ #define LIBSVM_VERSION 336
5
5
 
6
6
  #ifdef __cplusplus
7
7
  extern "C" {
@@ -3,6 +3,6 @@
3
3
  module Numo
4
4
  module Libsvm
5
5
  # The version of Numo::Libsvm you are using.
6
- VERSION = '2.2.0'
6
+ VERSION = '3.0.0'
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,29 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: numo-libsvm
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - yoshoku
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2023-03-05 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
- name: numo-narray
13
+ name: numo-narray-alt
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
- - - ">="
16
+ - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: 0.9.1
18
+ version: 0.9.3
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
- - - ">="
23
+ - - "~>"
25
24
  - !ruby/object:Gem::Version
26
- version: 0.9.1
25
+ version: 0.9.3
27
26
  description: |
28
27
  Numo::Libsvm is a Ruby gem binding to the LIBSVM library.
29
28
  LIBSVM is one of the famous libraries that implemented Support Vector Machines,
@@ -54,9 +53,9 @@ licenses:
54
53
  metadata:
55
54
  homepage_uri: https://github.com/yoshoku/numo-libsvm
56
55
  source_code_uri: https://github.com/yoshoku/numo-libsvm
57
- documentation_uri: https://yoshoku.github.io/numo-libsvm/doc/
56
+ changelog_uri: https://github.com/yoshoku/numo-libsvm/blob/main/CHANGELOG.md
57
+ documentation_uri: https://gemdocs.org/gems/numo-libsvm/3.0.0/
58
58
  rubygems_mfa_required: 'true'
59
- post_install_message:
60
59
  rdoc_options: []
61
60
  require_paths:
62
61
  - lib
@@ -71,8 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
70
  - !ruby/object:Gem::Version
72
71
  version: '0'
73
72
  requirements: []
74
- rubygems_version: 3.3.26
75
- signing_key:
73
+ rubygems_version: 3.6.9
76
74
  specification_version: 4
77
75
  summary: Numo::Libsvm is a Ruby gem binding to the LIBSVM library. Numo::Libsvm makes
78
76
  to use the LIBSVM functions with dataset represented by Numo::NArray.