32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/stair_car/pmatrix/types.rb', line 32
def type_class(type, sparse, initialize_values)
types = {
:zeros => {
false => {
:double => Java::cern.colt.matrix.tdouble.impl.DenseDoubleMatrix2D,
:float => Java::cern.colt.matrix.tfloat.impl.DenseFloatMatrix2D
},
true => {
:double => Java::cern.colt.matrix.tdouble.impl.SparseDoubleMatrix2D,
:float => Java::cern.colt.matrix.tfloat.impl.SparseFloatMatrix2D
}
},
:ones => {
false => {
:double => Java::cern.colt.matrix.tdouble.impl.DenseDoubleMatrix2D,
:float => Java::cern.colt.matrix.tfloat.impl.DenseFloatMatrix2D
},
true => {
:double => Java::cern.colt.matrix.tdouble.impl.SparseDoubleMatrix2D,
:float => Java::cern.colt.matrix.tfloat.impl.SparseFloatMatrix2D
}
},
:rand => {
false => {
:double => Java::cern.colt.matrix.tdouble.DoubleFactory2D.dense.method(:random),
:float => Java::cern.colt.matrix.tfloat.FloatFactory2D.dense.method(:random)
},
true => {
:double => Java::cern.colt.matrix.tdouble.DoubleFactory2D.sparse.method(:random),
:float => Java::cern.colt.matrix.tfloat.FloatFactory2D.sparse.method(:random)
}
},
:desc => {
false => {
:double => Java::cern.colt.matrix.tdouble.DoubleFactory2D.dense.method(:descending),
:float => Java::cern.colt.matrix.tfloat.FloatFactory2D.dense.method(:descending)
},
true => {
:double => Java::cern.colt.matrix.tdouble.DoubleFactory2D.sparse.method(:descending),
:float => Java::cern.colt.matrix.tfloat.FloatFactory2D.sparse.method(:descending)
}
},
:asc => {
false => {
:double => Java::cern.colt.matrix.tdouble.DoubleFactory2D.dense.method(:ascending),
:float => Java::cern.colt.matrix.tfloat.FloatFactory2D.dense.method(:ascending)
},
true => {
:double => Java::cern.colt.matrix.tdouble.DoubleFactory2D.sparse.method(:ascending),
:float => Java::cern.colt.matrix.tfloat.FloatFactory2D.sparse.method(:ascending)
}
}
}
klass = types[initialize_values][sparse][type]
unless klass
raise "Could not make a #{sparse ? 'sparse' : 'dense'} #{type} matrix"
end
return klass
end
|