mdarray 0.5.0.pre-java → 0.5.3-java
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.
- data/README.md +89 -90
- data/Rakefile +6 -1
- data/lib/colt/cern_double_functions.rb +193 -0
- data/lib/colt/cern_float_functions.rb +193 -0
- data/lib/colt/cern_int_functions.rb +152 -0
- data/lib/colt/cern_long_functions.rb +152 -0
- data/lib/colt/colt.rb +103 -1
- data/lib/mdarray.rb +71 -23
- data/lib/mdarray/access.rb +8 -0
- data/lib/mdarray/counter.rb +43 -1
- data/lib/mdarray/creation.rb +5 -10
- data/lib/mdarray/fast_operators.rb +17 -13
- data/lib/mdarray/function_creation.rb +11 -45
- data/lib/mdarray/function_map.rb +16 -8
- data/lib/mdarray/lazy_mdarray.rb +311 -0
- data/lib/mdarray/lazy_operators.rb +166 -0
- data/lib/mdarray/operators.rb +38 -9
- data/lib/mdarray/proc_util.rb +2 -0
- data/lib/mdarray/ruby_boolean_functions.rb +24 -0
- data/lib/mdarray/ruby_functions.rb +76 -2
- data/lib/mdarray/ruby_generic_functions.rb +12 -4
- data/lib/mdarray/ruby_math.rb +180 -2
- data/lib/mdarray/ruby_numeric_functions.rb +198 -7
- data/target/helper.jar +0 -0
- data/test/colt/ColtMethods.xlsx +0 -0
- data/test/colt/test_complete.rb +1 -0
- data/test/colt/test_math.rb +249 -0
- data/test/complete.rb +1 -0
- data/test/env.rb +17 -4
- data/test/mdarray/arithmetic_casting.rb +3 -0
- data/test/mdarray/test_boolean.rb +1 -1
- data/test/mdarray/test_complete.rb +1 -0
- data/test/mdarray/test_error.rb +13 -13
- data/test/mdarray/test_lazy.rb +306 -0
- data/test/mdarray/test_operator.rb +1 -1
- data/test/mdarray/test_performance.rb +57 -4
- data/test/mdarray/test_trigonometry.rb +5 -1
- data/vendor/commons-compiler.jar +0 -0
- data/vendor/janino.jar +0 -0
- data/version.rb +1 -1
- metadata +47 -10
- data/test/mdarray/test_statistics.rb +0 -80
@@ -4,14 +4,12 @@ require 'shoulda'
|
|
4
4
|
require 'jruby/profiler'
|
5
5
|
|
6
6
|
require 'benchmark'
|
7
|
-
|
8
7
|
require 'mdarray'
|
9
8
|
|
10
9
|
class MDArrayTest < Test::Unit::TestCase
|
11
10
|
|
12
11
|
context "Speed Tests" do
|
13
12
|
|
14
|
-
#=begin
|
15
13
|
setup do
|
16
14
|
|
17
15
|
p "starting performance testing"
|
@@ -21,6 +19,61 @@ class MDArrayTest < Test::Unit::TestCase
|
|
21
19
|
#-------------------------------------------------------------------------------------
|
22
20
|
#
|
23
21
|
#-------------------------------------------------------------------------------------
|
22
|
+
|
23
|
+
should "be faster lazy than eager" do
|
24
|
+
|
25
|
+
@a = MDArray.typed_arange("double", 10_000_000)
|
26
|
+
@b = MDArray.typed_arange("double", 10_000_000)
|
27
|
+
# @c = MDArray.arange(100_000_000)
|
28
|
+
# @d = MDArray.arange(100_000_000)
|
29
|
+
|
30
|
+
#=end
|
31
|
+
|
32
|
+
MDArray.lazy = true
|
33
|
+
puts "Benchmarking: 4 element expression lazyly"
|
34
|
+
|
35
|
+
profile_data = JRuby::Profiler.profile do
|
36
|
+
puts Benchmark.measure {
|
37
|
+
c = (@a + @b + @a + @b * @b * @b * @b * @b * @b * @b)[]
|
38
|
+
# c = (@a + @b * @c - @d)[]
|
39
|
+
# c = (@a + @b)[]
|
40
|
+
# c = (@a * @a + @b * @b + @a * @b)[]
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
profile_printer = JRuby::Profiler::FlatProfilePrinter.new(profile_data)
|
45
|
+
profile_printer.printProfile(STDOUT)
|
46
|
+
|
47
|
+
MDArray.lazy = false
|
48
|
+
|
49
|
+
#=begin
|
50
|
+
puts "========================="
|
51
|
+
puts "Benchmarking: 4 element expression eagerly"
|
52
|
+
|
53
|
+
profile_data = JRuby::Profiler.profile do
|
54
|
+
puts Benchmark.measure {
|
55
|
+
# c = (@a * @a + @b * @b + @a * @b)
|
56
|
+
#c = @a + @b + @c + @d
|
57
|
+
c = @a + @b + @a + @b * @b * @b * @b * @b * @b * @b
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
profile_printer = JRuby::Profiler::FlatProfilePrinter.new(profile_data)
|
62
|
+
profile_printer.printProfile(STDOUT)
|
63
|
+
|
64
|
+
=begin
|
65
|
+
profile_data = JRuby::Profiler.profile do
|
66
|
+
c = (@a + @b * @c - @d)
|
67
|
+
c[]
|
68
|
+
end
|
69
|
+
=end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
#-------------------------------------------------------------------------------------
|
74
|
+
#
|
75
|
+
#-------------------------------------------------------------------------------------
|
76
|
+
|
24
77
|
=begin
|
25
78
|
should "test basic operations" do
|
26
79
|
|
@@ -123,7 +176,7 @@ class MDArrayTest < Test::Unit::TestCase
|
|
123
176
|
#
|
124
177
|
#-------------------------------------------------------------------------------------
|
125
178
|
|
126
|
-
|
179
|
+
=begin
|
127
180
|
should "execute fromfunction" do
|
128
181
|
|
129
182
|
# creates an array from a function (actually a block). The name fromfunction
|
@@ -142,7 +195,7 @@ class MDArrayTest < Test::Unit::TestCase
|
|
142
195
|
}
|
143
196
|
|
144
197
|
end
|
145
|
-
|
198
|
+
=end
|
146
199
|
|
147
200
|
=begin
|
148
201
|
@a = MDArray.double([7, 500, 20, 320])
|
@@ -31,12 +31,13 @@ class MDArrayTest < Test::Unit::TestCase
|
|
31
31
|
|
32
32
|
setup do
|
33
33
|
|
34
|
-
# create a byte array filled with 0's
|
35
34
|
@a = MDArray.typed_arange("double", 90)
|
36
35
|
|
37
36
|
# create double array
|
38
37
|
@b = MDArray.double([2, 3, 4])
|
39
38
|
|
39
|
+
@c = MDArray.linspace("double", 0, 1, 100)
|
40
|
+
|
40
41
|
end
|
41
42
|
|
42
43
|
#-------------------------------------------------------------------------------------
|
@@ -45,7 +46,10 @@ class MDArrayTest < Test::Unit::TestCase
|
|
45
46
|
|
46
47
|
should "execute trigonometric functions" do
|
47
48
|
|
49
|
+
|
48
50
|
sin = @a.sin
|
51
|
+
sin.print
|
52
|
+
|
49
53
|
cos = @a.cos
|
50
54
|
|
51
55
|
id = sin**2 + cos**2
|
Binary file
|
data/vendor/janino.jar
ADDED
Binary file
|
data/version.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
$gem_name = "mdarray"
|
2
|
-
$version="0.5.
|
2
|
+
$version="0.5.3"
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mdarray
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
version: 0.5.
|
4
|
+
prerelease:
|
5
|
+
version: 0.5.3
|
6
6
|
platform: java
|
7
7
|
authors:
|
8
8
|
- Rodrigo Botafogo
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-06-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: map
|
@@ -27,6 +27,24 @@ dependencies:
|
|
27
27
|
none: false
|
28
28
|
prerelease: false
|
29
29
|
type: :runtime
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: shoulda
|
32
|
+
version_requirements: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: !binary |-
|
37
|
+
MA==
|
38
|
+
none: false
|
39
|
+
requirement: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: !binary |-
|
44
|
+
MA==
|
45
|
+
none: false
|
46
|
+
prerelease: false
|
47
|
+
type: :runtime
|
30
48
|
- !ruby/object:Gem::Dependency
|
31
49
|
name: simplecov
|
32
50
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -75,9 +93,18 @@ dependencies:
|
|
75
93
|
none: false
|
76
94
|
prerelease: false
|
77
95
|
type: :development
|
78
|
-
description: "\"
|
79
|
-
\
|
80
|
-
\
|
96
|
+
description: "\"MDArray is a multi dimensional array implemented for JRuby inspired\
|
97
|
+
\ by NumPy (www.numpy.org) and \nMasahiro Tanaka´s Narray (narray.rubyforge.org).\
|
98
|
+
\ MDArray stands on the shoulders of Java-NetCDF \nand Parallel Colt. At this\
|
99
|
+
\ point MDArray has libraries for mathematical, trigonometric and \ndescriptive\
|
100
|
+
\ statistics methods.\n\nNetCDF-Java Library is a Java interface to NetCDF files,\
|
101
|
+
\ as well as to many other types of \nscientific data formats. It is developed\
|
102
|
+
\ and distributed by Unidata (http://www.unidata.ucar.edu). \n\nParallel Colt (http://grepcode.com/snapshot/repo1.maven.org/maven2/net.sourceforge.parallelcolt/\n\
|
103
|
+
parallelcolt/0.10.0/) is a multithreaded version of Colt (http://acs.lbl.gov/software/colt/).\
|
104
|
+
\ \nColt provides a set of Open Source Libraries for High Performance Scientific\
|
105
|
+
\ and Technical \nComputing in Java. Scientific and technical computing is characterized\
|
106
|
+
\ by demanding problem \nsizes and a need for high performance at reasonably small\
|
107
|
+
\ memory footprint.\"\n"
|
81
108
|
email: rodrigo.a.botafogo@gmail.com
|
82
109
|
executables: []
|
83
110
|
extensions: []
|
@@ -87,6 +114,10 @@ files:
|
|
87
114
|
- version.rb
|
88
115
|
- lib/env.rb
|
89
116
|
- lib/mdarray.rb
|
117
|
+
- lib/colt/cern_double_functions.rb
|
118
|
+
- lib/colt/cern_float_functions.rb
|
119
|
+
- lib/colt/cern_int_functions.rb
|
120
|
+
- lib/colt/cern_long_functions.rb
|
90
121
|
- lib/colt/colt.rb
|
91
122
|
- lib/colt/colt_mdarray.rb
|
92
123
|
- lib/colt/double_descriptive.rb
|
@@ -100,6 +131,8 @@ files:
|
|
100
131
|
- lib/mdarray/function_creation.rb
|
101
132
|
- lib/mdarray/function_map.rb
|
102
133
|
- lib/mdarray/hierarchy.rb
|
134
|
+
- lib/mdarray/lazy_mdarray.rb
|
135
|
+
- lib/mdarray/lazy_operators.rb
|
103
136
|
- lib/mdarray/operators.rb
|
104
137
|
- lib/mdarray/printing.rb
|
105
138
|
- lib/mdarray/proc_util.rb
|
@@ -114,6 +147,7 @@ files:
|
|
114
147
|
- test/complete.rb
|
115
148
|
- test/env.rb
|
116
149
|
- test/colt/test_complete.rb
|
150
|
+
- test/colt/test_math.rb
|
117
151
|
- test/colt/test_statistics.rb
|
118
152
|
- test/colt/test_stat_list.rb
|
119
153
|
- test/mdarray/arithmetic_casting.rb
|
@@ -124,16 +158,17 @@ files:
|
|
124
158
|
- test/mdarray/test_counter.rb
|
125
159
|
- test/mdarray/test_creation.rb
|
126
160
|
- test/mdarray/test_error.rb
|
161
|
+
- test/mdarray/test_lazy.rb
|
127
162
|
- test/mdarray/test_operator.rb
|
128
163
|
- test/mdarray/test_performance.rb
|
129
164
|
- test/mdarray/test_printing.rb
|
130
165
|
- test/mdarray/test_shape.rb
|
131
|
-
- test/mdarray/test_statistics.rb
|
132
166
|
- test/mdarray/test_trigonometry.rb
|
133
167
|
- test/mdarray/test_views.rb
|
134
168
|
- test/colt/VALE3.csv
|
135
169
|
- test/colt/VALE3_short-err.csv
|
136
170
|
- test/colt/VALE3_short.csv
|
171
|
+
- test/colt/ColtMethods.xlsx
|
137
172
|
- test/colt/VALE3.xlsx
|
138
173
|
- test/colt/VALE3_short.xlsx
|
139
174
|
- doc/BinaryOperator.html
|
@@ -199,6 +234,8 @@ files:
|
|
199
234
|
- doc/MDArray/IteratorFastInt.html
|
200
235
|
- doc/MDArray/IteratorFastLong.html
|
201
236
|
- doc/MDArray/IteratorFastShort.html
|
237
|
+
- vendor/commons-compiler.jar
|
238
|
+
- vendor/janino.jar
|
202
239
|
- vendor/netcdfAll-4.3.16.jar
|
203
240
|
- vendor/parallelcolt-0.10.0.jar
|
204
241
|
- target/helper.jar
|
@@ -220,10 +257,10 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
220
257
|
none: false
|
221
258
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
222
259
|
requirements:
|
223
|
-
- -
|
224
|
-
Pg==
|
260
|
+
- - ">="
|
225
261
|
- !ruby/object:Gem::Version
|
226
|
-
version:
|
262
|
+
version: !binary |-
|
263
|
+
MA==
|
227
264
|
none: false
|
228
265
|
requirements: []
|
229
266
|
rubyforge_project:
|
@@ -1,80 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require "test/unit"
|
3
|
-
require 'shoulda'
|
4
|
-
|
5
|
-
require 'mdarray'
|
6
|
-
|
7
|
-
class MDArrayTest < Test::Unit::TestCase
|
8
|
-
|
9
|
-
context "Statistics Tests" do
|
10
|
-
|
11
|
-
setup do
|
12
|
-
|
13
|
-
# create a byte array filled with 0's
|
14
|
-
@a = MDArray.typed_arange("double", 10_000)
|
15
|
-
@weight = MDArray.arange(10_000)
|
16
|
-
|
17
|
-
# create double array
|
18
|
-
@b = MDArray.double([2, 3, 4])
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
#-------------------------------------------------------------------------------------
|
23
|
-
#
|
24
|
-
#-------------------------------------------------------------------------------------
|
25
|
-
|
26
|
-
should "do stats operations" do
|
27
|
-
|
28
|
-
# read file VALE3. This file has a header that we need to discard. VALE3
|
29
|
-
# contains quote values from brazilian company VALE as obtained from Yahoo finance
|
30
|
-
# (quote vale3.SA)
|
31
|
-
vale3 = MDArray.double("VALE3_short.csv", true)
|
32
|
-
|
33
|
-
# in order to use statistics we need to reset_statistics on array vale3. This
|
34
|
-
# breaks version 0.4.3 statistics that did not require a call to reset_statistics.
|
35
|
-
vale3.reset_statistics
|
36
|
-
|
37
|
-
# sum all values of vale3. This does not make sense from a financial point of view.
|
38
|
-
# suming all values including dates... Not doing anything with the value, just
|
39
|
-
# checking that it works!
|
40
|
-
vale3.sum
|
41
|
-
|
42
|
-
# lets get only the open price for the whole period. We slice the vale3 on the
|
43
|
-
# second dimension and get the second column.
|
44
|
-
open = vale3.slice(1,1)
|
45
|
-
|
46
|
-
# getting descriptive statistics for the open value. open is a new MDArray, so
|
47
|
-
# we need to reset_statistics for open as well.
|
48
|
-
open.reset_statistics
|
49
|
-
|
50
|
-
p "Durbin Watson: #{open.durbin_watson}"
|
51
|
-
p "Geometric mean: #{open.geometric_mean}"
|
52
|
-
p "Kurtosis: #{open.kurtosis}"
|
53
|
-
p "Lag1: #{open.lag1}"
|
54
|
-
p "Max: #{open.max}"
|
55
|
-
p "Mean: #{open.mean}"
|
56
|
-
p "Mean deviation: #{open.mean_deviation}"
|
57
|
-
p "Median: #{open.median}"
|
58
|
-
p "Min: #{open.min}"
|
59
|
-
p "Moment3: #{open.moment3}"
|
60
|
-
p "Moment4: #{open.moment4}"
|
61
|
-
p "Product: #{open.product}"
|
62
|
-
p "Skew: #{open.skew}"
|
63
|
-
p "Standard deviation: #{open.standard_deviation}"
|
64
|
-
p "Standard error: #{open.standard_error}"
|
65
|
-
p "Variance: #{open.variance}"
|
66
|
-
|
67
|
-
end
|
68
|
-
|
69
|
-
end
|
70
|
-
|
71
|
-
end
|
72
|
-
|
73
|
-
=begin
|
74
|
-
assert_equal(49995000, @a.sum)
|
75
|
-
assert_equal(0, @a.min)
|
76
|
-
assert_equal(9999, @a.max)
|
77
|
-
assert_equal(4999.5, @a.mean)
|
78
|
-
assert_equal(6666.333333333333, @a.weighted_mean(@weight))
|
79
|
-
=end
|
80
|
-
|