mdarray 0.5.5.2-java → 0.5.6-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.
- checksums.yaml +4 -4
- data/config.rb +29 -95
- data/doc/BinaryOperator.html +20 -21
- data/doc/BitwiseOperators.html +18 -8
- data/doc/BitwiseOperators/BinaryAnd.html +189 -0
- data/doc/BitwiseOperators/BinaryLeftShift.html +189 -0
- data/doc/BitwiseOperators/BinaryOnesComplement.html +189 -0
- data/doc/BitwiseOperators/BinaryOr.html +189 -0
- data/doc/BitwiseOperators/BinaryRightShift.html +189 -0
- data/doc/BitwiseOperators/BinaryXor.html +189 -0
- data/doc/BooleanFunctions.html +18 -8
- data/doc/BooleanFunctions/And.html +189 -0
- data/doc/BooleanFunctions/Not.html +189 -0
- data/doc/BooleanFunctions/Or.html +189 -0
- data/doc/BooleanMDArray.html +10 -10
- data/doc/ByteMDArray.html +73 -14
- data/doc/CernDoubleFunctions.html +208 -0
- data/doc/CernFloatFunctions.html +208 -0
- data/doc/CernFunctions.html +828 -0
- data/doc/CernIntFunctions.html +208 -0
- data/doc/CernLongFunctions.html +208 -0
- data/doc/CharMDArray.html +181 -0
- data/doc/Colt.html +18 -20
- data/doc/ComparisonOperators.html +18 -8
- data/doc/ComparisonOperators/Eq.html +189 -0
- data/doc/ComparisonOperators/Ge.html +189 -0
- data/doc/ComparisonOperators/Gt.html +189 -0
- data/doc/ComparisonOperators/Le.html +189 -0
- data/doc/ComparisonOperators/Lt.html +189 -0
- data/doc/Const.html +107 -47
- data/doc/Csv.html +325 -113
- data/doc/Csv/Dimension.html +771 -0
- data/doc/Csv/Dimensions.html +654 -0
- data/doc/DDescriptive.html +573 -625
- data/doc/DoubleMDArray.html +40 -172
- data/doc/DoubleStatList.html +19 -20
- data/doc/FastBinaryOperator.html +166 -148
- data/doc/FastUnaryOperator.html +104 -109
- data/doc/FloatMDArray.html +55 -16
- data/doc/FunctionCreation.html +53 -273
- data/doc/FunctionMap.html +381 -93
- data/doc/GenericFunctions.html +18 -8
- data/doc/GenericFunctions/Null.html +187 -0
- data/doc/IntMDArray.html +77 -16
- data/doc/Java/CernJetMathTdouble/DoubleFunctions.html +120 -0
- data/doc/Java/CernJetMathTfloat/FloatFunctions.html +120 -0
- data/doc/Java/CernJetMathTint/IntFunctions.html +120 -0
- data/doc/Java/CernJetMathTlong/LongFunctions.html +120 -0
- data/doc/LazyBinaryOperator.html +714 -0
- data/doc/LazyMDArray.html +990 -0
- data/doc/LazyMDArray/BinaryComp.html +282 -0
- data/doc/LazyMDArray/UnaryComp.html +280 -0
- data/doc/LazyUnaryOperator.html +537 -0
- data/doc/LongMDArray.html +59 -15
- data/doc/MDArray.html +3223 -2181
- data/doc/MDArray/Counter.html +321 -1233
- data/doc/MDArray/IteratorFast.html +177 -116
- data/doc/MDArray/IteratorFastBoolean.html +37 -41
- data/doc/MDArray/IteratorFastByte.html +46 -39
- data/doc/MDArray/IteratorFastChar.html +37 -41
- data/doc/MDArray/IteratorFastDouble.html +37 -41
- data/doc/MDArray/IteratorFastFloat.html +37 -41
- data/doc/MDArray/IteratorFastInt.html +37 -41
- data/doc/MDArray/IteratorFastLong.html +37 -41
- data/doc/MDArray/IteratorFastShort.html +37 -41
- data/doc/MDArray/Section.html +561 -0
- data/doc/Nashorn.html +1407 -0
- data/doc/NetCDF.html +749 -0
- data/doc/NetCDF/Attribute.html +875 -0
- data/doc/NetCDF/AttributeWriter.html +286 -0
- data/doc/NetCDF/CDMNode.html +460 -0
- data/doc/NetCDF/Dimension.html +559 -0
- data/doc/NetCDF/DimensionWriter.html +642 -0
- data/doc/NetCDF/File.html +1593 -0
- data/doc/NetCDF/FileParent.html +674 -0
- data/doc/NetCDF/FileWriter.html +2875 -0
- data/doc/NetCDF/Group.html +685 -0
- data/doc/NetCDF/GroupWriter.html +851 -0
- data/doc/NetCDF/TimeVariable.html +646 -0
- data/doc/NetCDF/Variable.html +2994 -0
- data/doc/NetCDF/VariableWriter.html +420 -0
- data/doc/NonNumericalMDArray.html +11 -11
- data/doc/NumericFunctions.html +38 -30
- data/doc/NumericFunctions/Abs.html +189 -0
- data/doc/NumericFunctions/Add.html +189 -0
- data/doc/NumericFunctions/Ceil.html +189 -0
- data/doc/NumericFunctions/Cube.html +189 -0
- data/doc/NumericFunctions/Div.html +189 -0
- data/doc/NumericFunctions/Floor.html +189 -0
- data/doc/NumericFunctions/Fourth.html +189 -0
- data/doc/NumericFunctions/IsZero.html +189 -0
- data/doc/NumericFunctions/Max.html +189 -0
- data/doc/NumericFunctions/Min.html +189 -0
- data/doc/NumericFunctions/Mul.html +189 -0
- data/doc/NumericFunctions/Power.html +189 -0
- data/doc/NumericFunctions/Square.html +189 -0
- data/doc/NumericFunctions/Sub.html +189 -0
- data/doc/NumericFunctions/Truncate.html +189 -0
- data/doc/NumericalMDArray.html +14 -15
- data/doc/Operator.html +318 -109
- data/doc/Proc.html +120 -129
- data/doc/RubyBinaryOperator.html +66 -70
- data/doc/RubyFunctions.html +572 -27
- data/doc/RubyMath.html +18 -8
- data/doc/RubyMath/Acos.html +189 -0
- data/doc/RubyMath/Acosh.html +189 -0
- data/doc/RubyMath/Asin.html +189 -0
- data/doc/RubyMath/Asinh.html +189 -0
- data/doc/RubyMath/Atan.html +189 -0
- data/doc/RubyMath/Atan2.html +189 -0
- data/doc/RubyMath/Atanh.html +189 -0
- data/doc/RubyMath/Cbrt.html +189 -0
- data/doc/RubyMath/Cos.html +189 -0
- data/doc/RubyMath/Cosh.html +189 -0
- data/doc/RubyMath/Erf.html +189 -0
- data/doc/RubyMath/Erfc.html +189 -0
- data/doc/RubyMath/Exp.html +189 -0
- data/doc/RubyMath/Gamma.html +189 -0
- data/doc/RubyMath/Hypot.html +189 -0
- data/doc/RubyMath/Ldexp.html +189 -0
- data/doc/RubyMath/Log.html +189 -0
- data/doc/RubyMath/Log10.html +189 -0
- data/doc/RubyMath/Log2.html +189 -0
- data/doc/RubyMath/Neg.html +189 -0
- data/doc/RubyMath/Sin.html +189 -0
- data/doc/RubyMath/Sinh.html +189 -0
- data/doc/RubyMath/Sqrt.html +189 -0
- data/doc/RubyMath/Tan.html +189 -0
- data/doc/RubyMath/Tanh.html +189 -0
- data/doc/RubyStats.html +8 -8
- data/doc/RubyUnaryOperator.html +61 -65
- data/doc/ShortMDArray.html +69 -14
- data/doc/Sol.html +700 -0
- data/doc/Sol/BarChart.html +181 -0
- data/doc/Sol/BaseChart.html +800 -0
- data/doc/Sol/Bootstrap.html +1137 -0
- data/doc/Sol/Bridge.html +586 -0
- data/doc/Sol/Chart.html +1162 -0
- data/doc/Sol/CoordinateChart.html +679 -0
- data/doc/Sol/Dashboard.html +2094 -0
- data/doc/Sol/Dashboard/DCFX.html +786 -0
- data/doc/Sol/Dashboard/MyHandle.html +338 -0
- data/doc/Sol/Dashboard/MyService.html +202 -0
- data/doc/Sol/Dashboard/MyTask.html +291 -0
- data/doc/Sol/Interval.html +1213 -0
- data/doc/Sol/LineChart.html +346 -0
- data/doc/Sol/LinearScale.html +334 -0
- data/doc/Sol/Margins.html +219 -0
- data/doc/Sol/OrdinalScale.html +263 -0
- data/doc/Sol/Scale.html +462 -0
- data/doc/Sol/Stack.html +199 -0
- data/doc/Sol/TimeScale.html +397 -0
- data/doc/StatList.html +110 -125
- data/doc/StringMDArray.html +10 -10
- data/doc/StructureMDArray.html +10 -10
- data/doc/UnaryOperator.html +20 -21
- data/doc/UserFunction.html +51 -49
- data/doc/_index.html +881 -106
- data/doc/class_list.html +8 -3
- data/doc/css/style.css +2 -1
- data/doc/file.README.html +455 -104
- data/doc/file_list.html +7 -2
- data/doc/frames.html +5 -7
- data/doc/index.html +455 -104
- data/doc/js/app.js +7 -2
- data/doc/js/full_list.js +11 -3
- data/doc/method_list.html +3170 -1233
- data/doc/top-level-namespace.html +31 -8
- data/lib/colt/matrix/algebra.rb +5 -5
- data/lib/mdarray.rb +6 -3
- data/lib/mdarray/csv.rb +25 -5
- data/lib/mdarray/fast_operators.rb +1 -1
- data/lib/mdarray/function_creation.rb +3 -1
- data/lib/mdarray/hierarchy.rb +2 -0
- data/lib/mdarray/operators.rb +1 -1
- data/lib/mdarray/ruby_functions.rb +8 -4
- data/lib/mdarray/ruby_math.rb +0 -28
- data/test/colt/matrix/test_matrix2d_floatingalgebra.rb +31 -7
- data/test/complete.rb +4 -4
- data/test/mdarray/PETR4_2014.csv +249 -0
- data/test/mdarray/VALE_2014.csv +253 -0
- data/test/mdarray/VALE_PETR4.csv +501 -0
- data/test/mdarray/arithmetic_casting.rb +1 -0
- data/test/mdarray/test_access.rb +1 -0
- data/test/mdarray/test_boolean.rb +1 -0
- data/test/mdarray/test_comparison.rb +1 -0
- data/test/mdarray/test_complete.rb +2 -5
- data/test/mdarray/test_counter.rb +1 -0
- data/test/mdarray/test_creation.rb +1 -0
- data/test/mdarray/test_csv.rb +51 -0
- data/test/mdarray/test_error.rb +1 -0
- data/test/mdarray/test_non_numeric.rb +1 -1
- data/test/mdarray/test_operator.rb +31 -14
- data/test/mdarray/test_performance.rb +2 -1
- data/test/mdarray/test_printing.rb +1 -0
- data/test/mdarray/test_sections.rb +1 -0
- data/test/mdarray/test_shape.rb +1 -0
- data/test/mdarray/test_trigonometry.rb +1 -0
- data/test/mdarray/test_views.rb +1 -0
- data/vendor/mdarray.jar +0 -0
- data/vendor/{netcdfAll-4.5_0.jar → netcdfAll-4.6.jar} +0 -0
- data/vendor/slf4j-jdk14-1.7.12.jar +0 -0
- data/version.rb +1 -1
- metadata +247 -139
- data/lib/env.rb +0 -12
- data/lib/mdarray/lazy_mdarray.rb +0 -315
- data/lib/mdarray/lazy_operators.rb +0 -174
- data/test/env.rb +0 -8
- data/test/mdarray/test_lazy.rb +0 -306
data/lib/env.rb
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
require 'java'
|
|
2
|
-
require_relative '../config.rb'
|
|
3
|
-
|
|
4
|
-
$CLASSPATH << "#{File.dirname(__FILE__)}/../vendor/"
|
|
5
|
-
|
|
6
|
-
Dir["#{File.dirname(__FILE__)}/../vendor/*.jar"].each do |jar|
|
|
7
|
-
require jar
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
Dir["#{File.dirname(__FILE__)}/../target/*.jar"].each do |jar|
|
|
11
|
-
require jar
|
|
12
|
-
end
|
data/lib/mdarray/lazy_mdarray.rb
DELETED
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
|
-
##########################################################################################
|
|
4
|
-
# Copyright © 2013 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
|
|
5
|
-
# and distribute this software and its documentation for educational, research, and
|
|
6
|
-
# not-for-profit purposes, without fee and without a signed licensing agreement, is hereby
|
|
7
|
-
# granted, provided that the above copyright notice, this paragraph and the following two
|
|
8
|
-
# paragraphs appear in all copies, modifications, and distributions. Contact Rodrigo
|
|
9
|
-
# Botafogo - rodrigo.a.botafogo@gmail.com for commercial licensing opportunities.
|
|
10
|
-
#
|
|
11
|
-
# IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
|
|
12
|
-
# INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF
|
|
13
|
-
# THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE
|
|
14
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
|
15
|
-
#
|
|
16
|
-
# RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
17
|
-
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
|
|
18
|
-
# SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS".
|
|
19
|
-
# RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
|
|
20
|
-
# OR MODIFICATIONS.
|
|
21
|
-
##########################################################################################
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
##########################################################################################
|
|
25
|
-
#
|
|
26
|
-
##########################################################################################
|
|
27
|
-
|
|
28
|
-
class LazyMDArray < ByteMDArray
|
|
29
|
-
include_package "ucar.ma2"
|
|
30
|
-
include_package "org.codehaus.janino"
|
|
31
|
-
|
|
32
|
-
attr_reader :stack
|
|
33
|
-
|
|
34
|
-
#=======================================================================================
|
|
35
|
-
# Class BinaryComp applies a function f to two arguments. The arguments can be
|
|
36
|
-
# functions on their own right
|
|
37
|
-
#=======================================================================================
|
|
38
|
-
|
|
39
|
-
class BinaryComp
|
|
40
|
-
|
|
41
|
-
def initialize(f, x, y, *args)
|
|
42
|
-
@x = x
|
|
43
|
-
@y = y
|
|
44
|
-
@f = f
|
|
45
|
-
@other_args = args
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def apply
|
|
49
|
-
@f.apply(@x.apply, @y.apply)
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
end # BinaryComp
|
|
53
|
-
|
|
54
|
-
#=======================================================================================
|
|
55
|
-
# Class UnaryComp applies a function f to one arguments. The arguments can be a
|
|
56
|
-
# function on its own right
|
|
57
|
-
#=======================================================================================
|
|
58
|
-
|
|
59
|
-
class UnaryComp
|
|
60
|
-
|
|
61
|
-
def initialize(f, x, *args)
|
|
62
|
-
@x = x
|
|
63
|
-
@f = f
|
|
64
|
-
@other_args = args
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def apply
|
|
68
|
-
@f.apply(@x.apply)
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
end # UnaryComp
|
|
72
|
-
|
|
73
|
-
#=======================================================================================
|
|
74
|
-
#
|
|
75
|
-
#=======================================================================================
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
#---------------------------------------------------------------------------------------
|
|
79
|
-
#
|
|
80
|
-
#---------------------------------------------------------------------------------------
|
|
81
|
-
|
|
82
|
-
def initialize
|
|
83
|
-
|
|
84
|
-
@stack = Array.new
|
|
85
|
-
@type = "lazy"
|
|
86
|
-
@previous_binary_operator = nil
|
|
87
|
-
@previous_unary_operator = nil
|
|
88
|
-
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
#---------------------------------------------------------------------------------------
|
|
92
|
-
#
|
|
93
|
-
#---------------------------------------------------------------------------------------
|
|
94
|
-
|
|
95
|
-
def push(elmt)
|
|
96
|
-
@stack << elmt
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
#---------------------------------------------------------------------------------------
|
|
100
|
-
#
|
|
101
|
-
#---------------------------------------------------------------------------------------
|
|
102
|
-
|
|
103
|
-
def pop
|
|
104
|
-
@stack.pop
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
#---------------------------------------------------------------------------------------
|
|
108
|
-
#
|
|
109
|
-
#---------------------------------------------------------------------------------------
|
|
110
|
-
|
|
111
|
-
def test_janino_function
|
|
112
|
-
$exp = ExpressionEvaluator.new
|
|
113
|
-
$exp.setExpressionType(Java::CernColtFunctionTdouble::DoubleFunction.java_class)
|
|
114
|
-
class_type = Java::JavaLang::Class.forName("java.lang.Class")
|
|
115
|
-
array = Java::JavaLangReflect::Array.newInstance(class_type, 2)
|
|
116
|
-
array[0] = Java::double.java_class
|
|
117
|
-
array[1] = Java::double.java_class
|
|
118
|
-
$exp.setParameters(["a", "b"].to_java(:string),
|
|
119
|
-
array)
|
|
120
|
-
$exp.cook("a + b")
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
#---------------------------------------------------------------------------------------
|
|
124
|
-
#
|
|
125
|
-
#---------------------------------------------------------------------------------------
|
|
126
|
-
|
|
127
|
-
def apply(*args)
|
|
128
|
-
|
|
129
|
-
type, shape, function = validate_fast(args)
|
|
130
|
-
|
|
131
|
-
result = MDArray.build(type, shape)
|
|
132
|
-
helper = Java::RbMdarrayLoopsLazy::DefaultLazyOperator
|
|
133
|
-
helper.send("apply", result.nc_array, function)
|
|
134
|
-
result
|
|
135
|
-
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
alias :[] :apply
|
|
139
|
-
|
|
140
|
-
#---------------------------------------------------------------------------------------
|
|
141
|
-
# Shows this LazyMDArray in Reverse Polish Notation. Mainly for debugging purposes.
|
|
142
|
-
#---------------------------------------------------------------------------------------
|
|
143
|
-
|
|
144
|
-
def rpn(nl = true)
|
|
145
|
-
|
|
146
|
-
exp = String.new
|
|
147
|
-
|
|
148
|
-
@stack.each do |elmt|
|
|
149
|
-
|
|
150
|
-
if (elmt.is_a? LazyMDArray)
|
|
151
|
-
exp << elmt.rpn(false)
|
|
152
|
-
elsif (elmt.is_a? Numeric)
|
|
153
|
-
exp << elmt << " "
|
|
154
|
-
elsif (elmt.is_a? Operator)
|
|
155
|
-
exp << elmt.name << " "
|
|
156
|
-
elsif (elmt.is_a? MDArray)
|
|
157
|
-
exp << elmt.type << " "
|
|
158
|
-
else
|
|
159
|
-
raise "Wrong element type in Array"
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
exp
|
|
165
|
-
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
#---------------------------------------------------------------------------------------
|
|
169
|
-
#
|
|
170
|
-
#---------------------------------------------------------------------------------------
|
|
171
|
-
|
|
172
|
-
def print
|
|
173
|
-
Kernel.print "[Lazy MDArray]\n"
|
|
174
|
-
p rpn
|
|
175
|
-
end
|
|
176
|
-
|
|
177
|
-
#---------------------------------------------------------------------------------------
|
|
178
|
-
#
|
|
179
|
-
#---------------------------------------------------------------------------------------
|
|
180
|
-
|
|
181
|
-
protected
|
|
182
|
-
|
|
183
|
-
#---------------------------------------------------------------------------------------
|
|
184
|
-
# Validates the expression checking if it can be performed: all dimensions need to be
|
|
185
|
-
# compatible
|
|
186
|
-
#---------------------------------------------------------------------------------------
|
|
187
|
-
|
|
188
|
-
def validate_fast(*args)
|
|
189
|
-
|
|
190
|
-
# test_janino_function
|
|
191
|
-
# p "validade_fast compile janino expression:"
|
|
192
|
-
# $exp.apply(100, 100)
|
|
193
|
-
|
|
194
|
-
helper_stack = Array.new
|
|
195
|
-
|
|
196
|
-
@stack.each do |elmt|
|
|
197
|
-
|
|
198
|
-
if (elmt.is_a? LazyMDArray)
|
|
199
|
-
helper_stack << elmt.validate_fast(*args)
|
|
200
|
-
elsif (elmt.is_a? MDArray)
|
|
201
|
-
# helper_stack << [elmt.type, elmt.shape, index_func(elmt)]
|
|
202
|
-
# iterator = elmt.nc_array.getIndexIterator
|
|
203
|
-
java_proc = Java::RbMdarrayUtil::Util.getIterator(elmt.nc_array)
|
|
204
|
-
helper_stack << [elmt.type, elmt.shape, java_proc]
|
|
205
|
-
elsif (elmt.is_a? Numeric)
|
|
206
|
-
# const_func is inefficient... fix!!!
|
|
207
|
-
helper_stack << ["numeric", 1, const_func(elmt)]
|
|
208
|
-
elsif (elmt.is_a? Operator)
|
|
209
|
-
case elmt.arity
|
|
210
|
-
when 1
|
|
211
|
-
top = helper_stack.pop
|
|
212
|
-
fmap = MDArray.select_function(elmt.name, MDArray.functions, top[0],
|
|
213
|
-
top[0], "void")
|
|
214
|
-
helper_stack <<
|
|
215
|
-
[top[0], top[1],
|
|
216
|
-
# UnaryComp.new(top[2], fmap.function, elmt.other_args)]
|
|
217
|
-
Java::RbMdarrayUtil::Util.compose(fmap.function, top[2])]
|
|
218
|
-
when 2
|
|
219
|
-
top1, top2 = helper_stack.pop(2)
|
|
220
|
-
if (top1[1] != top2[1] && top1[0] != "numeric" && top2[0] != "numeric")
|
|
221
|
-
raise "Expression involves incopatible arrays. #{top1[1]} != #{top2[1]}"
|
|
222
|
-
end
|
|
223
|
-
type = MDArray.upcast(top1[0], top2[0])
|
|
224
|
-
fmap = MDArray.select_function(elmt.name, MDArray.functions, type, type, type)
|
|
225
|
-
helper_stack <<
|
|
226
|
-
[type, top1[1],
|
|
227
|
-
Java::RbMdarrayUtil::Util.compose(fmap.function, top1[2], top2[2])]
|
|
228
|
-
end
|
|
229
|
-
else
|
|
230
|
-
raise "Expression is invalid: element #{elmt} is not valid in this position."
|
|
231
|
-
end
|
|
232
|
-
|
|
233
|
-
end
|
|
234
|
-
|
|
235
|
-
helper_stack[0]
|
|
236
|
-
|
|
237
|
-
end
|
|
238
|
-
|
|
239
|
-
#---------------------------------------------------------------------------------------
|
|
240
|
-
#
|
|
241
|
-
#---------------------------------------------------------------------------------------
|
|
242
|
-
|
|
243
|
-
private
|
|
244
|
-
|
|
245
|
-
#---------------------------------------------------------------------------------------
|
|
246
|
-
#
|
|
247
|
-
#---------------------------------------------------------------------------------------
|
|
248
|
-
|
|
249
|
-
def const_func(val)
|
|
250
|
-
Proc.new { |index| val }
|
|
251
|
-
end
|
|
252
|
-
|
|
253
|
-
#---------------------------------------------------------------------------------------
|
|
254
|
-
#
|
|
255
|
-
#---------------------------------------------------------------------------------------
|
|
256
|
-
|
|
257
|
-
def index_func(a)
|
|
258
|
-
Proc.new { |index| a.jget(index) }
|
|
259
|
-
end
|
|
260
|
-
|
|
261
|
-
#---------------------------------------------------------------------------------------
|
|
262
|
-
#
|
|
263
|
-
#---------------------------------------------------------------------------------------
|
|
264
|
-
|
|
265
|
-
def get_next_func(a)
|
|
266
|
-
Proc.new { a.getObjectNext() }
|
|
267
|
-
end
|
|
268
|
-
|
|
269
|
-
#---------------------------------------------------------------------------------------
|
|
270
|
-
#
|
|
271
|
-
#---------------------------------------------------------------------------------------
|
|
272
|
-
|
|
273
|
-
def binary_function_next(proc1, proc2, f, *args)
|
|
274
|
-
Proc.new { f.call(proc1.apply, proc2.apply, *args) }
|
|
275
|
-
end
|
|
276
|
-
|
|
277
|
-
end # LazyMDArray
|
|
278
|
-
|
|
279
|
-
##########################################################################################
|
|
280
|
-
#
|
|
281
|
-
##########################################################################################
|
|
282
|
-
|
|
283
|
-
class MDArray
|
|
284
|
-
|
|
285
|
-
#---------------------------------------------------------------------------------------
|
|
286
|
-
#
|
|
287
|
-
#---------------------------------------------------------------------------------------
|
|
288
|
-
|
|
289
|
-
def self.set_lazy(flag = true)
|
|
290
|
-
|
|
291
|
-
if (flag)
|
|
292
|
-
if (MDArray.binary_operator != LazyBinaryOperator)
|
|
293
|
-
MDArray.previous_binary_operator = MDArray.binary_operator
|
|
294
|
-
MDArray.previous_unary_operator = MDArray.unary_operator
|
|
295
|
-
end
|
|
296
|
-
MDArray.binary_operator = LazyBinaryOperator
|
|
297
|
-
MDArray.unary_operator = LazyUnaryOperator
|
|
298
|
-
else
|
|
299
|
-
MDArray.binary_operator = MDArray.previous_binary_operator if MDArray.previous_binary_operator != nil
|
|
300
|
-
MDArray.unary_operator = MDArray.previous_unary_operator if MDArray.previous_unary_operator != nil
|
|
301
|
-
end
|
|
302
|
-
|
|
303
|
-
end
|
|
304
|
-
|
|
305
|
-
#---------------------------------------------------------------------------------------
|
|
306
|
-
#
|
|
307
|
-
#---------------------------------------------------------------------------------------
|
|
308
|
-
|
|
309
|
-
def self.lazy=(flag)
|
|
310
|
-
set_lazy(flag)
|
|
311
|
-
end
|
|
312
|
-
|
|
313
|
-
end
|
|
314
|
-
|
|
315
|
-
require_relative 'lazy_operators'
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
|
-
##########################################################################################
|
|
4
|
-
# Copyright © 2013 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
|
|
5
|
-
# and distribute this software and its documentation for educational, research, and
|
|
6
|
-
# not-for-profit purposes, without fee and without a signed licensing agreement, is hereby
|
|
7
|
-
# granted, provided that the above copyright notice, this paragraph and the following two
|
|
8
|
-
# paragraphs appear in all copies, modifications, and distributions. Contact Rodrigo
|
|
9
|
-
# Botafogo - rodrigo.a.botafogo@gmail.com for commercial licensing opportunities.
|
|
10
|
-
#
|
|
11
|
-
# IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
|
|
12
|
-
# INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF
|
|
13
|
-
# THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE
|
|
14
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
|
15
|
-
#
|
|
16
|
-
# RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
17
|
-
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
|
|
18
|
-
# SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS".
|
|
19
|
-
# RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
|
|
20
|
-
# OR MODIFICATIONS.
|
|
21
|
-
##########################################################################################
|
|
22
|
-
|
|
23
|
-
##########################################################################################
|
|
24
|
-
#
|
|
25
|
-
##########################################################################################
|
|
26
|
-
|
|
27
|
-
class LazyBinaryOperator < BinaryOperator
|
|
28
|
-
|
|
29
|
-
attr_reader :exp # expression in string format
|
|
30
|
-
|
|
31
|
-
#---------------------------------------------------------------------------------------
|
|
32
|
-
#
|
|
33
|
-
#---------------------------------------------------------------------------------------
|
|
34
|
-
|
|
35
|
-
def get_args(*args)
|
|
36
|
-
|
|
37
|
-
@op1 = args.shift
|
|
38
|
-
@op2 = args.shift
|
|
39
|
-
@other_args = args
|
|
40
|
-
@exp = ""
|
|
41
|
-
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
#---------------------------------------------------------------------------------------
|
|
45
|
-
# A default binary operator takes two arrays where one array can be degenerated (a
|
|
46
|
-
# number and loops through all elements of the arrays applying a given method to them.
|
|
47
|
-
# For instance, operator '+' in a + b is a default binary operator.
|
|
48
|
-
#---------------------------------------------------------------------------------------
|
|
49
|
-
|
|
50
|
-
def default(*args)
|
|
51
|
-
|
|
52
|
-
get_args(*args)
|
|
53
|
-
lazy = @op1
|
|
54
|
-
|
|
55
|
-
if (@op1.is_a? LazyMDArray)
|
|
56
|
-
lazy.push(@op2)
|
|
57
|
-
lazy.push(self)
|
|
58
|
-
# @exp << "(" << @op1.exp << name << @op2.id << ")"
|
|
59
|
-
else
|
|
60
|
-
lazy = LazyMDArray.new
|
|
61
|
-
lazy.push(@op1)
|
|
62
|
-
lazy.push(@op2)
|
|
63
|
-
lazy.push(self)
|
|
64
|
-
# p @op1.id
|
|
65
|
-
# p @op2.id
|
|
66
|
-
# p @name
|
|
67
|
-
# @exp << "(" << @op1.id << name << @op2.id << ")"
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
return lazy
|
|
71
|
-
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
#---------------------------------------------------------------------------------------
|
|
75
|
-
# A fill binary operator takes two arrays where one array can be degenerated (a number)
|
|
76
|
-
# and loops through all elements of the arrays, setting the value of the first array
|
|
77
|
-
# to the values of the second.
|
|
78
|
-
#---------------------------------------------------------------------------------------
|
|
79
|
-
|
|
80
|
-
def fill(*args)
|
|
81
|
-
raise "Cannot fill array lazyly"
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
#---------------------------------------------------------------------------------------
|
|
85
|
-
#
|
|
86
|
-
#---------------------------------------------------------------------------------------
|
|
87
|
-
|
|
88
|
-
def in_place(*args)
|
|
89
|
-
raise "Cannot operate in_place lazyly"
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
#---------------------------------------------------------------------------------------
|
|
93
|
-
#
|
|
94
|
-
#---------------------------------------------------------------------------------------
|
|
95
|
-
|
|
96
|
-
def reduce(*args)
|
|
97
|
-
raise "Cannot reduce array in lazy operation"
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
#---------------------------------------------------------------------------------------
|
|
101
|
-
#
|
|
102
|
-
#---------------------------------------------------------------------------------------
|
|
103
|
-
|
|
104
|
-
def complex_reduce(*args)
|
|
105
|
-
raise "Cannot reduce array in lazy operation"
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
end # LazyBinaryOperator
|
|
109
|
-
|
|
110
|
-
##########################################################################################
|
|
111
|
-
#
|
|
112
|
-
##########################################################################################
|
|
113
|
-
|
|
114
|
-
class LazyUnaryOperator < UnaryOperator
|
|
115
|
-
|
|
116
|
-
#---------------------------------------------------------------------------------------
|
|
117
|
-
#
|
|
118
|
-
#---------------------------------------------------------------------------------------
|
|
119
|
-
|
|
120
|
-
def get_args(*args)
|
|
121
|
-
|
|
122
|
-
@op = args.shift
|
|
123
|
-
@other_args = args
|
|
124
|
-
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
#---------------------------------------------------------------------------------------
|
|
128
|
-
# A default unary operator takes one arrays and loops through all elements of the array
|
|
129
|
-
# applying a given method to it. For instance, operator 'log' in a.log is a default
|
|
130
|
-
# unary operator.
|
|
131
|
-
#---------------------------------------------------------------------------------------
|
|
132
|
-
|
|
133
|
-
def default(*args)
|
|
134
|
-
|
|
135
|
-
get_args(*args)
|
|
136
|
-
lazy = @op
|
|
137
|
-
|
|
138
|
-
if (@op.is_a? LazyMDArray)
|
|
139
|
-
lazy.push(self)
|
|
140
|
-
else
|
|
141
|
-
lazy = LazyMDArray.new
|
|
142
|
-
lazy.push(@op)
|
|
143
|
-
lazy.push(self)
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
return lazy
|
|
147
|
-
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
#---------------------------------------------------------------------------------------
|
|
151
|
-
#
|
|
152
|
-
#---------------------------------------------------------------------------------------
|
|
153
|
-
|
|
154
|
-
def in_place(*args)
|
|
155
|
-
raise "Cannot operate in_place lazyly"
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
#---------------------------------------------------------------------------------------
|
|
159
|
-
#
|
|
160
|
-
#---------------------------------------------------------------------------------------
|
|
161
|
-
|
|
162
|
-
def reduce(*args)
|
|
163
|
-
raise "Cannot reduce array in lazy operation"
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
#---------------------------------------------------------------------------------------
|
|
167
|
-
#
|
|
168
|
-
#---------------------------------------------------------------------------------------
|
|
169
|
-
|
|
170
|
-
def complex_reduce(*args)
|
|
171
|
-
raise "Cannot reduce array in lazy operation"
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
end # LazyUnaryOperator
|