1 |
(* translate-basis.sml |
(* translate-basis.sml |
2 |
* |
* |
3 |
* COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu) |
* COPYRIGHT (c) 2010 The Diderot Project (http://diderot-language.cs.uchicago.edu) |
4 |
* All rights reserved. |
* All rights reserved. |
5 |
* |
* |
6 |
* Translation for basis operations in Simple AST to HighIL code |
* Translation for basis operations in Simple AST to HighIL code |
13 |
* reverse order. |
* reverse order. |
14 |
*) |
*) |
15 |
val translate : (HighIL.var * Var.var * Types.meta_var list * HighIL.var list) |
val translate : (HighIL.var * Var.var * Types.meta_var list * HighIL.var list) |
16 |
-> HighIL.assign list |
-> HighIL.assignment list |
17 |
|
|
18 |
end = struct |
end = struct |
19 |
|
|
26 |
structure MV = MetaVar |
structure MV = MetaVar |
27 |
structure VTbl = Var.Tbl |
structure VTbl = Var.Tbl |
28 |
|
|
29 |
|
structure EinOp= Operators |
30 |
|
structure S=Specialize |
31 |
|
|
32 |
|
fun pruneTy tv = (case TU.prune(MV.toType tv) |
33 |
|
of (ty as Ty.T_Var _) => raise Fail("unresolved type " ^ TU.toString ty) |
34 |
|
| ty => TranslateTy.tr ty |
35 |
|
(* end case *)) |
36 |
|
|
37 |
fun pruneDim d = (case TU.pruneDim d |
fun pruneDim d = (case TU.pruneDim d |
38 |
of (Ty.DimConst n) => n |
of (Ty.DimConst n) => n |
39 |
| d => raise Fail("unresolved dimension " ^ TU.dimToString d) |
| d => raise Fail("unresolved dimension " ^ TU.dimToString d) |
40 |
(* end case *)) |
(* end case *)) |
41 |
|
|
42 |
|
|
43 |
|
|
44 |
fun pruneShape sv = (case TU.pruneShape(MV.toShape sv) |
fun pruneShape sv = (case TU.pruneShape(MV.toShape sv) |
45 |
of Ty.Shape dd => DstTy.TensorTy(List.map pruneDim dd) |
of Ty.Shape dd => DstTy.tensorTy(List.map pruneDim dd) |
46 |
| shp => raise Fail("unresolved shape " ^ TU.shapeToString shp) |
| shp => raise Fail("unresolved shape " ^ TU.shapeToString shp) |
47 |
(* end case *)) |
(* end case *)) |
48 |
|
|
|
fun dimVarToTensor dv = DstTy.TensorTy[pruneDim(MV.toDim dv)] |
|
|
fun shapeVarToTensor sv = pruneShape sv |
|
49 |
|
|
50 |
fun assign (y, rator, xs) = [(y, IL.OP(rator, xs))] |
fun dimVarToInt dv = pruneDim(MV.toDim dv) |
51 |
|
fun dimVarToTensor dv = DstTy.tensorTy[dimVarToInt dv] |
52 |
|
fun dimVarToMatrix dv = let |
53 |
|
val d = dimVarToInt dv |
54 |
|
in |
55 |
|
DstTy.tensorTy[d, d] (* square matrix type *) |
56 |
|
end |
57 |
|
|
58 |
|
|
59 |
|
fun assign (y, rator, xs) = [IL.ASSGN(y, IL.OP(rator, xs))] |
60 |
|
|
61 |
|
fun basisFn name (y, [], xs) = [IL.ASSGN(y, IL.APPLY(name, xs))] |
62 |
|
|
63 |
fun simpleOp rator (y, [], xs) = assign (y, rator, xs) |
fun simpleOp rator (y, [], xs) = assign (y, rator, xs) |
64 |
|
fun shapeVarToTensor sv = pruneShape sv |
65 |
|
|
66 |
|
|
67 |
fun tensorOp rator (y, [sv], xs) = assign (y, rator(shapeVarToTensor sv), xs) |
fun tensorOp rator (y, [sv], xs) = assign (y, rator(shapeVarToTensor sv), xs) |
68 |
|
|
69 |
fun vectorOp rator (y, [dv], xs) = assign (y, rator(dimVarToTensor dv), xs) |
fun vectorOp rator (y, [dv], xs) = assign (y, rator(dimVarToTensor dv), xs) |
70 |
|
|
71 |
fun kernel h (y, [], []) = assign(y, Op.Kernel h, []) |
fun kernel h (y, [], []) = assign(y, Op.Kernel(h, 0), []) |
72 |
|
|
73 |
|
(* utility functions for synthesizing eigenvector/eigenvalue code *) |
74 |
|
fun eigenVec (rator, dim) = let |
75 |
|
val ty = DstTy.SeqTy(DstTy.realTy, dim) |
76 |
|
in |
77 |
|
fn (y, _, [m]) => let |
78 |
|
val v = IL.Var.new("evals", ty) |
79 |
|
in |
80 |
|
[IL.MASSGN([v, y], rator, [m])] |
81 |
|
end |
82 |
|
end |
83 |
|
fun eigenVal (rator, dim) = let |
84 |
|
val ty = DstTy.SeqTy(DstTy.vecTy dim, dim) |
85 |
|
in |
86 |
|
fn (y, _, [m]) => let |
87 |
|
val v = IL.Var.new("evecs", ty) |
88 |
|
in |
89 |
|
[IL.MASSGN([y, v], rator, [m])] |
90 |
|
end |
91 |
|
end |
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
|
96 |
|
|
97 |
|
fun assignEin (y, rator, xs) = [IL.ASSGN(y, IL.EINAPP(rator, xs))] |
98 |
|
|
99 |
|
fun simpleEinOp rator (y, _,xs) = assignEin(y, rator, xs) |
100 |
|
|
101 |
|
fun peelFieldSK SK=[2] (*(case TU.pruneShape(MV.toShape SK) |
102 |
|
of Ty.Shape dd => List.map pruneDim dd |
103 |
|
| shp => raise Fail("unresolved shape " ^ TU.shapeToString shp) |
104 |
|
(* end case *))*) |
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
fun tensorEinOp einop (y, [SK], xs) = |
109 |
|
let val ty1 as DstTy.TensorTy dd1 = pruneShape SK |
110 |
|
val rator =S.transform(einop,[dd1],[]) |
111 |
|
in |
112 |
|
assignEin(y, rator,xs) |
113 |
|
end |
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|
fun scalarField(einop,paramarg,y,xs)= |
118 |
|
let val paramarg'=List.map dimVarToInt paramarg(*[2]*) |
119 |
|
val rator=S.transform(einop, [[]],paramarg') |
120 |
|
|
121 |
|
in |
122 |
|
assignEin(y, rator, xs) |
123 |
|
end |
124 |
|
|
125 |
|
fun singleField(SK,einop,paramarg, y, xs)= |
126 |
|
let |
127 |
|
val s=peelFieldSK SK |
128 |
|
val paramarg'= List.map dimVarToInt paramarg (*[2]*) |
129 |
|
val rator= S.transform(einop, [s],paramarg') |
130 |
|
in assignEin(y, rator, xs) |
131 |
|
end |
132 |
|
|
133 |
|
|
134 |
|
|
135 |
|
|
136 |
|
(****MV.toDim returns int, and DstTy.TensorTy returns intlist *) |
137 |
|
|
138 |
|
(*DK- SK-shape,NK-dim *) |
139 |
|
|
140 |
|
(* shape is an int list, DIM is in int|variable, k-level of differntiation *) |
141 |
|
|
142 |
(* build a table that maps Basis variables to their translation functions *) |
(* build a table that maps Basis variables to their translation functions *) |
143 |
val tbl : ((IL.var * Ty.meta_var list * IL.var list) -> IL.assign list) VTbl.hash_table = let |
val tbl : ((IL.var * Ty.meta_var list * IL.var list) -> IL.assignment list) VTbl.hash_table = let |
144 |
val tbl = VTbl.mkTable (128, Fail "Translate table") |
val tbl = VTbl.mkTable (128, Fail "Translate table") |
145 |
|
val insert = VTbl.insert tbl |
146 |
in |
in |
147 |
List.app (VTbl.insert tbl) [ |
List.app insert [ |
|
(BV.add_ii, simpleOp(Op.Add DstTy.IntTy)), |
|
|
(BV.add_tt, tensorOp Op.Add), |
|
|
(BV.sub_ii, simpleOp(Op.Sub DstTy.IntTy)), |
|
|
(BV.sub_tt, tensorOp Op.Sub), |
|
|
(BV.mul_ii, simpleOp(Op.Mul DstTy.IntTy)), |
|
|
(BV.mul_rr, simpleOp(Op.Mul(DstTy.TensorTy[]))), |
|
|
(BV.mul_rt, tensorOp Op.Scale), |
|
|
(BV.mul_tr, fn (y, sv, [t, r]) => tensorOp Op.Scale (y, sv, [r, t])), |
|
|
(BV.div_ii, simpleOp(Op.Div DstTy.IntTy)), |
|
|
(BV.div_rr, simpleOp(Op.Div(DstTy.TensorTy[]))), |
|
|
(BV.div_tr, tensorOp Op.InvScale), |
|
148 |
(BV.lt_ii, simpleOp(Op.LT DstTy.IntTy)), |
(BV.lt_ii, simpleOp(Op.LT DstTy.IntTy)), |
149 |
(BV.lt_rr, simpleOp(Op.LT(DstTy.TensorTy[]))), |
(BV.lt_rr, simpleOp(Op.LT DstTy.realTy)), |
150 |
(BV.lte_ii, simpleOp(Op.LTE DstTy.IntTy)), |
(BV.lte_ii, simpleOp(Op.LTE DstTy.IntTy)), |
151 |
(BV.lte_rr, simpleOp(Op.LTE(DstTy.TensorTy[]))), |
(BV.lte_rr, simpleOp(Op.LTE DstTy.realTy)), |
152 |
(BV.gte_ii, simpleOp(Op.GTE DstTy.IntTy)), |
(BV.gte_ii, simpleOp(Op.GTE DstTy.IntTy)), |
153 |
(BV.gte_rr, simpleOp(Op.GTE(DstTy.TensorTy[]))), |
(BV.gte_rr, simpleOp(Op.GTE(DstTy.realTy))), |
154 |
(BV.gt_ii, simpleOp(Op.GT DstTy.IntTy)), |
(BV.gt_ii, simpleOp(Op.GT DstTy.IntTy)), |
155 |
(BV.gt_rr, simpleOp(Op.GT(DstTy.TensorTy[]))), |
(BV.gt_rr, simpleOp(Op.GT(DstTy.realTy))), |
156 |
(BV.equ_bb, simpleOp(Op.EQ DstTy.BoolTy)), |
(BV.equ_bb, simpleOp(Op.EQ DstTy.BoolTy)), |
157 |
(BV.equ_ii, simpleOp(Op.EQ DstTy.IntTy)), |
(BV.equ_ii, simpleOp(Op.EQ DstTy.IntTy)), |
158 |
(BV.equ_ss, simpleOp(Op.EQ DstTy.StringTy)), |
(BV.equ_ss, simpleOp(Op.EQ DstTy.StringTy)), |
159 |
(BV.equ_rr, simpleOp(Op.EQ(DstTy.TensorTy[]))), |
(BV.equ_rr, simpleOp(Op.EQ(DstTy.realTy))), |
160 |
(BV.neq_bb, simpleOp(Op.NEQ DstTy.BoolTy)), |
(BV.neq_bb, simpleOp(Op.NEQ DstTy.BoolTy)), |
161 |
(BV.neq_ii, simpleOp(Op.NEQ DstTy.IntTy)), |
(BV.neq_ii, simpleOp(Op.NEQ DstTy.IntTy)), |
162 |
(BV.neq_ss, simpleOp(Op.NEQ DstTy.StringTy)), |
(BV.neq_ss, simpleOp(Op.NEQ DstTy.StringTy)), |
163 |
(BV.neq_rr, simpleOp(Op.NEQ(DstTy.TensorTy[]))), |
(BV.neq_rr, simpleOp(Op.NEQ(DstTy.realTy))), |
164 |
(BV.neg_i, simpleOp(Op.Neg DstTy.IntTy)), |
(BV.add_ii, simpleOp Op.IAdd ), |
165 |
(BV.neg_t, tensorOp Op.Neg), |
(BV.add_tt, tensorEinOp EinOp.addTensor), |
166 |
(BV.neg_f, fn (y, _, xs) => assign(y, Op.NegField, xs)), |
(BV.add_ff, fn (y, [_,NK,SK], xs)=> singleField(SK,EinOp.addField, [NK,NK], y, xs)), |
167 |
(BV.op_at, fn (y, [_, dv, sv], xs) => |
(BV.add_fr, fn (y, [_,NK], xs)=> scalarField(EinOp.addTenField,[NK],y, xs)), |
168 |
assign(y, Op.Probe(shapeVarToTensor sv, dimVarToTensor dv), xs)), |
(BV.add_rf, fn (y, [_,NK], [s, f])=>scalarField(EinOp.addTenField,[NK],y,[f,s])), |
169 |
(BV.op_convolve, fn (y, _, xs) => assign(y, Op.Convolve, xs)), |
(BV.sub_ii, simpleOp Op.ISub ), |
170 |
(BV.op_D, fn (y, _, xs) => assign(y, Op.DiffField, xs)), |
(BV.sub_tt, tensorEinOp EinOp.subTensor), |
171 |
(BV.op_norm, tensorOp Op.Norm), |
(BV.sub_ff, fn (y, [_,NK,SK], xs)=>singleField(SK,EinOp.subField, [NK,NK],y,xs)), |
172 |
|
(BV.sub_fr, fn (y, [_,NK], xs) => scalarField(EinOp.subField,[NK], y,xs)), |
173 |
|
(BV.sub_rf, fn (y, [_,NK], [s, f]) => scalarField(EinOp.subField,[NK], y,[f, s])), |
174 |
|
(* CHANEG create negative subtraction*) |
175 |
|
(BV.mul_ii, simpleOp Op.IMul), |
176 |
|
(BV.mul_rr, simpleOp Op.IMul), |
177 |
|
(BV.mul_rt, tensorEinOp EinOp.scaleTensor), |
178 |
|
(BV.mul_tr, fn (y, [SK], [t, r])=>let |
179 |
|
val ty1 as DstTy.TensorTy dd1 = pruneShape SK |
180 |
|
val rator =S.transform(EinOp.scaleTensor,[dd1],[]) |
181 |
|
in |
182 |
|
assignEin(y, rator,[r,t]) |
183 |
|
end), |
184 |
|
|
185 |
|
|
186 |
|
|
187 |
|
(BV.mul_rf, fn (y,[_,NK,SK], xs)=> singleField(SK,EinOp.scaleField,[NK],y, xs)), |
188 |
|
|
189 |
|
|
190 |
|
|
191 |
|
(BV.mul_fr, fn (y, [_,NK,SK], [f, s])=> singleField(SK,EinOp.scaleField, [NK],y,[s,f])), |
192 |
|
|
193 |
|
(BV.div_ii, simpleOp Op.IDiv), |
194 |
|
(BV.div_rr, simpleOp Op.IDiv), |
195 |
|
|
196 |
|
|
197 |
|
(BV.div_tr, tensorEinOp EinOp.divideTensor), |
198 |
|
|
199 |
|
(BV.div_fr, fn (y, [_,NK,SK], xs) =>singleField(SK,EinOp.divideField, [NK],y, xs)), |
200 |
|
(BV.exp_ri, simpleOp(Op.Power)), |
201 |
|
(BV.exp_rr, basisFn MathFuns.pow), |
202 |
|
(BV.curl2D, simpleEinOp EinOp.Curl2d), |
203 |
|
(BV.curl3D, simpleEinOp EinOp.Curl3d), |
204 |
|
(BV.convolve_vk, fn (y, [_, NK, SK], xs) => singleField(SK,EinOp.conv, [NK],y,xs)), |
205 |
|
(BV.convolve_kv, fn (y, [_, NK, SK], [k, v]) =>singleField(SK,EinOp.conv, [NK],y,[v,k])), |
206 |
|
(BV.neg_i, simpleOp Op.INeg), |
207 |
|
(BV.neg_t, tensorEinOp EinOp.negTensor), |
208 |
|
|
209 |
|
|
210 |
|
(BV.neg_f, fn (y, [_,NK,SK], xs) => singleField(SK,EinOp.negField, [NK],y,xs)), |
211 |
|
|
212 |
|
(BV.op_probe, fn (y, [_, NK, SK], xs) => |
213 |
|
let |
214 |
|
val dv=dimVarToTensor NK (*Field*) |
215 |
|
val sv=shapeVarToTensor SK (*Position*) |
216 |
|
val dv'=peelFieldSK dv |
217 |
|
val sv'=peelFieldSK sv |
218 |
|
val einop= S.transform(EinOp.probe,[sv',dv'],[2]) |
219 |
|
in assignEin(y, einop,xs) |
220 |
|
end), |
221 |
|
(BV.op_D, fn (y, [_, NK], xs) => scalarField(EinOp.Grad,[NK], y,xs)), |
222 |
|
(BV.op_Dotimes, fn (y, [_, NK, SK, NK2], xs) => singleField(SK,EinOp.Divergence,[NK], y,xs)), |
223 |
|
(BV.op_norm, fn (y, [sv], xs) => (case shapeVarToTensor sv |
224 |
|
of DstTy.TensorTy[] => assign(y, Op.Abs DstTy.realTy, xs) |
225 |
|
| ty => assign(y, Op.Norm ty, xs) |
226 |
|
(* end case *))), |
227 |
|
|
228 |
(BV.op_not, simpleOp Op.Not), |
(BV.op_not, simpleOp Op.Not), |
229 |
(BV.fn_CL, fn (y, _, xs) => assign(y, Op.CL, xs)), |
(BV.op_cross, simpleEinOp EinOp.crossProduct), |
230 |
(BV.fn_convolve, fn (y, _, [h, img]) => assign(y, Op.Convolve, [img, h])), |
(BV.op_outer, fn (y, [dv1, dv2], xs) => let |
231 |
(BV.fn_cos, simpleOp Op.Cos), |
val d1 = [pruneDim(MV.toDim dv1)] |
232 |
(BV.fn_dot, vectorOp Op.Dot), |
val d2 = [pruneDim(MV.toDim dv2)] |
233 |
|
in |
234 |
|
assignEin( y, S.transform(EinOp.outerProduct,[d1,d2],[]),xs) |
235 |
|
end), |
236 |
|
(BV.op_inner, fn (y, [sh1, sh2, _], xs) => |
237 |
|
let |
238 |
|
val ty1 as DstTy.TensorTy dd1 = pruneShape sh1 |
239 |
|
val ty2 as DstTy.TensorTy dd2 = pruneShape sh2 |
240 |
|
val alpha= List.take(dd1, length(dd1)-1) |
241 |
|
val beta= tl(dd2) |
242 |
|
val i =hd(dd2) |
243 |
|
val ilist= [alpha, beta, [i]] |
244 |
|
in |
245 |
|
assignEin(y, S.transform(EinOp.innerProduct, ilist,[]),xs) |
246 |
|
end), |
247 |
|
|
248 |
|
(BV.op_colon, fn (y, [sh1, sh2, _], xs) => |
249 |
|
let |
250 |
|
val ty1 as DstTy.TensorTy dd1 = pruneShape sh1 |
251 |
|
val ty2 as DstTy.TensorTy dd2 = pruneShape sh2 |
252 |
|
val m= List.take(dd2,2) |
253 |
|
val i=hd(m) |
254 |
|
val j=tl(m) |
255 |
|
val alpha= List.take(dd1, length(dd1)-2) |
256 |
|
val beta=tl(tl(dd2)) |
257 |
|
val ilist=[alpha, beta, [i], j] |
258 |
|
in |
259 |
|
assignEin(y, S.transform(EinOp.doubleDot, ilist,[]),xs) |
260 |
|
end), |
261 |
|
|
262 |
(BV.fn_inside, fn (y, [_, dv, _], xs) => |
(BV.fn_inside, fn (y, [_, dv, _], xs) => |
263 |
assign(y, Op.Inside(dimVarToTensor dv), xs)), |
assign(y, Op.Inside(pruneDim(MV.toDim dv)), xs)), |
264 |
|
(BV.clamp_rrr, simpleOp (Op.Clamp DstTy.realTy)), |
265 |
|
(BV.clamp_vvv, vectorOp Op.Clamp), |
266 |
|
(BV.lerp3, tensorOp Op.Lerp), |
267 |
|
(BV.lerp5, fn (y, [sv], [a, b, x0, x, x1]) => let |
268 |
|
val t1 = IL.Var.new("t1", DstTy.realTy) |
269 |
|
val t2 = IL.Var.new("t2", DstTy.realTy) |
270 |
|
val t3 = IL.Var.new("t3", DstTy.realTy) |
271 |
|
in [ |
272 |
|
IL.ASSGN(t1, IL.OP(Op.ISub, [x, x0])), |
273 |
|
IL.ASSGN(t2, IL.OP(Op.ISub, [x1, x0])), |
274 |
|
IL.ASSGN(t3, IL.OP(Op.IDiv, [t1, t2])), |
275 |
|
IL.ASSGN(y, IL.OP(Op.Lerp(shapeVarToTensor sv), [a, b, t3])) |
276 |
|
] end), |
277 |
|
(BV.evals2x2, eigenVal (Op.Eigen2x2, 2)), |
278 |
|
(BV.evals3x3, eigenVal (Op.Eigen3x3, 3)), |
279 |
|
(BV.evecs2x2, eigenVec (Op.Eigen2x2, 2)), |
280 |
|
(BV.evecs3x3, eigenVec (Op.Eigen3x3, 3)), |
281 |
(BV.fn_max, simpleOp Op.Max), |
(BV.fn_max, simpleOp Op.Max), |
282 |
(BV.fn_min, simpleOp Op.Min), |
(BV.fn_min, simpleOp Op.Min), |
283 |
(BV.fn_modulate, vectorOp Op.Mul), |
(BV.fn_modulate, fn (y, _, xs) => assign (y, Op.IMul, xs)), |
284 |
(BV.fn_pow, simpleOp Op.Pow), |
(BV.fn_normalize, vectorOp Op.Normalize), |
285 |
(BV.fn_principleEvec, vectorOp Op.PrincipleEvec), |
(BV.fn_principleEvec, vectorOp Op.PrincipleEvec), |
286 |
(BV.fn_sin, simpleOp Op.Sin), |
|
287 |
|
(BV.fn_trace, fn (y, [dv], xs) =>let |
288 |
|
val d=dimVarToInt dv |
289 |
|
in |
290 |
|
assignEin(y,S.transform(EinOp.trace, [[d]],[]),xs) |
291 |
|
end), |
292 |
|
|
293 |
|
(BV.fn_transpose, fn (y, [dv1, dv2], xs) => |
294 |
|
let |
295 |
|
val d1=dimVarToInt dv1 |
296 |
|
val d2=dimVarToInt dv2 |
297 |
|
in |
298 |
|
assignEin(y,S.transform(EinOp.transpose, [[d1],[d2]],[]),xs) |
299 |
|
end), |
300 |
|
|
301 |
(BV.kn_bspln3, kernel Kernel.bspln3), |
(BV.kn_bspln3, kernel Kernel.bspln3), |
302 |
(BV.kn_bspln5, kernel Kernel.bspln5), |
(BV.kn_bspln5, kernel Kernel.bspln5), |
303 |
(BV.kn_ctmr, kernel Kernel.ctmr), |
(BV.kn_ctmr, kernel Kernel.ctmr), |
304 |
|
(BV.kn_c2ctmr, kernel Kernel.ctmr), |
305 |
|
(BV.kn_c4hexic, kernel Kernel.c4hexic), |
306 |
(BV.kn_tent, kernel Kernel.tent), |
(BV.kn_tent, kernel Kernel.tent), |
307 |
(BV.i2r, simpleOp Op.IntToReal) |
(BV.kn_c1tent, kernel Kernel.tent), |
308 |
|
(BV.i2r, simpleOp Op.IntToReal), |
309 |
|
|
310 |
|
(BV.identity, fn (y, [dv], xs) =>let |
311 |
|
val d=dimVarToInt dv |
312 |
|
in assignEin(y, S.transform(EinOp.identity,[[d],[d]],[]),xs) |
313 |
|
end), |
314 |
|
|
315 |
|
(* (BV.zero, fn (y, [sv], []) => |
316 |
|
assign(y, Op.Zero(shapeVarToTensor sv), [])),*) |
317 |
|
(BV.subscript, fn (y, [tv, dv], xs) => |
318 |
|
assign(y, |
319 |
|
Op.SeqSub(DstTy.SeqTy(pruneTy tv, pruneDim(MV.toDim dv))), |
320 |
|
xs)) |
321 |
|
|
322 |
|
|
323 |
|
(*, |
324 |
|
|
325 |
|
(BV.dynSubscript, fn (y, [tv], args) => |
326 |
|
assign(y, Op.SeqSub(DstTy.DynSeqTy(pruneTy tv)), args))*) |
327 |
]; |
]; |
328 |
|
|
329 |
|
(* add C math functions *) |
330 |
|
List.app (fn (n, x) => insert(x, basisFn n)) BV.mathFns; |
331 |
tbl |
tbl |
332 |
end |
end |
333 |
|
|
335 |
of SOME transFn => transFn(y, mvs, xs) |
of SOME transFn => transFn(y, mvs, xs) |
336 |
| NONE => raise Fail("TranslateBasis.translate: unknown basis function " ^ Var.uniqueNameOf f) |
| NONE => raise Fail("TranslateBasis.translate: unknown basis function " ^ Var.uniqueNameOf f) |
337 |
(* end case *)) |
(* end case *)) |
338 |
|
handle ex => (print(concat["translate (", IL.Var.toString y, ", ", |
339 |
|
Var.uniqueNameOf f, ", ...)\n"]); raise ex) |
340 |
|
|
341 |
end |
end |