52 |
fun tensorBinOp rator [TV(s1, v1), TV(s2, v2)] = |
fun tensorBinOp rator [TV(s1, v1), TV(s2, v2)] = |
53 |
TV(s1, ListPair.mapEq rator (v1, v2)) |
TV(s1, ListPair.mapEq rator (v1, v2)) |
54 |
fun realBinOp rator [TV([], [a]), TV([], [b])] = RV(rator(a, b)) |
fun realBinOp rator [TV([], [a]), TV([], [b])] = RV(rator(a, b)) |
55 |
|
fun realUnOp rator [TV([], [a])] = RV(rator a) |
56 |
fun intCmp rator [IV a, IV b] = BV(rator(a, b)) |
fun intCmp rator [IV a, IV b] = BV(rator(a, b)) |
57 |
fun realCmp rator [TV([], [a]), TV([], [b])] = BV(rator(a, b)) |
fun realCmp rator [TV([], [a]), TV([], [b])] = BV(rator(a, b)) |
58 |
fun boolCmp rator [BV a, BV b] = BV(rator(a, b)) |
fun boolCmp rator [BV a, BV b] = BV(rator(a, b)) |
91 |
(BV.neq_ii, intCmp (op <>)), |
(BV.neq_ii, intCmp (op <>)), |
92 |
(BV.neq_ss, stringCmp (op <>)), |
(BV.neq_ss, stringCmp (op <>)), |
93 |
(BV.neq_rr, realCmp Real.!=), |
(BV.neq_rr, realCmp Real.!=), |
94 |
|
(BV.neg_i, fn [IV i] => IV(~i)), |
95 |
(* |
(* |
|
(BV.neg_i, simpleOp(Op.Neg Op.IntTy)), |
|
96 |
(BV.neg_t, tensorOp Op.Neg), |
(BV.neg_t, tensorOp Op.Neg), |
97 |
(BV.neg_f, fn (y, _, xs) => assign(y, Op.NegField, xs)), |
*) |
98 |
|
(BV.neg_f, fn [FV fld] => FV(FieldDef.neg fld)), |
99 |
|
(* |
100 |
(BV.op_at, fn (y, _, xs) => assign(y, Op.Probe, xs)), |
(BV.op_at, fn (y, _, xs) => assign(y, Op.Probe, xs)), |
101 |
(BV.op_D, fn (y, _, xs) => assign(y, Op.DiffField, xs)), |
*) |
102 |
(BV.op_norm, tensorOp Op.Norm), |
(BV.op_D, fn [FV fld] => FV(FieldDef.diff fld)), |
|
(BV.op_not, simpleOp Op.Not), |
|
103 |
(* |
(* |
104 |
(BV.op_subscript, fn (y, [SK, NK], xs) => ??), (*FIXME*) |
(BV.op_norm, tensorOp Op.Norm), |
105 |
*) |
*) |
106 |
|
(BV.op_not, fn [BV b] => BV(not b)), |
107 |
|
(* |
108 |
|
(BV.op_subscript, fn (y, [SK, NK], xs) => ??), |
109 |
(BV.fn_CL, fn (y, _, xs) => assign(y, Op.CL, xs)), |
(BV.fn_CL, fn (y, _, xs) => assign(y, Op.CL, xs)), |
110 |
(BV.fn_convolve, fn (y, _, xs) => assign(y, Op.Convolve, xs)), |
*) |
111 |
(BV.fn_cos, simpleOp Op.Cos), |
(BV.fn_convolve, fn [KV h, Img info] => FV(FieldDef.CONV(info, h))), |
112 |
|
(BV.fn_cos, realUnOp Math.cos), |
113 |
|
(* |
114 |
(BV.fn_dot, vectorOp Op.Dot), |
(BV.fn_dot, vectorOp Op.Dot), |
115 |
(BV.fn_inside, fn (y, _, xs) => assign(y, Op.Inside, xs)), |
(BV.fn_inside, fn (y, _, xs) => assign(y, Op.Inside, xs)), |
116 |
*) |
*) |
120 |
(BV.fn_pow, realBinOp Real.Math.pow), |
(BV.fn_pow, realBinOp Real.Math.pow), |
121 |
(* |
(* |
122 |
(BV.fn_principleEvec, vectorOp Op.PrincipleEvec), |
(BV.fn_principleEvec, vectorOp Op.PrincipleEvec), |
|
(BV.fn_sin, simpleOp Op.Sin), |
|
123 |
*) |
*) |
124 |
|
(BV.fn_sin, realUnOp Math.sin), |
125 |
(BV.kn_bspln3, kernel Kernel.bspln3), |
(BV.kn_bspln3, kernel Kernel.bspln3), |
126 |
(BV.kn_bspln5, kernel Kernel.bspln5), |
(BV.kn_bspln5, kernel Kernel.bspln5), |
127 |
(BV.kn_ctmr, kernel Kernel.ctmr), |
(BV.kn_ctmr, kernel Kernel.ctmr), |
128 |
(BV.kn_tent, kernel Kernel.tent), |
(BV.kn_tent, kernel Kernel.tent), |
129 |
(BV.i2r, fn [IV i] => RV(real(IntInf.toInt i)))(*, |
(BV.i2r, fn [IV i] => RV(real(IntInf.toInt i))) |
|
(BV.input, fn (y, [TK], xs) => ??), (*FIXME*) |
|
|
(BV.optInput, fn (y, [TK], xs) => ??) (*FIXME*) |
|
|
*) |
|
130 |
]; |
]; |
131 |
tbl |
tbl |
132 |
end |
end |
133 |
|
|
134 |
fun loadImage (mvs, [SV filename]) = let |
fun loadImage ([Ty.DIM dim, Ty.SHAPE shp], [SV filename]) = let |
135 |
val info = ImageInfo.getInfo filename |
val Ty.DimConst d = TypeUtil.resolveDim dim |
136 |
|
val Ty.Shape dd = TypeUtil.resolveShape shp |
137 |
|
val info as ImageInfo.ImgInfo{dim, ...} = ImageInfo.getInfo filename |
138 |
in |
in |
139 |
(* FIXME: check image info details against mvs *) |
(* check that the expected dimension and actual dimension match *) |
140 |
|
if (d <> dim) |
141 |
|
then raise Fail(concat["image file \"", filename, "\" has wrong dimension"]) |
142 |
|
else (); |
143 |
|
(* check that the expected shape and actual shape match *) |
144 |
|
(* FIXME *) |
145 |
Img info |
Img info |
146 |
end |
end |
147 |
|
|