14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/stair_car/umatrix/types.rb', line 14
def type_class(type, sparse, initialize_values)
if sparse
base = Java::org.ujmp.parallelcolt::ParallelColtSparseDoubleMatrix2D
else
base = Java::org.ujmp.core.Matrix.factory
end
if [:zeros, :ones, :rand, :desc, :asc].include?(initialize_values)
if [:asc, :desc].include?(initialize_values)
initialize_values = :zeros
end
if sparse && initialize_values == :zeros
initialize_values = :new
end
return Proc.new { |rows, cols| base.send(initialize_values, rows, cols) }
else
raise "Type is not valid"
end
end
|