scicom 0.2.0-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.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +674 -0
  3. data/README.md +66 -0
  4. data/README.md~ +290 -0
  5. data/Rakefile +51 -0
  6. data/config.rb +163 -0
  7. data/doc/PypeR.pdf +0 -0
  8. data/doc/Stat 133 Class Notes (Phil Spector).pdf +29905 -45
  9. data/doc/The R interface.docx +0 -0
  10. data/lib/JRubyR/as_mdarray.rb +60 -0
  11. data/lib/JRubyR/attributes.rb +74 -0
  12. data/lib/JRubyR/dataframe.rb +35 -0
  13. data/lib/JRubyR/environment.rb +60 -0
  14. data/lib/JRubyR/function.rb +61 -0
  15. data/lib/JRubyR/index.rb +278 -0
  16. data/lib/JRubyR/list.rb +56 -0
  17. data/lib/JRubyR/list_orig.rb +111 -0
  18. data/lib/JRubyR/logical_value.rb +56 -0
  19. data/lib/JRubyR/rbsexp.rb +386 -0
  20. data/lib/JRubyR/renjin.rb +431 -0
  21. data/lib/JRubyR/ruby_classes.rb +58 -0
  22. data/lib/JRubyR/sequence.rb +56 -0
  23. data/lib/JRubyR/vector.rb +493 -0
  24. data/lib/env.rb +12 -0
  25. data/lib/rinruby.rb +795 -0
  26. data/lib/scicom.rb +29 -0
  27. data/target/helper.jar +0 -0
  28. data/test/baseball.csv +1 -0
  29. data/test/env.rb +7 -0
  30. data/test/test_R_interface.rb +165 -0
  31. data/test/test_array.rb +191 -0
  32. data/test/test_attributes.rb +261 -0
  33. data/test/test_basic.rb +156 -0
  34. data/test/test_column-major.rb +114 -0
  35. data/test/test_complete.rb +49 -0
  36. data/test/test_creation.rb +299 -0
  37. data/test/test_dataframe.rb +248 -0
  38. data/test/test_distribution.rb +320 -0
  39. data/test/test_double_assign.rb +240 -0
  40. data/test/test_double_receive.rb +106 -0
  41. data/test/test_environment.rb +57 -0
  42. data/test/test_factor.rb +285 -0
  43. data/test/test_functions.rb +67 -0
  44. data/test/test_linear_model.rb +64 -0
  45. data/test/test_list.rb +220 -0
  46. data/test/test_matrix.rb +205 -0
  47. data/test/test_mdarray.rb +258 -0
  48. data/test/test_operators.rb +227 -0
  49. data/test/test_sequence.rb +63 -0
  50. data/test/test_subsetting.rb +67 -0
  51. data/test/test_tmp.rb +67 -0
  52. data/test/test_vector.rb +227 -0
  53. data/vendor/Renjin.pdf +0 -0
  54. data/vendor/renjin-script-engine-0.7.0-RC7-SNAPSHOT-jar-with-dependencies.jar +0 -0
  55. data/version.rb +2 -0
  56. metadata +196 -0
data/README.md ADDED
@@ -0,0 +1,66 @@
1
+ Announcement
2
+ ============
3
+
4
+ SciCom (Scientific Computing) for Ruby brings the power of R to the Ruby community. SciCom
5
+ is based on Renjin, a JVM-based interpreter for the R language for statistical computing.
6
+
7
+ R on the JVM
8
+ ------------
9
+
10
+ Over the past two decades, the R language for statistical computing has emerged as the de
11
+ facto standard for analysts, statisticians, and scientists. Today, a wide range of
12
+ enterprises – from pharmaceuticals to insurance – depend on R for key business uses. Renjin
13
+ is a new implementation of the R language and environment for the Java Virtual Machine (JVM),
14
+ whose goal is to enable transparent analysis of big data sets and seamless integration with
15
+ other enterprise systems such as databases and application servers.
16
+
17
+ Renjin is still under development, but it is already being used in production for a number
18
+ of client projects, and supports most CRAN packages, including some with C/Fortran
19
+ dependencies.
20
+
21
+ SciCom and Renjin
22
+ -----------------
23
+
24
+ SciCom integrates with Renjin and allows the use of R inside a Ruby script. In a sense,
25
+ SciCom is similar to other solutions such as RinRuby, Rpy2, PipeR, etc. However, since
26
+ SciCom and Renjin both target the JVM there is no need to integrate both solutions and
27
+ there is no need to send data between Ruby and R, as it all resides in the same JVM.
28
+ Further, installation of SciCom does not require the installation of GNU R; Renjin is the
29
+ interpreter and comes with SciCom. Finally, although SciCom provides a basic interface to
30
+ Renjin similar to RinRuby, a much tighter integration is also possible.
31
+
32
+ SciCom and Renjin Limitations
33
+ ------------------------------
34
+
35
+ Renjin is in development and still has some limitations
36
+
37
+ + Renjin does not allow dynamic loading of libaries. My understanding is that Renjin
38
+ developers are actually working on a new version on which loading of libraries will be
39
+ possible.
40
+ + Renjin does not implement any of the graphical libaries such as plot or ggplot. We
41
+ hope that this limitation will be solved not by implementing those libraries but by the
42
+ use of Ruby libraries from SciRuby such as NyaPlot (https://github.com/domitry/nyaplot)
43
+ or daru (https://github.com/v0dro/daru).
44
+
45
+
46
+ SciCom installation and download:
47
+ ==================================
48
+
49
+ + Install Jruby
50
+ + jruby –S gem install scicom
51
+
52
+ SciCom Homepages:
53
+ ==================
54
+
55
+ + http://rubygems.org/gems/scicom
56
+ + https://github.com/rbotafogo/scicom/wiki
57
+
58
+ Contributors:
59
+ =============
60
+ Contributors are welcome.
61
+
62
+ SciCom History:
63
+ ================
64
+
65
+ + 17/11//2014: Version 0.2.0 - Most R functionality available to SciCom
66
+ + 21/06/2014: Version 0.0.1 - Initial release
data/README.md~ ADDED
@@ -0,0 +1,290 @@
1
+ Announcement
2
+ ============
3
+
4
+ MDArray version 0.5.5 has Just been released. MDArray is a multi dimensional array implemented
5
+ for JRuby inspired by NumPy (www.numpy.org) and Masahiro Tanaka´s Narray (narray.rubyforge.org).
6
+ MDArray stands on the shoulders of Java-NetCDF and Parallel Colt. At this point MDArray has
7
+ libraries for linear algebra, mathematical, trigonometric and descriptive statistics methods.
8
+
9
+ NetCDF-Java Library is a Java interface to NetCDF files, as well as to many other types of
10
+ scientific data formats. It is developed and distributed by Unidata (http://www.unidata.ucar.edu).
11
+
12
+ Parallel Colt (https://sites.google.com/site/piotrwendykier/software/parallelcolt is a
13
+ multithreaded version of Colt (http://acs.lbl.gov/software/colt/). Colt provides a set of
14
+ Open Source Libraries for High Performance Scientific and Technical Computing in Java.
15
+ Scientific and technical computing is characterized by demanding problem sizes and a need for
16
+ high performance at reasonably small memory footprint.
17
+
18
+
19
+ What´s new:
20
+ ===========
21
+
22
+ Class MDMatrix and Linear Algebra Methods
23
+ -----------------------------------------
24
+
25
+ This version of MDArray introduces class MDMatrix. MDMatrix is a matrix class wrapping many
26
+ linear algebra methods from Parallel Colt (see below). MDMatrix support only the following
27
+ types: i) int; ii) long; iii) float and iv) double.
28
+
29
+ Differently from other libraries, in which matrix is a subclass of array, MDMatrix is a
30
+ twin class of MDArray. MDMatrix is a twin class of MDArray as every time an MDMatrix is
31
+ instantiated, an MDArray class is also instantiated. In reality, there is only one backing
32
+ store that can be viewed by either MDMatrix or MDArray.
33
+
34
+ Creation of MDMatrix follows the same API as MDArray API. For instance, creating a double
35
+ square matrix of size 5 x 5 can be done by:
36
+
37
+ matrix = MDMatrix.double([5, 5], [2.0, 0.0, 8.0, 6.0, 0.0,\
38
+ 1.0, 6.0, 0.0, 1.0, 7.0,\
39
+ 5.0, 0.0, 7.0, 4.0, 0.0,\
40
+ 7.0, 0.0, 8.0, 5.0, 0.0,\
41
+ 0.0, 10.0, 0.0, 0.0, 7.0])
42
+
43
+ Creating an int matrix filled with zero can be done by:
44
+
45
+ matrix = MDMatrix.int([4, 3])
46
+
47
+ MDMatrix also supports creation based on methods such as fromfunction, linspace, init_with,
48
+ arange, typed_arange and ones:
49
+
50
+
51
+ array = MDArray.typed_arange("double", 0, 15)
52
+ array = MDMatrix.fromfunction("double", [4, 4]) { |x, y| x + y }
53
+
54
+ An MDMatrix can also be created from an MDArray as follows:
55
+
56
+ d2 = MDArray.typed_arange("double", 0, 15)
57
+ double_matrix = MDMatrix.from_mdarray(d2)
58
+
59
+ An MDMatrix can only be created from MDArrays of one, two or three dimensions. However,
60
+ one can take a view from an MDArray to create an MDMatrix, as long as the view is at most
61
+ three dimensional:
62
+
63
+ # Instantiate an MDArray and shape it with 4 dimensions
64
+ > d1 = MDArray.typed_arange("double", 0, 420)
65
+ > d1.reshape!([5, 4, 3, 7])
66
+ # slice the array, getting a three dimensional array and from that, make a matrix
67
+ > matrix = MDMatrix.from_mdarray(d1.slice(0, 0))
68
+ # get a region from the array, with the first two dimensions of size 0, reduce it to a
69
+ # size two array and then build a two dimensional matrix
70
+ > matrix = MDMatrix.from_mdarray(d1.region(:spec => "0:0, 0:0, 0:2, 0:6").reduce)
71
+
72
+ printing the above two dimensional matrix gives us:
73
+
74
+ > matrix.print
75
+ 3 x 7 matrix
76
+ 0,00000 1,00000 2,00000 3,00000 4,00000 5,00000 6,00000
77
+ 7,00000 8,00000 9,00000 10,0000 11,0000 12,0000 13,0000
78
+ 14,0000 15,0000 16,0000 17,0000 18,0000 19,0000 20,0000
79
+
80
+ Every MDMatrix instance has a twin MDArray instance that uses the same backing store. This
81
+ allows the user to treat the data as either a matrix or an array and use methods either from
82
+ matrix or array. The above matrix can be printed as an array:
83
+
84
+
85
+ > matrix.mdarray.print
86
+ [[0.00 1.00 2.00 3.00 4.00 5.00 6.00]
87
+ [7.00 8.00 9.00 10.00 11.00 12.00 13.00]
88
+ [14.00 15.00 16.00 17.00 18.00 19.00 20.00]]
89
+
90
+ With an MDMatrix, many linear algebra methods can be easily calculated:
91
+
92
+ # basic operations on matrix can be done, such as, ‘+’, ‘-‘, ´*’, ‘/’
93
+ # make a 4 x 4 matrix and fill it with ´double´ 2.5
94
+ > a = MDMatrix.double([4, 4])
95
+ > a.fill(2.5)
96
+ > make a 4 x 4 matrix ´b´ from a given function (block)
97
+ > b = MDMatrix.fromfunction("double", [4, 4]) { |x, y| x + y }
98
+ # add both matrices
99
+ > c = a + b
100
+ # multiply by scalar
101
+ > c = a * 2
102
+ # divide two matrices. Matrix ´b´ has to be non-singular, otherwise an exception is
103
+ # raised.
104
+ # generate a non-singular matrix from a given matrix
105
+ > b.generate_non_singular!
106
+ > c = a / b
107
+
108
+ Linear algebra methods:
109
+
110
+ # create a matrix with the given data
111
+ > pos = MDArray.double([3, 3], [4, 12, -16, 12, 37, -43, -16, -43, 98])
112
+ > matrix = MDMatrix.from_mdarray(pos)
113
+ # Cholesky decomposition from wikipedia example
114
+ > chol = matrix.chol
115
+ > assert_equal(2, chol[0, 0])
116
+ > assert_equal(6, chol[1, 0])
117
+ > assert_equal(-8, chol[2, 0])
118
+ > assert_equal(5, chol[2, 1])
119
+ > assert_equal(3, chol[2, 2])
120
+
121
+ All other linear algebra methods are called the same way.
122
+
123
+
124
+ MDArray and SciRuby:
125
+ ====================
126
+
127
+ MDArray subscribes fully to the SciRuby Manifesto (http://sciruby.com/).
128
+
129
+ “Ruby has for some time had no equivalent to the beautifully constructed NumPy, SciPy, and
130
+ matplotlib libraries for Python.
131
+
132
+ We believe that the time for a Ruby science and visualization package has come. Sometimes
133
+ when a solution of sugar and water becomes super-saturated, from it precipitates a pure,
134
+ delicious, and diabetes-inducing crystal of sweetness, induced by no more than the tap of a
135
+ finger. So is occurring now, we believe, with numeric and visualization libraries for Ruby.”
136
+
137
+ MDArray main properties are:
138
+ ============================
139
+
140
+ + Homogeneous multidimensional array, a table of elements (usually numbers), all of the
141
+ same type, indexed by a tuple of positive integers;
142
+ + Support for many linear algebra methods (see bellow);
143
+ + Easy calculation for large numerical multi dimensional arrays;
144
+ + Basic types are: boolean, byte, short, int, long, float, double, string, structure;
145
+ + Based on JRuby, which allows importing Java libraries;
146
+ + Operator: +,-,*,/,%,**, >, >=, etc.;
147
+ + Functions: abs, ceil, floor, truncate, is_zero, square, cube, fourth;
148
+ + Binary Operators: &, |, ^, ~ (binary_ones_complement), <<, >>;
149
+ + Ruby Math functions: acos, acosh, asin, asinh, atan, atan2, atanh, cbrt, cos, erf, exp,
150
+ gamma, hypot, ldexp, log, log10, log2, sin, sinh, sqrt, tan, tanh, neg;
151
+ + Boolean operations on boolean arrays: and, or, not;
152
+ + Fast descriptive statistics from Parallel Colt (complete list found bellow);
153
+ + Easy manipulation of arrays: reshape, reduce dimension, permute, section, slice, etc.;
154
+ + Support for reading and writing NetCDF-3 files;
155
+ + Reading of two dimensional arrays from CSV files (mainly for debugging and simple testing
156
+ purposes);
157
+ + StatList: a list that can grow/shrink and that can compute Parallel Colt descriptive
158
+ statistics;
159
+ + Experimental lazy evaluation (still slower than eager evaluation).
160
+
161
+ Supported linear algebra methods:
162
+ =================================
163
+
164
+ + backwardSolve: Solves the upper triangular system U*x=b;
165
+ + chol: Constructs and returns the cholesky-decomposition of the given matrix.
166
+ + cond: Returns the condition of matrix A, which is the ratio of largest to smallest singular value.
167
+ + det: Returns the determinant of matrix A.
168
+ + eig: Constructs and returns the Eigenvalue-decomposition of the given matrix.
169
+ + forwardSolve: Solves the lower triangular system L*x=b;
170
+ + inverse: Returns the inverse or pseudo-inverse of matrix A.
171
+ + kron: Computes the Kronecker product of two real matrices.
172
+ + lu: Constructs and returns the LU-decomposition of the given matrix.
173
+ + mult: Inner product of two vectors; Sum(x[i] * y[i]).
174
+ + mult: Linear algebraic matrix-vector multiplication; z = A * y.
175
+ + mult: Linear algebraic matrix-matrix multiplication; C = A x B.
176
+ + multOuter: Outer product of two vectors; Sets A[i,j] = x[i] * y[j].
177
+ + norm1: Returns the one-norm of vector x, which is Sum(abs(x[i])).
178
+ + norm1: Returns the one-norm of matrix A, which is the maximum absolute column sum.
179
+ + norm2: Returns the two-norm (aka euclidean norm) of vector x; equivalent to Sqrt(mult(x,x)).
180
+ + norm2: Returns the two-norm of matrix A, which is the maximum singular value; obtained from SVD.
181
+ + normF: Returns the Frobenius norm of matrix A, which is Sqrt(Sum(A[i]2)).
182
+ + normF: Returns the Frobenius norm of matrix A, which is Sqrt(Sum(A[i,j]2)).
183
+ + normInfinity: Returns the infinity norm of vector x, which is Max(abs(x[i])).
184
+ + normInfinity: Returns the infinity norm of matrix A, which is the maximum absolute row sum.
185
+ + pow: Linear algebraic matrix power; B = Ak <==> B = A*A*...*A.
186
+ + qr: Constructs and returns the QR-decomposition of the given matrix.
187
+ + rank: Returns the effective numerical rank of matrix A, obtained from Singular Value Decomposition.
188
+ + solve: Solves A*x = b.
189
+ + solve: Solves A*X = B.
190
+ + solveTranspose: Solves X*A = B, which is also A'*X' = B'.
191
+ + svd: Constructs and returns the SingularValue-decomposition of the given matrix.
192
+ + trace: Returns the sum of the diagonal elements of matrix A; Sum(A[i,i]).
193
+ + trapezoidalLower: Modifies the matrix to be a lower trapezoidal matrix.
194
+ + vectorNorm2: Returns the two-norm (aka euclidean norm) of vector X.vectorize();
195
+ + xmultOuter: Outer product of two vectors; Returns a matrix with A[i,j] = x[i] * y[j].
196
+ + xpowSlow: Linear algebraic matrix power; B = Ak <==> B = A*A*...*A.
197
+
198
+ Properties´ methods tested on matrices:
199
+ =======================================
200
+
201
+ + density: Returns the matrix's fraction of non-zero cells; A.cardinality() / A.size().
202
+ + generate_non_singular!: Modifies the given square matrix A such that it is diagonally dominant by row and column, hence non-singular, hence invertible.
203
+ + diagonal?: A matrix A is diagonal if A[i,j] == 0 whenever i != j.
204
+ + diagonally_dominant_by_column?: A matrix A is diagonally dominant by column if the absolute value of each diagonal element is larger than the sum of the absolute values of the off-diagonal elements in the corresponding column.
205
+ + diagonally_dominant_by_row?: A matrix A is diagonally dominant by row if the absolute value of each diagonal element is larger than the sum of the absolute values of the off-diagonal elements in the corresponding row.
206
+ + identity?: A matrix A is an identity matrix if A[i,i] == 1 and all other cells are zero.
207
+ + lower_bidiagonal?: A matrix A is lower bidiagonal if A[i,j]==0 unless i==j || i==j+1.
208
+ + lower_triangular?: A matrix A is lower triangular if A[i,j]==0 whenever i < j.
209
+ + nonnegative?: A matrix A is non-negative if A[i,j] >= 0 holds for all cells.
210
+ + orthogonal?: A square matrix A is orthogonal if A*transpose(A) = I.
211
+ + positive?: A matrix A is positive if A[i,j] > 0 holds for all cells.
212
+ + singular?: A matrix A is singular if it has no inverse, that is, iff det(A)==0.
213
+ + skew_symmetric?: A square matrix A is skew-symmetric if A = -transpose(A), that is A[i,j] == -A[j,i].
214
+ + square?: A matrix A is square if it has the same number of rows and columns.
215
+ + strictly_lower_triangular?: A matrix A is strictly lower triangular if A[i,j]==0 whenever i <= j.
216
+ + strictly_triangular?: A matrix A is strictly triangular if it is triangular and its diagonal elements all equal 0.
217
+ + strictly_upper_triangular?: A matrix A is strictly upper triangular if A[i,j]==0 whenever i >= j.
218
+ + symmetric?: A matrix A is symmetric if A = tranpose(A), that is A[i,j] == A[j,i].
219
+ + triangular?: A matrix A is triangular iff it is either upper or lower triangular.
220
+ + tridiagonal?: A matrix A is tridiagonal if A[i,j]==0 whenever Math.abs(i-j) > 1.
221
+ + unit_triangular?: A matrix A is unit triangular if it is triangular and its diagonal elements all equal 1.
222
+ + upper_bidiagonal?: A matrix A is upper bidiagonal if A[i,j]==0 unless i==j || i==j-1.
223
+ + upper_triangular?: A matrix A is upper triangular if A[i,j]==0 whenever i > j.
224
+ + zero?: A matrix A is zero if all its cells are zero.
225
+ + lower_bandwidth: The lower bandwidth of a square matrix A is the maximum i-j for which A[i,j] is nonzero and i > j.
226
+ + semi_bandwidth: Returns the semi-bandwidth of the given square matrix A.
227
+ + upper_bandwidth: The upper bandwidth of a square matrix A is the maximum j-i for which A[i,j] is nonzero and j > i.
228
+
229
+ Descriptive statistics methods imported from Parallel Colt:
230
+ ===========================================================
231
+
232
+ + auto_correlation, correlation, covariance, durbin_watson, frequencies, geometric_mean,
233
+ + harmonic_mean, kurtosis, lag1, max, mean, mean_deviation, median, min, moment, moment3,
234
+ + moment4, pooled_mean, pooled_variance, product, quantile, quantile_inverse,
235
+ + rank_interpolated, rms, sample_covariance, sample_kurtosis, sample_kurtosis_standard_error,
236
+ + sample_skew, sample_skew_standard_error, sample_standard_deviation, sample_variance,
237
+ + sample_weighted_variance, skew, split, standard_deviation, standard_error, sum,
238
+ + sum_of_inversions, sum_of_logarithms, sum_of_powers, sum_of_power_deviations,
239
+ + sum_of_squares, sum_of_squared_deviations, trimmed_mean, variance, weighted_mean,
240
+ + weighted_rms, weighted_sums, winsorized_mean.
241
+
242
+ Double and Float methods from Parallel Colt:
243
+ ============================================
244
+
245
+ + acos, asin, atan, atan2, ceil, cos, exp, floor, greater, IEEEremainder, inv, less, lg,
246
+ + log, log2, rint, sin, sqrt, tan.
247
+
248
+ Double, Float, Long and Int methods from Parallel Colt:
249
+ =======================================================
250
+
251
+ + abs, compare, div, divNeg, equals, isEqual (is_equal), isGreater (is_greater),
252
+ + isles (is_less), max, min, minus, mod, mult, multNeg (mult_neg), multSquare (mult_square),
253
+ + neg, plus (add), plusAbs (plus_abs), pow (power), sign, square.
254
+
255
+ Long and Int methods from Parallel Colt
256
+ =======================================
257
+
258
+ + and, dec, factorial, inc, not, or, shiftLeft (shift_left), shiftRightSigned
259
+ (shift_right_signed), shiftRightUnsigned (shift_right_unsigned), xor.
260
+
261
+ MDArray installation and download:
262
+ ==================================
263
+
264
+ + Install Jruby
265
+ + jruby –S gem install mdarray
266
+
267
+ MDArray Homepages:
268
+ ==================
269
+
270
+ + http://rubygems.org/gems/mdarray
271
+ + https://github.com/rbotafogo/mdarray/wiki
272
+
273
+ Contributors:
274
+ =============
275
+ Contributors are welcome.
276
+
277
+ MDArray History:
278
+ ================
279
+
280
+ + 14/11/2013: Version 0.5.5 - Support for linear algebra methods
281
+ + 07/08/2013: Version 0.5.4 - Support for reading and writing NetCDF-3 files
282
+ + 24/06/2013: Version 0.5.3 – Over 90% Performance improvements for methods imported
283
+ from Parallel Colt and over 40% performance improvements for all other methods
284
+ (implemented in Ruby);
285
+ + 16/05/2013: Version 0.5.0 - All loops transferred to Java with over 50% performance
286
+ improvements. Descriptive statistics from Parallel Colt;
287
+ + 19/04/2013: Version 0.4.3 - Fixes a simple, but fatal bug in 0.4.2. No new features;
288
+ + 17/04/2013: Version 0.4.2 - Adds simple statistics and boolean operators;
289
+ + 05/04/2013: Version 0.4.0 – Initial release.
290
+
data/Rakefile ADDED
@@ -0,0 +1,51 @@
1
+ require 'rake/testtask'
2
+ require_relative 'version'
3
+
4
+ name = "#{$gem_name}-#{$version}.gem"
5
+
6
+ rule '.class' => '.java' do |t|
7
+ sh "javac #{t.source}"
8
+ end
9
+
10
+ desc 'default task'
11
+ task :default => [:install_gem]
12
+
13
+ desc 'Makes a Gem'
14
+ task :make_gem do
15
+ sh "gem build #{$gem_name}.gemspec"
16
+ end
17
+
18
+ desc 'Install the gem in the standard location'
19
+ task :install_gem => [:make_gem] do
20
+ sh "gem install #{$gem_name}-#{$version}-java.gem"
21
+ end
22
+
23
+ desc 'Make documentation'
24
+ task :make_doc do
25
+ sh "yard doc lib/*.rb lib/**/*.rb"
26
+ end
27
+
28
+ desc 'Push project to github'
29
+ task :push do
30
+ sh "git push origin master"
31
+ end
32
+
33
+ desc 'Push gem to rubygem'
34
+ task :push_gem do
35
+ sh "push #{name} -p $http_proxy"
36
+ end
37
+
38
+ desc 'Counts the number of lines of ruby code'
39
+ task :count do
40
+ sh "find . -name '*.rb' | xargs wc -l"
41
+ end
42
+
43
+ Rake::TestTask.new do |t|
44
+ t.libs << "test"
45
+ t.test_files = FileList['test/complete.rb']
46
+ t.ruby_opts = ["--server", "-Xinvokedynamic.constants=true", "-J-Xmn512m",
47
+ "-J-Xms1024m", "-J-Xmx1024m"]
48
+ t.verbose = true
49
+ t.warning = true
50
+ end
51
+
data/config.rb ADDED
@@ -0,0 +1,163 @@
1
+ require 'rbconfig'
2
+
3
+ ##########################################################################################
4
+ # Configuration. Remove setting before publishing Gem.
5
+ ##########################################################################################
6
+
7
+ # set to true if development environment
8
+ # $DVLP = true
9
+
10
+ # Set to 'cygwin' when in cygwin
11
+ # $ENV = 'cygwin'
12
+
13
+ # Set development dependency: those are gems that are also in development and thus not
14
+ # installed in the gem directory. Need a way of accessing them
15
+ # $DEPEND=["MDArray"]
16
+
17
+ ##########################################################################################
18
+
19
+ # the platform
20
+ @platform =
21
+ case RUBY_PLATFORM
22
+ when /mswin/ then 'windows'
23
+ when /mingw/ then 'windows'
24
+ when /bccwin/ then 'windows'
25
+ when /cygwin/ then 'windows-cygwin'
26
+ when /java/
27
+ require 'java' #:nodoc:
28
+ if java.lang.System.getProperty("os.name") =~ /[Ww]indows/
29
+ 'windows-java'
30
+ else
31
+ 'default-java'
32
+ end
33
+ else 'default'
34
+ end
35
+
36
+ #---------------------------------------------------------------------------------------
37
+ # Add path to load path
38
+ #---------------------------------------------------------------------------------------
39
+
40
+ def mklib(path, home_path = true)
41
+
42
+ if (home_path)
43
+ lib = path + "/lib"
44
+ else
45
+ lib = path
46
+ end
47
+
48
+ $LOAD_PATH << lib
49
+
50
+ end
51
+
52
+ ##########################################################################################
53
+ # Prepare environment to work inside Cygwin
54
+ ##########################################################################################
55
+
56
+ if $ENV == 'cygwin'
57
+
58
+ #---------------------------------------------------------------------------------------
59
+ # Return the cygpath of a path
60
+ #---------------------------------------------------------------------------------------
61
+
62
+ def set_path(path)
63
+ `cygpath -a -p -m #{path}`.tr("\n", "")
64
+ end
65
+
66
+ else
67
+
68
+ #---------------------------------------------------------------------------------------
69
+ # Return the path
70
+ #---------------------------------------------------------------------------------------
71
+
72
+ def set_path(path)
73
+ path
74
+ end
75
+
76
+ end
77
+
78
+ #---------------------------------------------------------------------------------------
79
+ # Set the project directories
80
+ #---------------------------------------------------------------------------------------
81
+
82
+ class SciCom
83
+
84
+ @home_dir = File.expand_path File.dirname(__FILE__)
85
+
86
+ class << self
87
+ attr_reader :home_dir
88
+ end
89
+
90
+ @project_dir = SciCom.home_dir + "/.."
91
+ @doc_dir = SciCom.home_dir + "/doc"
92
+ @lib_dir = SciCom.home_dir + "/lib"
93
+ @src_dir = SciCom.home_dir + "/src"
94
+ @target_dir = SciCom.home_dir + "/target"
95
+ @test_dir = SciCom.home_dir + "/test"
96
+ @vendor_dir = SciCom.home_dir + "/vendor"
97
+
98
+ class << self
99
+ attr_reader :project_dir
100
+ attr_reader :doc_dir
101
+ attr_reader :lib_dir
102
+ attr_reader :src_dir
103
+ attr_reader :target_dir
104
+ attr_reader :test_dir
105
+ attr_reader :vendor_dir
106
+ end
107
+
108
+ @build_dir = SciCom.src_dir + "/build"
109
+
110
+ class << self
111
+ attr_reader :build_dir
112
+ end
113
+
114
+ @classes_dir = SciCom.build_dir + "/classes"
115
+
116
+ class << self
117
+ attr_reader :classes_dir
118
+ end
119
+
120
+ end
121
+
122
+ #---------------------------------------------------------------------------------------
123
+ # Set dependencies
124
+ #---------------------------------------------------------------------------------------
125
+
126
+ def depend(name)
127
+
128
+ dependency_dir = SciCom.project_dir + "/" + name
129
+ mklib(dependency_dir)
130
+
131
+ end
132
+
133
+ ##########################################################################################
134
+ # If development
135
+ ##########################################################################################
136
+
137
+ if ($DVLP == true)
138
+
139
+ mklib(SciCom.home_dir)
140
+
141
+ # Add dependencies here
142
+ # depend(<other_gems>)
143
+ $DEPEND.each do |dep|
144
+ depend(dep)
145
+ end if $DEPEND
146
+
147
+ #----------------------------------------------------------------------------------------
148
+ # If we need to test for coverage
149
+ #----------------------------------------------------------------------------------------
150
+
151
+ if $COVERAGE == 'true'
152
+
153
+ require 'simplecov'
154
+
155
+ SimpleCov.start do
156
+ @filters = []
157
+ add_group "SciCom", "lib/scicom"
158
+ end
159
+
160
+ end
161
+
162
+ end
163
+