gslr 0.3.1 → 0.3.2

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: ed25291c8db448474f899977ed387aee68777c7295f7a2c9a800d20f9080e0aa
4
- data.tar.gz: 8ecd7a62b1908c697b3c5b49ece4fec68a2d518e4d4e6cdc65e342f7b3c5f93f
3
+ metadata.gz: 2ba14834cdeabffc31c4820a0ff36ed60022f96b761364c7eb74e416e304a716
4
+ data.tar.gz: 88fbc5eed0052e531d96520ee19392c15ad66a970480c876cd90b79d59563599
5
5
  SHA512:
6
- metadata.gz: d0b36089807185b51a4620fb4950b1779dd134d6d88d7936c74623f01a266ed064e5b742dec1d1274732badb61a2770cd20c16e5fe26c74dd6494fb4842fa38c
7
- data.tar.gz: fec15c0e8bbf262214287cf25a7409ba5401dd7b8bd7332307590052be218a75f45b49a4465f3cc55aaf97231d218cc0e92c4106f691039a73441df530e43409
6
+ metadata.gz: 1fd72f51597b8f1de6aa5286d1fcec6a2256ee490241e5e6201f6367d3dbf733ebbc3ff491b34570364cef9d9d9560bc2747c398d8f446d29e038f41d4aaa5d2
7
+ data.tar.gz: 87d542a34a25e2b09675ab1f49cc1d919d971ffa066da39fa04f25fe26c3fbcc7decf247b13d083ee34ba13709a8050f263e0b29ff47dd15ca2f1b2fffe84f9f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.3.2 (2025-05-04)
2
+
3
+ - Fixed memory leaks
4
+
1
5
  ## 0.3.1 (2024-12-29)
2
6
 
3
7
  - Fixed GSL detection on Mac x86-64
data/lib/gslr/model.rb CHANGED
@@ -23,6 +23,7 @@ module GSLR
23
23
  s2 += 1 if intercept
24
24
 
25
25
  xc = FFI.gsl_matrix_alloc(s1, s2)
26
+ xc.free = FFI["gsl_matrix_free"]
26
27
  x_ptr = FFI.gsl_matrix_ptr(xc, 0, 0)
27
28
 
28
29
  if numo?(x)
@@ -47,6 +48,7 @@ module GSLR
47
48
 
48
49
  def set_vector(x)
49
50
  v = FFI.gsl_vector_alloc(x.size)
51
+ v.free = FFI["gsl_vector_free"]
50
52
  ptr = FFI.gsl_vector_ptr(v, 0)
51
53
  set_data(ptr, x)
52
54
  v
data/lib/gslr/ols.rb CHANGED
@@ -6,12 +6,16 @@ module GSLR
6
6
  # set data
7
7
  xc, s1, s2 = set_matrix(x, intercept: @fit_intercept)
8
8
  yc = set_vector(y)
9
+ yc.free = FFI["gsl_vector_free"]
9
10
 
10
11
  # allocate solution
11
12
  c = FFI.gsl_vector_alloc(s2)
13
+ c.free = FFI["gsl_vector_free"]
12
14
  cov = FFI.gsl_matrix_alloc(s2, s2)
13
- chisq = Fiddle::Pointer.malloc(Fiddle::SIZEOF_DOUBLE)
15
+ cov.free = FFI["gsl_matrix_free"]
16
+ chisq = Fiddle::Pointer.malloc(Fiddle::SIZEOF_DOUBLE, Fiddle::RUBY_FREE)
14
17
  work = FFI.gsl_multifit_linear_alloc(s1, s2)
18
+ work.free = FFI["gsl_multifit_linear_free"]
15
19
 
16
20
  # fit
17
21
  if weight
@@ -29,13 +33,6 @@ module GSLR
29
33
  @chi2 = chisq[0, Fiddle::SIZEOF_DOUBLE].unpack1("d")
30
34
 
31
35
  nil
32
- ensure
33
- FFI.gsl_matrix_free(xc) if xc
34
- FFI.gsl_vector_free(yc) if yc
35
- FFI.gsl_vector_free(wc) if wc
36
- FFI.gsl_vector_free(c) if c
37
- FFI.gsl_matrix_free(cov) if cov
38
- FFI.gsl_multifit_linear_free(work) if work
39
36
  end
40
37
 
41
38
  private
data/lib/gslr/ridge.rb CHANGED
@@ -32,9 +32,11 @@ module GSLR
32
32
 
33
33
  # allocate solution
34
34
  c = FFI.gsl_vector_alloc(s2)
35
- rnorm = Fiddle::Pointer.malloc(Fiddle::SIZEOF_DOUBLE)
36
- snorm = Fiddle::Pointer.malloc(Fiddle::SIZEOF_DOUBLE)
35
+ c.free = FFI["gsl_vector_free"]
36
+ rnorm = Fiddle::Pointer.malloc(Fiddle::SIZEOF_DOUBLE, Fiddle::RUBY_FREE)
37
+ snorm = Fiddle::Pointer.malloc(Fiddle::SIZEOF_DOUBLE, Fiddle::RUBY_FREE)
37
38
  work = FFI.gsl_multifit_linear_alloc(s1, s2)
39
+ work.free = FFI["gsl_multifit_linear_free"]
38
40
 
39
41
  # fit
40
42
  check_status FFI.gsl_multifit_linear_svd(xc, work)
@@ -51,11 +53,6 @@ module GSLR
51
53
  end
52
54
 
53
55
  nil
54
- ensure
55
- FFI.gsl_matrix_free(xc) if xc
56
- FFI.gsl_vector_free(yc) if yc
57
- FFI.gsl_vector_free(c) if c
58
- FFI.gsl_multifit_linear_free(work) if work
59
56
  end
60
57
 
61
58
  private
@@ -74,6 +71,7 @@ module GSLR
74
71
 
75
72
  s1, s2 = shape(x)
76
73
  xc = FFI.gsl_matrix_alloc(s1, s2)
74
+ xc.free = FFI["gsl_matrix_free"]
77
75
  x_ptr = FFI.gsl_matrix_ptr(xc, 0, 0)
78
76
 
79
77
  # pack efficiently
data/lib/gslr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module GSLR
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gslr
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
  - Andrew Kane
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2024-12-29 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: fiddle
@@ -56,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
56
56
  - !ruby/object:Gem::Version
57
57
  version: '0'
58
58
  requirements: []
59
- rubygems_version: 3.6.2
59
+ rubygems_version: 3.6.7
60
60
  specification_version: 4
61
61
  summary: High performance linear regression for Ruby, powered by GSL
62
62
  test_files: []