ruby-gsl-ng 0.2.4.1 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +13 -0
- data/Manifest +2 -1
- data/Rakefile +1 -1
- data/ext/extconf.rb +6 -0
- data/ext/gslng_extensions.cpp +70 -15
- data/ext/plotting.cpp +14 -1
- data/lib/core_extensions/array.rb +14 -0
- data/lib/gslng.rb +2 -0
- data/lib/gslng/backend_components/matrix.rb +3 -0
- data/lib/gslng/backend_components/stats.rb +1 -0
- data/lib/gslng/matrix.rb +65 -50
- data/lib/gslng/matrix_view.rb +2 -0
- data/lib/gslng/plotter.rb +6 -2
- data/lib/gslng/vector.rb +112 -87
- data/lib/gslng/vector_view.rb +3 -1
- data/ruby-gsl-ng.gemspec +4 -4
- data/test/benchmark_results +53 -41
- data/test/matrix_test.rb +9 -0
- data/test/test_gsl.rb +2 -1
- data/test/vector_test.rb +17 -4
- metadata +6 -5
data/lib/gslng/vector_view.rb
CHANGED
@@ -11,8 +11,10 @@ module GSLng
|
|
11
11
|
attr_reader :owner
|
12
12
|
|
13
13
|
def initialize(ptr, owner, size, stride = 1) # @private
|
14
|
+
@backend = GSLng.backend
|
14
15
|
@owner,@size,@stride = owner,size,stride
|
15
16
|
@ptr = FFI::AutoPointer.new(ptr, View.method(:release))
|
17
|
+
@ptr_value = @ptr.to_i
|
16
18
|
end
|
17
19
|
|
18
20
|
def View.release(ptr)
|
@@ -24,7 +26,7 @@ module GSLng
|
|
24
26
|
# @return [Vector]
|
25
27
|
def dup
|
26
28
|
v = Vector.new(@size)
|
27
|
-
|
29
|
+
@backend.gsl_vector_memcpy(v.ptr, @ptr)
|
28
30
|
return v
|
29
31
|
end
|
30
32
|
alias_method :clone, :dup
|
data/ruby-gsl-ng.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{ruby-gsl-ng}
|
5
|
-
s.version = "0.2.
|
5
|
+
s.version = "0.2.6"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["v01d"]
|
9
|
-
s.date = %q{
|
9
|
+
s.date = %q{2011-03-07}
|
10
10
|
s.description = %q{Ruby/GSL new-generation wrapper}
|
11
11
|
s.email = %q{}
|
12
12
|
s.extensions = ["ext/extconf.rb"]
|
13
|
-
s.extra_rdoc_files = ["README.rdoc", "ext/extconf.rb", "ext/gslng_extensions.cpp", "ext/plotting.cpp", "lib/gslng.rb", "lib/gslng/backend.rb", "lib/gslng/backend_components/error_handling.rb", "lib/gslng/backend_components/matrix.rb", "lib/gslng/backend_components/rng.rb", "lib/gslng/backend_components/special.rb", "lib/gslng/backend_components/stats.rb", "lib/gslng/backend_components/vector.rb", "lib/gslng/matrix.rb", "lib/gslng/matrix_view.rb", "lib/gslng/plotter.rb", "lib/gslng/rng/gaussian.rb", "lib/gslng/rng/rng.rb", "lib/gslng/rng/uniform.rb", "lib/gslng/special.rb", "lib/gslng/vector.rb", "lib/gslng/vector_view.rb"]
|
14
|
-
s.files = ["History.txt", "README.rdoc", "Rakefile", "ext/extconf.rb", "ext/gslng_extensions.cpp", "ext/plotting.cpp", "lib/gslng.rb", "lib/gslng/backend.rb", "lib/gslng/backend_components/error_handling.rb", "lib/gslng/backend_components/matrix.rb", "lib/gslng/backend_components/rng.rb", "lib/gslng/backend_components/special.rb", "lib/gslng/backend_components/stats.rb", "lib/gslng/backend_components/vector.rb", "lib/gslng/matrix.rb", "lib/gslng/matrix_view.rb", "lib/gslng/plotter.rb", "lib/gslng/rng/gaussian.rb", "lib/gslng/rng/rng.rb", "lib/gslng/rng/uniform.rb", "lib/gslng/special.rb", "lib/gslng/vector.rb", "lib/gslng/vector_view.rb", "ruby-gsl-ng.gemspec", "test/benchmark.rb", "test/benchmark_results", "test/matrix_test.rb", "test/rng_test.rb", "test/test_gsl.rb", "test/test_special.rb", "test/vector_test.rb"
|
13
|
+
s.extra_rdoc_files = ["README.rdoc", "ext/extconf.rb", "ext/gslng_extensions.cpp", "ext/plotting.cpp", "lib/core_extensions/array.rb", "lib/gslng.rb", "lib/gslng/backend.rb", "lib/gslng/backend_components/error_handling.rb", "lib/gslng/backend_components/matrix.rb", "lib/gslng/backend_components/rng.rb", "lib/gslng/backend_components/special.rb", "lib/gslng/backend_components/stats.rb", "lib/gslng/backend_components/vector.rb", "lib/gslng/matrix.rb", "lib/gslng/matrix_view.rb", "lib/gslng/plotter.rb", "lib/gslng/rng/gaussian.rb", "lib/gslng/rng/rng.rb", "lib/gslng/rng/uniform.rb", "lib/gslng/special.rb", "lib/gslng/vector.rb", "lib/gslng/vector_view.rb"]
|
14
|
+
s.files = ["History.txt", "Manifest", "README.rdoc", "Rakefile", "ext/extconf.rb", "ext/gslng_extensions.cpp", "ext/plotting.cpp", "lib/core_extensions/array.rb", "lib/gslng.rb", "lib/gslng/backend.rb", "lib/gslng/backend_components/error_handling.rb", "lib/gslng/backend_components/matrix.rb", "lib/gslng/backend_components/rng.rb", "lib/gslng/backend_components/special.rb", "lib/gslng/backend_components/stats.rb", "lib/gslng/backend_components/vector.rb", "lib/gslng/matrix.rb", "lib/gslng/matrix_view.rb", "lib/gslng/plotter.rb", "lib/gslng/rng/gaussian.rb", "lib/gslng/rng/rng.rb", "lib/gslng/rng/uniform.rb", "lib/gslng/special.rb", "lib/gslng/vector.rb", "lib/gslng/vector_view.rb", "ruby-gsl-ng.gemspec", "test/benchmark.rb", "test/benchmark_results", "test/matrix_test.rb", "test/rng_test.rb", "test/test_gsl.rb", "test/test_special.rb", "test/vector_test.rb"]
|
15
15
|
s.homepage = %q{http://github.com/v01d/ruby-gsl-ng}
|
16
16
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Ruby-gsl-ng", "--main", "README.rdoc"]
|
17
17
|
s.require_paths = ["lib", "ext"]
|
data/test/benchmark_results
CHANGED
@@ -1,80 +1,92 @@
|
|
1
|
+
#################################### Vector ####################################
|
2
|
+
Vector#[]
|
3
|
+
Rehearsal --------------------------------------------
|
4
|
+
rb-gsl : 0.300000 0.000000 0.300000 ( 0.301650)
|
5
|
+
GSLng : 0.360000 0.000000 0.360000 ( 0.369323)
|
6
|
+
----------------------------------- total: 0.660000sec
|
7
|
+
|
8
|
+
user system total real
|
9
|
+
rb-gsl : 0.310000 0.000000 0.310000 ( 0.387314)
|
10
|
+
GSLng : 0.340000 0.000000 0.340000 ( 0.348130)
|
11
|
+
|
1
12
|
Vector#each - vector of 5000 elements
|
2
|
-
Rehearsal
|
3
|
-
rb-gsl
|
4
|
-
|
5
|
-
|
13
|
+
Rehearsal --------------------------------------------
|
14
|
+
rb-gsl : 0.220000 0.000000 0.220000 ( 0.218779)
|
15
|
+
GSLng : 0.200000 0.000000 0.200000 ( 0.205919)
|
16
|
+
----------------------------------- total: 0.420000sec
|
6
17
|
|
7
|
-
|
8
|
-
rb-gsl
|
9
|
-
|
18
|
+
user system total real
|
19
|
+
rb-gsl : 0.220000 0.000000 0.220000 ( 0.231055)
|
20
|
+
GSLng : 0.200000 0.000000 0.200000 ( 0.203754)
|
10
21
|
|
11
22
|
Norm (BLAS) - vector of 50000 elements
|
12
23
|
Rehearsal --------------------------------------------
|
13
|
-
rb-gsl : 0.520000 0.000000 0.520000 ( 0.
|
14
|
-
GSLng : 0.520000 0.
|
15
|
-
----------------------------------- total: 1.
|
24
|
+
rb-gsl : 0.520000 0.000000 0.520000 ( 0.521935)
|
25
|
+
GSLng : 0.520000 0.000000 0.520000 ( 0.521729)
|
26
|
+
----------------------------------- total: 1.040000sec
|
16
27
|
|
17
28
|
user system total real
|
18
|
-
rb-gsl : 0.520000 0.000000 0.520000 ( 0.
|
19
|
-
GSLng : 0.520000 0.000000 0.520000 ( 0.
|
29
|
+
rb-gsl : 0.520000 0.000000 0.520000 ( 0.521828)
|
30
|
+
GSLng : 0.520000 0.000000 0.520000 ( 0.521704)
|
20
31
|
|
21
32
|
Vector#map!
|
22
33
|
Rehearsal --------------------------------------------
|
23
|
-
rb-gsl : 0.
|
24
|
-
GSLng : 0.
|
25
|
-
----------------------------------- total: 0.
|
34
|
+
rb-gsl : 0.240000 0.000000 0.240000 ( 0.239012)
|
35
|
+
GSLng : 0.260000 0.000000 0.260000 ( 0.259632)
|
36
|
+
----------------------------------- total: 0.500000sec
|
26
37
|
|
27
38
|
user system total real
|
28
|
-
rb-gsl : 0.
|
29
|
-
GSLng : 0.
|
39
|
+
rb-gsl : 0.250000 0.000000 0.250000 ( 0.245187)
|
40
|
+
GSLng : 0.240000 0.000000 0.240000 ( 0.235865)
|
30
41
|
|
31
42
|
Vector product - two vectors of 5000 elements
|
32
43
|
Rehearsal --------------------------------------------
|
33
|
-
rb-gsl : 0.620000 0.000000 0.620000 ( 0.
|
34
|
-
GSLng : 0.
|
44
|
+
rb-gsl : 0.620000 0.000000 0.620000 ( 0.655681)
|
45
|
+
GSLng : 0.620000 0.010000 0.630000 ( 0.652757)
|
35
46
|
----------------------------------- total: 1.250000sec
|
36
47
|
|
37
48
|
user system total real
|
38
|
-
rb-gsl : 1.
|
39
|
-
GSLng : 1.170000 0.000000 1.170000 ( 1.
|
49
|
+
rb-gsl : 1.170000 0.000000 1.170000 ( 1.178990)
|
50
|
+
GSLng : 1.170000 0.000000 1.170000 ( 1.172545)
|
40
51
|
|
41
52
|
Sort - vector of 5000 elements
|
42
53
|
Rehearsal --------------------------------------------
|
43
|
-
rb-gsl : 0.440000 0.000000 0.440000 ( 0.
|
44
|
-
GSLng : 0.440000 0.000000 0.440000 ( 0.
|
54
|
+
rb-gsl : 0.440000 0.000000 0.440000 ( 0.441440)
|
55
|
+
GSLng : 0.440000 0.000000 0.440000 ( 0.444755)
|
45
56
|
----------------------------------- total: 0.880000sec
|
46
57
|
|
47
58
|
user system total real
|
48
|
-
rb-gsl : 0.
|
49
|
-
GSLng : 0.
|
59
|
+
rb-gsl : 0.430000 0.000000 0.430000 ( 0.440950)
|
60
|
+
GSLng : 0.450000 0.010000 0.460000 ( 0.447733)
|
50
61
|
|
51
62
|
Vector#to_a
|
52
63
|
Rehearsal --------------------------------------------
|
53
|
-
rb-gsl : 0.
|
54
|
-
GSLng : 0.
|
55
|
-
----------------------------------- total:
|
64
|
+
rb-gsl : 0.470000 0.000000 0.470000 ( 0.490407)
|
65
|
+
GSLng : 0.470000 0.000000 0.470000 ( 0.472971)
|
66
|
+
----------------------------------- total: 0.940000sec
|
56
67
|
|
57
68
|
user system total real
|
58
|
-
rb-gsl : 0.
|
59
|
-
GSLng : 0.
|
69
|
+
rb-gsl : 0.450000 0.000000 0.450000 ( 0.452365)
|
70
|
+
GSLng : 0.460000 0.000000 0.460000 ( 0.450768)
|
60
71
|
|
61
72
|
Vector::from_array
|
62
73
|
Rehearsal --------------------------------------------
|
63
|
-
rb-gsl : 0.
|
64
|
-
GSLng : 0.
|
65
|
-
----------------------------------- total:
|
74
|
+
rb-gsl : 0.730000 0.140000 0.870000 ( 0.868696)
|
75
|
+
GSLng : 0.650000 0.160000 0.810000 ( 0.811343)
|
76
|
+
----------------------------------- total: 1.680000sec
|
66
77
|
|
67
78
|
user system total real
|
68
|
-
rb-gsl : 0.
|
69
|
-
GSLng : 0.
|
79
|
+
rb-gsl : 0.730000 0.000000 0.730000 ( 0.727155)
|
80
|
+
GSLng : 0.650000 0.000000 0.650000 ( 0.644819)
|
70
81
|
|
71
|
-
|
82
|
+
#################################### Matrix ####################################
|
83
|
+
Matrix#[] - 50 x 50
|
72
84
|
Rehearsal --------------------------------------------
|
73
|
-
rb-gsl : 0.
|
74
|
-
GSLng : 0.
|
75
|
-
----------------------------------- total: 0.
|
85
|
+
rb-gsl : 0.380000 0.080000 0.460000 ( 0.455793)
|
86
|
+
GSLng : 0.530000 0.000000 0.530000 ( 0.542278)
|
87
|
+
----------------------------------- total: 0.990000sec
|
76
88
|
|
77
89
|
user system total real
|
78
|
-
rb-gsl : 0.
|
79
|
-
GSLng : 0.510000 0.000000 0.510000 ( 0.
|
90
|
+
rb-gsl : 0.360000 0.000000 0.360000 ( 0.367216)
|
91
|
+
GSLng : 0.510000 0.000000 0.510000 ( 0.510689)
|
80
92
|
|
data/test/matrix_test.rb
CHANGED
@@ -111,6 +111,15 @@ class TestMatrix < Test::Unit::TestCase
|
|
111
111
|
assert_equal(Matrix[[2,3,4],[1,2,3],[3,4,5]], m.swap_rows(0,1))
|
112
112
|
assert_equal(Matrix[[3,2,4],[2,1,3],[4,3,5]], m.swap_columns(0,1))
|
113
113
|
assert_equal(Matrix[[3,2,4],[2,1,3],[4,3,5]], m.swap_rowcol(0,0))
|
114
|
+
|
115
|
+
m = Matrix[[1,2,3],[4,5,6],[7,8,9]]
|
116
|
+
assert_equal(Matrix[[0, 0, 0],[0, 1, 2],[0, 4, 5]], m.slide(1, 1))
|
117
|
+
|
118
|
+
m = Matrix[[1,2,3],[4,5,6],[7,8,9]]
|
119
|
+
assert_equal(Matrix[[5, 6, 0],[8, 9, 0],[0, 0, 0]], m.slide(-1, -1))
|
120
|
+
|
121
|
+
m = Matrix[[1,2,3],[4,5,6],[7,8,9]]
|
122
|
+
assert_equal(Matrix[[4, 5, 6],[7, 8, 9],[0, 0, 0]], m.slide(-1, 0))
|
114
123
|
end
|
115
124
|
|
116
125
|
def test_view
|
data/test/test_gsl.rb
CHANGED
data/test/vector_test.rb
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
$:.unshift File.join(File.dirname(__FILE__),'..','lib')
|
5
5
|
$:.unshift File.join(File.dirname(__FILE__),'..','ext')
|
6
6
|
|
7
|
+
require 'rubygems'
|
7
8
|
require 'test/unit'
|
8
9
|
require 'gslng'
|
9
10
|
|
@@ -15,6 +16,10 @@ class VectorTest < Test::Unit::TestCase
|
|
15
16
|
assert_equal(10, Vector.zero(10).size)
|
16
17
|
assert(Vector.zero(10).zero?)
|
17
18
|
assert_nothing_raised { Vector.random(10) }
|
19
|
+
assert_equal(Vector[0], Vector.linspace(0, 1, 1.5))
|
20
|
+
assert_equal(Vector[0,1], Vector.linspace(0, 1, 1))
|
21
|
+
assert_equal(Vector[0,0.5,1], Vector.linspace(0, 1, 0.5))
|
22
|
+
assert_equal(Vector[0,0.7], Vector.linspace(0, 1, 0.7))
|
18
23
|
end
|
19
24
|
|
20
25
|
def test_to_s
|
@@ -31,7 +36,10 @@ class VectorTest < Test::Unit::TestCase
|
|
31
36
|
assert_equal(Vector[1,2,3], Vector[1,2,3])
|
32
37
|
assert_equal(Vector[0...3], [0,1,2])
|
33
38
|
assert_equal(Vector.zero(3), Vector.zero(3))
|
34
|
-
assert_not_equal(Vector.zero(4), Vector.zero(3))
|
39
|
+
assert_not_equal(Vector.zero(4), Vector.zero(3))
|
40
|
+
|
41
|
+
assert(Vector[1,2,3].eql?(Vector[1,2,3]))
|
42
|
+
assert(!Vector[1,2,3].eql?(Vector[1,2,4]))
|
35
43
|
end
|
36
44
|
|
37
45
|
def test_each
|
@@ -49,6 +57,11 @@ class VectorTest < Test::Unit::TestCase
|
|
49
57
|
assert_equal(v1.dup, v2)
|
50
58
|
end
|
51
59
|
|
60
|
+
def test_stats
|
61
|
+
assert_equal(Vector[1, 2, 3, 4, 5].median, 3)
|
62
|
+
assert_equal(Vector[1, 2, 3, 4].median, 2.5)
|
63
|
+
end
|
64
|
+
|
52
65
|
def test_sets
|
53
66
|
assert_equal(Vector.zero(3).set!(1), Vector[1,1,1])
|
54
67
|
assert_equal(Vector.zero(3).set!(1).zero!, Vector.zero(3))
|
@@ -115,9 +128,9 @@ class VectorTest < Test::Unit::TestCase
|
|
115
128
|
end
|
116
129
|
|
117
130
|
def test_wrap
|
118
|
-
v = Vector[1,2,8]
|
119
|
-
assert_equal(Vector[0,0,-1],v.wrap!(
|
120
|
-
assert_equal(Vector[1,2,3], v)
|
131
|
+
v = Vector[1,2,8,-1,11]
|
132
|
+
assert_equal(Vector[0,0,-1,1,-2],v.wrap!(5))
|
133
|
+
assert_equal(Vector[1,2,3,4,1], v)
|
121
134
|
end
|
122
135
|
|
123
136
|
def test_predicate
|
metadata
CHANGED
@@ -5,9 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
|
10
|
-
version: 0.2.4.1
|
8
|
+
- 6
|
9
|
+
version: 0.2.6
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- v01d
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date:
|
17
|
+
date: 2011-03-07 00:00:00 -03:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
@@ -55,6 +54,7 @@ extra_rdoc_files:
|
|
55
54
|
- ext/extconf.rb
|
56
55
|
- ext/gslng_extensions.cpp
|
57
56
|
- ext/plotting.cpp
|
57
|
+
- lib/core_extensions/array.rb
|
58
58
|
- lib/gslng.rb
|
59
59
|
- lib/gslng/backend.rb
|
60
60
|
- lib/gslng/backend_components/error_handling.rb
|
@@ -74,11 +74,13 @@ extra_rdoc_files:
|
|
74
74
|
- lib/gslng/vector_view.rb
|
75
75
|
files:
|
76
76
|
- History.txt
|
77
|
+
- Manifest
|
77
78
|
- README.rdoc
|
78
79
|
- Rakefile
|
79
80
|
- ext/extconf.rb
|
80
81
|
- ext/gslng_extensions.cpp
|
81
82
|
- ext/plotting.cpp
|
83
|
+
- lib/core_extensions/array.rb
|
82
84
|
- lib/gslng.rb
|
83
85
|
- lib/gslng/backend.rb
|
84
86
|
- lib/gslng/backend_components/error_handling.rb
|
@@ -104,7 +106,6 @@ files:
|
|
104
106
|
- test/test_gsl.rb
|
105
107
|
- test/test_special.rb
|
106
108
|
- test/vector_test.rb
|
107
|
-
- Manifest
|
108
109
|
has_rdoc: true
|
109
110
|
homepage: http://github.com/v01d/ruby-gsl-ng
|
110
111
|
licenses: []
|