lbfgsb 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b3bd36b7d31d1cbc04ef90be26df3fcf67b73a1dbeba544a1c838f6b35786115
4
- data.tar.gz: d09cc5f75361c4ec6c542ed7b663d87c8654e806cfdcd81415754f963074fbd1
3
+ metadata.gz: d3c9f07b919bd5a429225c6aa74e05b4c64ad9df9464388ffea2648560432573
4
+ data.tar.gz: 2f264cc51d1d7b3438ecdd0204b41cd7d1ad4c38e9b23c2f6fc0a2116e923cd0
5
5
  SHA512:
6
- metadata.gz: ce048d758955f403e2d6c176f316e8f7e5db58dc142f91a0ee343fd0115a17b9b61c6a26a145eb1553dab6644f3f6cc5f6fa8ad04898287393247ef34de58fc0
7
- data.tar.gz: 6d6e7dd5fbc941b37542de548385a6202322fbfebe5a6a77a9afbb169dcf9d421f7d79435dda881b5c3174948b47eb603a065c6726011f010c66e45b674c41d5
6
+ metadata.gz: 9ee089354c99d1eaa412f42f4e74e8b51124be569c4b56820a88e3e0dcaff79b8f23e24d4c12b49b89824ed5f6a4975024973a2d3be6fa0fe33a8f25b1fc5aaa
7
+ data.tar.gz: f6727155040cd9b36effa98056eabc826dbf7c4701973202238dea8145c0cd2cfa9b6cb55ffa9a01f01d4d1365438ed62cb2dca1b987b41e77a26661a1a5df28
@@ -1,3 +1,7 @@
1
+ ## 0.3.2
2
+ - Refactor native extension codes.
3
+ - Update documentations.
4
+
1
5
  ## 0.3.1
2
6
  - Add GC guard to narray given to native extension method.
3
7
 
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Build Status](https://github.com/yoshoku/lbfgsb.rb/workflows/build/badge.svg)](https://github.com/yoshoku/lbfgsb.rb/actions?query=workflow%3Abuild)
4
4
  [![Gem Version](https://badge.fury.io/rb/lbfgsb.svg)](https://badge.fury.io/rb/lbfgsb)
5
- [![BSD 3-Clause License](https://img.shields.io/badge/License-BSD%203--Clause-orange.svg)](https://github.com/yoshoku/suika/blob/master/LICENSE.txt)
5
+ [![BSD 3-Clause License](https://img.shields.io/badge/License-BSD%203--Clause-orange.svg)](https://github.com/yoshoku/suika/blob/main/LICENSE.txt)
6
6
  [![Documentation](http://img.shields.io/badge/api-reference-blue.svg)](https://yoshoku.github.io/lbfgsb.rb/doc/)
7
7
 
8
8
  Lbfgsb.rb is a Ruby binding for [L-BFGS-B](http://users.iems.northwestern.edu/~nocedal/lbfgsb.html)
@@ -8,7 +8,6 @@ VALUE lbfgsb_min_l_bfgs_b(VALUE self,
8
8
  VALUE l_val, VALUE u_val, VALUE nbd_val,
9
9
  VALUE maxcor, VALUE ftol, VALUE gtol, VALUE maxiter, VALUE disp)
10
10
  {
11
- long i;
12
11
  long n_iter;
13
12
  long n_fev;
14
13
  long n_jev;
@@ -19,12 +18,12 @@ VALUE lbfgsb_min_l_bfgs_b(VALUE self,
19
18
  narray_t* nbd_nary;
20
19
  long n;
21
20
  long m = NUM2LONG(maxcor);
22
- double *x_ptr;
23
- double *l_ptr;
24
- double *u_ptr;
25
- long *nbd_ptr;
21
+ double* x_ptr;
22
+ double* l_ptr;
23
+ double* u_ptr;
24
+ long* nbd_ptr;
26
25
  double f;
27
- double *g;
26
+ double* g;
28
27
  double factr = NUM2DBL(ftol);
29
28
  double pgtol = NUM2DBL(gtol);
30
29
  double* wa;
@@ -35,7 +34,6 @@ VALUE lbfgsb_min_l_bfgs_b(VALUE self,
35
34
  long lsave[4];
36
35
  long isave[44];
37
36
  double dsave[29];
38
- double* g_ptr;
39
37
  VALUE g_val;
40
38
  VALUE fg_arr;
41
39
  VALUE ret;
@@ -111,7 +109,7 @@ VALUE lbfgsb_min_l_bfgs_b(VALUE self,
111
109
 
112
110
  g_val = Qnil;
113
111
  f = 0.0;
114
- for (i = 0; i < n; g[i++] = 0.0);
112
+ memset(g, 0, n * sizeof(*g));
115
113
  strcpy(task, "START");
116
114
  n_fev = 0;
117
115
  n_jev = 0;
@@ -130,15 +128,14 @@ VALUE lbfgsb_min_l_bfgs_b(VALUE self,
130
128
  f = NUM2DBL(rb_funcall(self, rb_intern("fnc"), 3, fnc, x_val, args));
131
129
  g_val = rb_funcall(self, rb_intern("jcb"), 3, jcb, x_val, args);
132
130
  }
133
- n_fev += 1;
134
- n_jev += 1;
131
+ n_fev++;
132
+ n_jev++;
135
133
  if (CLASS_OF(g_val) != numo_cDFloat) g_val = rb_funcall(numo_cDFloat, rb_intern("cast"), 1, g_val);
136
134
  if (!RTEST(nary_check_contiguous(g_val))) g_val = nary_dup(g_val);
137
- g_ptr = (double*)na_get_pointer_for_read(g_val);
138
- for (i = 0; i < n; i++) g[i] = g_ptr[i];
135
+ memcpy(g, na_get_pointer_for_read(g_val), n * sizeof(*g));
136
+ RB_GC_GUARD(g_val);
139
137
  } else if (strncmp(task, "NEW_X", 5) == 0) {
140
- n_iter += 1;
141
- continue;
138
+ n_iter++;
142
139
  } else {
143
140
  break;
144
141
  }
@@ -2,6 +2,7 @@
2
2
  #define LBFGSB_RB_H 1
3
3
 
4
4
  #include <float.h>
5
+ #include <string.h>
5
6
 
6
7
  #include <ruby.h>
7
8
  #include <numo/narray.h>
@@ -6,14 +6,17 @@ Gem::Specification.new do |spec|
6
6
  spec.authors = ['yoshoku']
7
7
  spec.email = ['yoshoku@outlook.com']
8
8
 
9
- spec.summary = 'Lbfgsb.rb is a Ruby binding for L-BFGS-B'
10
- spec.description = 'Lbfgsb.rb is a Ruby binding for L-BFGS-B'
9
+ spec.summary = 'Lbfgsb.rb is a Ruby binding for L-BFGS-B.'
10
+ spec.description = <<~MSG
11
+ Lbfgsb.rb is a Ruby binding for L-BFGS-B that is a limited-memory algorithm for
12
+ solving large nonlinear optimization problems subject to simple bounds on the variables.
13
+ MSG
11
14
  spec.homepage = 'https://github.com/yoshoku/lbfgsb.rb'
12
15
  spec.license = 'BSD-3-Clause'
13
16
 
14
- spec.metadata['homepage_uri'] = spec.homepage
15
- spec.metadata['source_code_uri'] = 'https://github.com/yoshoku/lbfgsb.rb'
16
- spec.metadata['changelog_uri'] = 'https://github.com/yoshoku/lbfgsb.rb/blob/main/CHANGELOG.md'
17
+ spec.metadata['homepage_uri'] = spec.homepage
18
+ spec.metadata['source_code_uri'] = 'https://github.com/yoshoku/lbfgsb.rb'
19
+ spec.metadata['changelog_uri'] = 'https://github.com/yoshoku/lbfgsb.rb/blob/main/CHANGELOG.md'
17
20
  spec.metadata['documentation_uri'] = 'https://yoshoku.github.io/lbfgsb.rb/doc/'
18
21
 
19
22
  # Specify which files should be added to the gem when it is released.
@@ -3,5 +3,5 @@
3
3
  # Lbfgsb.rb is a Ruby binding for L-BFGS-B with Numo::NArray.
4
4
  module Lbfgsb
5
5
  # The version of Lbfgsb.rb you are using.
6
- VERSION = '0.3.1'
6
+ VERSION = '0.3.2'
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lbfgsb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - yoshoku
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-16 00:00:00.000000000 Z
11
+ date: 2021-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: numo-narray
@@ -24,7 +24,9 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.9.1
27
- description: Lbfgsb.rb is a Ruby binding for L-BFGS-B
27
+ description: |
28
+ Lbfgsb.rb is a Ruby binding for L-BFGS-B that is a limited-memory algorithm for
29
+ solving large nonlinear optimization problems subject to simple bounds on the variables.
28
30
  email:
29
31
  - yoshoku@outlook.com
30
32
  executables: []
@@ -77,8 +79,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
79
  - !ruby/object:Gem::Version
78
80
  version: '0'
79
81
  requirements: []
80
- rubygems_version: 3.1.4
82
+ rubygems_version: 3.2.3
81
83
  signing_key:
82
84
  specification_version: 4
83
- summary: Lbfgsb.rb is a Ruby binding for L-BFGS-B
85
+ summary: Lbfgsb.rb is a Ruby binding for L-BFGS-B.
84
86
  test_files: []