gslr 0.3.1 → 0.4.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: ed25291c8db448474f899977ed387aee68777c7295f7a2c9a800d20f9080e0aa
4
- data.tar.gz: 8ecd7a62b1908c697b3c5b49ece4fec68a2d518e4d4e6cdc65e342f7b3c5f93f
3
+ metadata.gz: 6dffcae9687090d250236a2dbe1b14d0a871d8aca6322946e2d70bb7e1524f6c
4
+ data.tar.gz: 296e86ff4b492e6f098b71cedce786e5402b9d68d6c9dd0e7f927750490b35e8
5
5
  SHA512:
6
- metadata.gz: d0b36089807185b51a4620fb4950b1779dd134d6d88d7936c74623f01a266ed064e5b742dec1d1274732badb61a2770cd20c16e5fe26c74dd6494fb4842fa38c
7
- data.tar.gz: fec15c0e8bbf262214287cf25a7409ba5401dd7b8bd7332307590052be218a75f45b49a4465f3cc55aaf97231d218cc0e92c4106f691039a73441df530e43409
6
+ metadata.gz: 6191eb9d4a4ca68c15322c0d841fd2908f33c2bcddc772a3a8b76834a0afb86f46c572df513312c6993c26486bc0b88cc7cc2c6a4be8b6a2ffb6199ff5458910
7
+ data.tar.gz: 70ed2e44186ce9484548d6db67c8c012bad1911a161994e10f394909e5e45911bd2bf6a95ba63769957b636d403adbc03d3f367bb98f37b67aeb497e456d9a81
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 0.4.0 (2026-04-07)
2
+
3
+ - Dropped support for Ruby < 3.3
4
+
5
+ ## 0.3.2 (2025-05-04)
6
+
7
+ - Fixed memory leaks
8
+
1
9
  ## 0.3.1 (2024-12-29)
2
10
 
3
11
  - Fixed GSL detection on Mac x86-64
data/NOTICE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (C) 2019-2022 Andrew Kane
1
+ Copyright (C) 2019-2026 Andrew Kane
2
2
 
3
3
  This program is free software: you can redistribute it and/or modify
4
4
  it under the terms of the GNU General Public License as published by
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.4.0"
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.4.0
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
@@ -49,14 +49,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
49
49
  requirements:
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: '3.1'
52
+ version: '3.3'
53
53
  required_rubygems_version: !ruby/object:Gem::Requirement
54
54
  requirements:
55
55
  - - ">="
56
56
  - !ruby/object:Gem::Version
57
57
  version: '0'
58
58
  requirements: []
59
- rubygems_version: 3.6.2
59
+ rubygems_version: 4.0.6
60
60
  specification_version: 4
61
61
  summary: High performance linear regression for Ruby, powered by GSL
62
62
  test_files: []