22 |
val hashstring = HashString.hashString |
val hashstring = HashString.hashString |
23 |
fun stringToString s = String.concat["\"", s, "\""] |
fun stringToString s = String.concat["\"", s, "\""] |
24 |
|
|
25 |
|
(* required helper functions for the mask tyoe *) |
26 |
|
type mask = bool list |
27 |
|
val samemask : (mask * mask -> bool) = (op =) |
28 |
|
fun hashmask m = |
29 |
|
List.foldl (fn (false, w) => w+w | (true, w) => w+w+0w1) |
30 |
|
(Word.fromInt(List.length m)) m |
31 |
|
fun maskToString m = |
32 |
|
String.concat(List.map (fn true => "_" | false => ":") m) |
33 |
|
|
34 |
datatype rator |
datatype rator |
35 |
= Add of ty |
= Add of ty |
36 |
| Sub of ty |
| Sub of ty |
43 |
| NEQ of ty |
| NEQ of ty |
44 |
| GT of ty |
| GT of ty |
45 |
| GTE of ty |
| GTE of ty |
46 |
|
| Max |
47 |
|
| Min |
48 |
|
| Sin |
49 |
|
| Cos |
50 |
|
| Pow |
51 |
|
| Not |
52 |
| Dot of ty |
| Dot of ty |
53 |
| Cross |
| Cross |
54 |
| Norm of ty |
| Norm of ty |
56 |
| InvScale of ty |
| InvScale of ty |
57 |
| CL |
| CL |
58 |
| PrincipleEvec of ty |
| PrincipleEvec of ty |
59 |
|
| Slice of ty * mask |
60 |
| Subscript of ty |
| Subscript of ty |
|
| Max |
|
|
| Min |
|
|
| Sin |
|
|
| Cos |
|
|
| Pow |
|
|
| Not |
|
61 |
| IntToReal |
| IntToReal |
62 |
| TruncToInt |
| TruncToInt |
63 |
| RoundToInt |
| RoundToInt |
87 |
| arity (NEQ _) = 2 |
| arity (NEQ _) = 2 |
88 |
| arity (GT _) = 2 |
| arity (GT _) = 2 |
89 |
| arity (GTE _) = 2 |
| arity (GTE _) = 2 |
90 |
|
| arity Max = 2 |
91 |
|
| arity Min = 2 |
92 |
|
| arity Sin = 1 |
93 |
|
| arity Cos = 1 |
94 |
|
| arity Pow = 2 |
95 |
|
| arity Not = 1 |
96 |
| arity (Dot _) = 2 |
| arity (Dot _) = 2 |
97 |
| arity Cross = 2 |
| arity Cross = 2 |
98 |
| arity (Norm _) = 1 |
| arity (Norm _) = 1 |
100 |
| arity (InvScale _) = 2 |
| arity (InvScale _) = 2 |
101 |
| arity CL = 1 |
| arity CL = 1 |
102 |
| arity (PrincipleEvec _) = 2 |
| arity (PrincipleEvec _) = 2 |
103 |
| arity (Subscript _) = 2 |
| arity (Slice _) = 1 |
104 |
| arity Max = 2 |
| arity (Subscript _) = ~1 |
|
| arity Min = 2 |
|
|
| arity Sin = 1 |
|
|
| arity Cos = 1 |
|
|
| arity Pow = 2 |
|
|
| arity Not = 1 |
|
105 |
| arity IntToReal = 1 |
| arity IntToReal = 1 |
106 |
| arity TruncToInt = 1 |
| arity TruncToInt = 1 |
107 |
| arity RoundToInt = 1 |
| arity RoundToInt = 1 |
131 |
| same (NEQ(a0), NEQ(b0)) = samety(a0, b0) |
| same (NEQ(a0), NEQ(b0)) = samety(a0, b0) |
132 |
| same (GT(a0), GT(b0)) = samety(a0, b0) |
| same (GT(a0), GT(b0)) = samety(a0, b0) |
133 |
| same (GTE(a0), GTE(b0)) = samety(a0, b0) |
| same (GTE(a0), GTE(b0)) = samety(a0, b0) |
134 |
|
| same (Max, Max) = true |
135 |
|
| same (Min, Min) = true |
136 |
|
| same (Sin, Sin) = true |
137 |
|
| same (Cos, Cos) = true |
138 |
|
| same (Pow, Pow) = true |
139 |
|
| same (Not, Not) = true |
140 |
| same (Dot(a0), Dot(b0)) = samety(a0, b0) |
| same (Dot(a0), Dot(b0)) = samety(a0, b0) |
141 |
| same (Cross, Cross) = true |
| same (Cross, Cross) = true |
142 |
| same (Norm(a0), Norm(b0)) = samety(a0, b0) |
| same (Norm(a0), Norm(b0)) = samety(a0, b0) |
144 |
| same (InvScale(a0), InvScale(b0)) = samety(a0, b0) |
| same (InvScale(a0), InvScale(b0)) = samety(a0, b0) |
145 |
| same (CL, CL) = true |
| same (CL, CL) = true |
146 |
| same (PrincipleEvec(a0), PrincipleEvec(b0)) = samety(a0, b0) |
| same (PrincipleEvec(a0), PrincipleEvec(b0)) = samety(a0, b0) |
147 |
|
| same (Slice(a0,a1), Slice(b0,b1)) = samety(a0, b0) andalso samemask(a1, b1) |
148 |
| same (Subscript(a0), Subscript(b0)) = samety(a0, b0) |
| same (Subscript(a0), Subscript(b0)) = samety(a0, b0) |
|
| same (Max, Max) = true |
|
|
| same (Min, Min) = true |
|
|
| same (Sin, Sin) = true |
|
|
| same (Cos, Cos) = true |
|
|
| same (Pow, Pow) = true |
|
|
| same (Not, Not) = true |
|
149 |
| same (IntToReal, IntToReal) = true |
| same (IntToReal, IntToReal) = true |
150 |
| same (TruncToInt, TruncToInt) = true |
| same (TruncToInt, TruncToInt) = true |
151 |
| same (RoundToInt, RoundToInt) = true |
| same (RoundToInt, RoundToInt) = true |
176 |
| hash (NEQ(a0)) = 0w29 + hashty a0 |
| hash (NEQ(a0)) = 0w29 + hashty a0 |
177 |
| hash (GT(a0)) = 0w31 + hashty a0 |
| hash (GT(a0)) = 0w31 + hashty a0 |
178 |
| hash (GTE(a0)) = 0w37 + hashty a0 |
| hash (GTE(a0)) = 0w37 + hashty a0 |
179 |
| hash (Dot(a0)) = 0w41 + hashty a0 |
| hash Max = 0w41 |
180 |
| hash Cross = 0w43 |
| hash Min = 0w43 |
181 |
| hash (Norm(a0)) = 0w47 + hashty a0 |
| hash Sin = 0w47 |
182 |
| hash (Scale(a0)) = 0w53 + hashty a0 |
| hash Cos = 0w53 |
183 |
| hash (InvScale(a0)) = 0w59 + hashty a0 |
| hash Pow = 0w59 |
184 |
| hash CL = 0w61 |
| hash Not = 0w61 |
185 |
| hash (PrincipleEvec(a0)) = 0w67 + hashty a0 |
| hash (Dot(a0)) = 0w67 + hashty a0 |
186 |
| hash (Subscript(a0)) = 0w71 + hashty a0 |
| hash Cross = 0w71 |
187 |
| hash Max = 0w73 |
| hash (Norm(a0)) = 0w73 + hashty a0 |
188 |
| hash Min = 0w79 |
| hash (Scale(a0)) = 0w79 + hashty a0 |
189 |
| hash Sin = 0w83 |
| hash (InvScale(a0)) = 0w83 + hashty a0 |
190 |
| hash Cos = 0w89 |
| hash CL = 0w89 |
191 |
| hash Pow = 0w97 |
| hash (PrincipleEvec(a0)) = 0w97 + hashty a0 |
192 |
| hash Not = 0w101 |
| hash (Slice(a0,a1)) = 0w101 + hashty a0 + hashmask a1 |
193 |
| hash IntToReal = 0w103 |
| hash (Subscript(a0)) = 0w103 + hashty a0 |
194 |
| hash TruncToInt = 0w107 |
| hash IntToReal = 0w107 |
195 |
| hash RoundToInt = 0w109 |
| hash TruncToInt = 0w109 |
196 |
| hash CeilToInt = 0w113 |
| hash RoundToInt = 0w113 |
197 |
| hash FloorToInt = 0w127 |
| hash CeilToInt = 0w127 |
198 |
| hash (Kernel(a0)) = 0w131 + Kernel.hash a0 |
| hash FloorToInt = 0w131 |
199 |
| hash (LoadImage(a0)) = 0w137 + ImageInfo.hash a0 |
| hash (Kernel(a0)) = 0w137 + Kernel.hash a0 |
200 |
| hash Convolve = 0w139 |
| hash (LoadImage(a0)) = 0w139 + ImageInfo.hash a0 |
201 |
| hash Inside = 0w149 |
| hash Convolve = 0w149 |
202 |
| hash (Field(a0)) = 0w151 + FieldDef.hash a0 |
| hash Inside = 0w151 |
203 |
| hash AddField = 0w157 |
| hash (Field(a0)) = 0w157 + FieldDef.hash a0 |
204 |
| hash ScaleField = 0w163 |
| hash AddField = 0w163 |
205 |
| hash NegField = 0w167 |
| hash ScaleField = 0w167 |
206 |
| hash DiffField = 0w173 |
| hash NegField = 0w173 |
207 |
| hash Probe = 0w179 |
| hash DiffField = 0w179 |
208 |
| hash (Input(a0)) = 0w181 + hashstring a0 |
| hash Probe = 0w181 |
209 |
| hash (InputWithDefault(a0)) = 0w191 + hashstring a0 |
| hash (Input(a0)) = 0w191 + hashstring a0 |
210 |
|
| hash (InputWithDefault(a0)) = 0w193 + hashstring a0 |
211 |
|
|
212 |
fun toString (Add(a0)) = concat["Add<", tyToString a0, ">"] |
fun toString (Add(a0)) = concat["Add<", tyToString a0, ">"] |
213 |
| toString (Sub(a0)) = concat["Sub<", tyToString a0, ">"] |
| toString (Sub(a0)) = concat["Sub<", tyToString a0, ">"] |
220 |
| toString (NEQ(a0)) = concat["NEQ<", tyToString a0, ">"] |
| toString (NEQ(a0)) = concat["NEQ<", tyToString a0, ">"] |
221 |
| toString (GT(a0)) = concat["GT<", tyToString a0, ">"] |
| toString (GT(a0)) = concat["GT<", tyToString a0, ">"] |
222 |
| toString (GTE(a0)) = concat["GTE<", tyToString a0, ">"] |
| toString (GTE(a0)) = concat["GTE<", tyToString a0, ">"] |
223 |
|
| toString Max = "Max" |
224 |
|
| toString Min = "Min" |
225 |
|
| toString Sin = "Sin" |
226 |
|
| toString Cos = "Cos" |
227 |
|
| toString Pow = "Pow" |
228 |
|
| toString Not = "Not" |
229 |
| toString (Dot(a0)) = concat["Dot<", tyToString a0, ">"] |
| toString (Dot(a0)) = concat["Dot<", tyToString a0, ">"] |
230 |
| toString Cross = "Cross" |
| toString Cross = "Cross" |
231 |
| toString (Norm(a0)) = concat["Norm<", tyToString a0, ">"] |
| toString (Norm(a0)) = concat["Norm<", tyToString a0, ">"] |
233 |
| toString (InvScale(a0)) = concat["InvScale<", tyToString a0, ">"] |
| toString (InvScale(a0)) = concat["InvScale<", tyToString a0, ">"] |
234 |
| toString CL = "CL" |
| toString CL = "CL" |
235 |
| toString (PrincipleEvec(a0)) = concat["PrincipleEvec<", tyToString a0, ">"] |
| toString (PrincipleEvec(a0)) = concat["PrincipleEvec<", tyToString a0, ">"] |
236 |
|
| toString (Slice(a0,a1)) = concat["Slice<", tyToString a0, ",", maskToString a1, ">"] |
237 |
| toString (Subscript(a0)) = concat["Subscript<", tyToString a0, ">"] |
| toString (Subscript(a0)) = concat["Subscript<", tyToString a0, ">"] |
|
| toString Max = "Max" |
|
|
| toString Min = "Min" |
|
|
| toString Sin = "Sin" |
|
|
| toString Cos = "Cos" |
|
|
| toString Pow = "Pow" |
|
|
| toString Not = "Not" |
|
238 |
| toString IntToReal = "IntToReal" |
| toString IntToReal = "IntToReal" |
239 |
| toString TruncToInt = "TruncToInt" |
| toString TruncToInt = "TruncToInt" |
240 |
| toString RoundToInt = "RoundToInt" |
| toString RoundToInt = "RoundToInt" |