9 |
structure HighOps = |
structure HighOps = |
10 |
struct |
struct |
11 |
|
|
12 |
type ty = IntTy | TensorTy of int list |
type ty = BoolTy | StringTy | IntTy | TensorTy of int list |
13 |
|
|
14 |
fun sameTy (ty1 : ty, ty2) = (ty1 = ty2) |
fun sameTy (ty1 : ty, ty2) = (ty1 = ty2) |
15 |
|
|
17 |
= Add of ty | Sub of ty (* type-indexed arithmetic operations *) |
= Add of ty | Sub of ty (* type-indexed arithmetic operations *) |
18 |
| Mul of ty | Div of ty |
| Mul of ty | Div of ty |
19 |
| Neg of ty |
| Neg of ty |
20 |
|
| LT of ty | LTE of ty |
21 |
|
| EQ of ty | NEQ of ty |
22 |
|
| GT of ty | GTE of ty |
23 |
| Dot of ty | Cross | Norm of ty (* vector operations *) |
| Dot of ty | Cross | Norm of ty (* vector operations *) |
24 |
| Scale of ty (* scalar/tensor multiplication *) |
| Scale of ty (* scalar/tensor multiplication *) |
25 |
| CL (* linear anisotropy measure *) |
| CL (* linear anisotropy measure *) |
28 |
| Max | Min |
| Max | Min |
29 |
| Sin | Cos |
| Sin | Cos |
30 |
| Pow |
| Pow |
31 |
|
| Not (* boolean negation *) |
32 |
(* conversions *) |
(* conversions *) |
33 |
| IntToReal |
| IntToReal |
34 |
| TruncToInt |
| TruncToInt |
47 |
| arity (Mul _) = 2 |
| arity (Mul _) = 2 |
48 |
| arity (Div _) = 2 |
| arity (Div _) = 2 |
49 |
| arity (Neg _) = 1 |
| arity (Neg _) = 1 |
50 |
|
| arity (LT _) = 2 |
51 |
|
| arity (LTE _) = 2 |
52 |
|
| arity (EQ _) = 2 |
53 |
|
| arity (NEQ _) = 2 |
54 |
|
| arity (GT _) = 2 |
55 |
|
| arity (GTE _) = 2 |
56 |
| arity (Dot _) = 2 |
| arity (Dot _) = 2 |
57 |
| arity Cross = 2 |
| arity Cross = 2 |
58 |
| arity (Norm _) = 1 |
| arity (Norm _) = 1 |
65 |
| arity Sin = 1 |
| arity Sin = 1 |
66 |
| arity Cos = 1 |
| arity Cos = 1 |
67 |
| arity Pow = 2 |
| arity Pow = 2 |
68 |
|
| arity Not = 1 |
69 |
| arity IntToReal = 1 |
| arity IntToReal = 1 |
70 |
| arity TruncToInt = 1 |
| arity TruncToInt = 1 |
71 |
| arity RoundToInt = 1 |
| arity RoundToInt = 1 |
82 |
| same (Mul ty1, Mul ty2) = sameTy(ty1, ty2) |
| same (Mul ty1, Mul ty2) = sameTy(ty1, ty2) |
83 |
| same (Div ty1, Div ty2) = sameTy(ty1, ty2) |
| same (Div ty1, Div ty2) = sameTy(ty1, ty2) |
84 |
| same (Neg ty1, Neg ty2) = sameTy(ty1, ty2) |
| same (Neg ty1, Neg ty2) = sameTy(ty1, ty2) |
85 |
|
| same (LT ty1, LT ty2) = sameTy(ty1, ty2) |
86 |
|
| same (LTE ty1, LTE ty2) = sameTy(ty1, ty2) |
87 |
|
| same (EQ ty1, EQ ty2) = sameTy(ty1, ty2) |
88 |
|
| same (NEQ ty1, NEQ ty2) = sameTy(ty1, ty2) |
89 |
|
| same (GT ty1, GT ty2) = sameTy(ty1, ty2) |
90 |
|
| same (GTE ty1, GTE ty2) = sameTy(ty1, ty2) |
91 |
| same (Dot ty1, Dot ty2) = sameTy(ty1, ty2) |
| same (Dot ty1, Dot ty2) = sameTy(ty1, ty2) |
92 |
| same (Cross, Cross) = true |
| same (Cross, Cross) = true |
93 |
| same (Norm ty1, Norm ty2) = sameTy(ty1, ty2) |
| same (Norm ty1, Norm ty2) = sameTy(ty1, ty2) |
100 |
| same (Sin, Sin) = true |
| same (Sin, Sin) = true |
101 |
| same (Cos, Cos) = true |
| same (Cos, Cos) = true |
102 |
| same (Pow, Pow) = true |
| same (Pow, Pow) = true |
103 |
|
| same (Not, Not) = true |
104 |
| same (IntToReal, IntToReal) = true |
| same (IntToReal, IntToReal) = true |
105 |
| same (TruncToInt, TruncToInt) = true |
| same (TruncToInt, TruncToInt) = true |
106 |
| same (RoundToInt, RoundToInt) = true |
| same (RoundToInt, RoundToInt) = true |