Changeset 250dbae
- Timestamp:
- Dec 31, 2019, 12:19:53 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- f8a8fb1
- Parents:
- 94df8de
- git-author:
- Dmitry Kobets <dkobets@…> (12/31/19 12:13:34)
- git-committer:
- Dmitry Kobets <dkobets@…> (12/31/19 12:19:53)
- Location:
- libcfa/src/vec
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/vec/vec.hfa
r94df8de r250dbae 74 74 } 75 75 76 77 76 forall(otype T, otype V | { T length(V); V ?/?(V, T); }) 78 77 V normalize(V v) { … … 114 113 // i is the incident vector 115 114 // ng is the geometric normal of the surface 116 /* forall(| add(T) | multiply(T) | lessthan(T) | fromint(T) | subtract(T)) */117 115 forall(otype T | lessthan(T) | zeroinit(T), otype V | dottable(V, T) | negate(V)) 118 116 V faceforward(V n, V i, V ng) { -
libcfa/src/vec/vec2.hfa
r94df8de r250dbae 10 10 } 11 11 12 13 12 forall (otype T) { 14 13 static inline { … … 31 30 } 32 31 33 // Assignment34 32 void ?=?(vec2(T)& vec, vec2(T) other) with (vec) { 35 33 [x,y] = other.[x,y]; … … 42 40 // Primitive mathematical operations 43 41 42 // - 44 43 forall(| subtract(T)) { 45 vec2(T) ?-?(vec2(T) u, vec2(T) v) { // TODO( can't make this const ref )44 vec2(T) ?-?(vec2(T) u, vec2(T) v) { 46 45 return [u.x - v.x, u.y - v.y]; 47 46 } … … 69 68 } 70 69 70 // + 71 71 forall(| add(T)) { 72 vec2(T) ?+?(vec2(T) u, vec2(T) v) { // TODO( can't make this const ref )72 vec2(T) ?+?(vec2(T) u, vec2(T) v) { 73 73 return [u.x + v.x, u.y + v.y]; 74 74 } … … 92 92 } 93 93 94 // * 94 95 forall(| multiply(T)) { 95 vec2(T) ?*?(vec2(T) v, T scalar) with (v) { // TODO (can't make this const ref)96 vec2(T) ?*?(vec2(T) v, T scalar) with (v) { 96 97 return [x * scalar, y * scalar]; 97 98 } 98 vec2(T) ?*?(T scalar, vec2(T) v) { // TODO (can't make this const ref)99 vec2(T) ?*?(T scalar, vec2(T) v) { 99 100 return v * scalar; 100 101 } … … 112 113 } 113 114 115 // / 114 116 forall(| divide(T)) { 115 117 vec2(T) ?/?(vec2(T) v, T scalar) with (v) { … … 119 121 return [u.x / v.x, u.y / v.y]; 120 122 } 121 vec2(T)& ?/=?(vec2(T)& v, T scalar) with (v){123 vec2(T)& ?/=?(vec2(T)& v, T scalar) { 122 124 v = v / scalar; 123 125 return v; … … 129 131 } 130 132 133 // % 131 134 forall(| { T ?%?(T,T); }) { 132 135 vec2(T) ?%?(vec2(T) v, T scalar) with (v) { … … 146 149 } 147 150 151 // & 148 152 forall(| { T ?&?(T,T); }) { 149 153 vec2(T) ?&?(vec2(T) v, T scalar) with (v) { … … 163 167 } 164 168 169 // | 165 170 forall(| { T ?|?(T,T); }) { 166 171 vec2(T) ?|?(vec2(T) v, T scalar) with (v) { … … 180 185 } 181 186 187 // ^ 182 188 forall(| { T ?^?(T,T); }) { 183 189 vec2(T) ?^?(vec2(T) v, T scalar) with (v) { … … 197 203 } 198 204 205 // << 199 206 forall(| { T ?<<?(T,T); }) { 200 207 vec2(T) ?<<?(vec2(T) v, T scalar) with (v) { … … 214 221 } 215 222 223 // >> 216 224 forall(| { T ?>>?(T,T); }) { 217 225 vec2(T) ?>>?(vec2(T) v, T scalar) with (v) { … … 231 239 } 232 240 241 // ~ 233 242 forall(| { T ~?(T); }) 234 243 vec2(T) ~?(vec2(T) v) with (v) { … … 236 245 } 237 246 238 // Relational Operators247 // relational 239 248 forall(| equality(T)) { 240 249 bool ?==?(vec2(T) u, vec2(T) v) with (u) { -
libcfa/src/vec/vec3.hfa
r94df8de r250dbae 10 10 } 11 11 12 13 12 forall (otype T) { 14 13 static inline { … … 31 30 } 32 31 33 // Assignment34 32 void ?=?(vec3(T)& vec, vec3(T) other) with (vec) { 35 33 [x,y,z] = other.[x,y,z]; … … 44 42 // - 45 43 forall(| subtract(T)) { 46 vec3(T) ?-?(vec3(T) u, vec3(T) v) { // TODO( can't make this const ref )44 vec3(T) ?-?(vec3(T) u, vec3(T) v) { 47 45 return [u.x - v.x, u.y - v.y, u.z - v.z]; 48 46 } … … 52 50 } 53 51 } 54 55 52 forall(| negate(T)) { 56 53 vec3(T) -?(vec3(T) v) with (v) { … … 58 55 } 59 56 } 60 61 57 forall(| { T --?(T&); }) { 62 58 vec3(T)& --?(vec3(T)& v) { … … 75 71 // + 76 72 forall(| add(T)) { 77 vec3(T) ?+?(vec3(T) u, vec3(T) v) { // TODO( can't make this const ref )73 vec3(T) ?+?(vec3(T) u, vec3(T) v) { 78 74 return [u.x + v.x, u.y + v.y, u.z + v.z]; 79 75 } … … 83 79 } 84 80 } 85 86 81 87 82 forall(| { T ++?(T&); }) { … … 101 96 // * 102 97 forall(| multiply(T)) { 103 vec3(T) ?*?(vec3(T) v, T scalar) with (v) { // TODO (can't make this const ref)98 vec3(T) ?*?(vec3(T) v, T scalar) with (v) { 104 99 return [x * scalar, y * scalar, z * scalar]; 105 100 } 106 vec3(T) ?*?(T scalar, vec3(T) v) { // TODO (can't make this const ref)101 vec3(T) ?*?(T scalar, vec3(T) v) { 107 102 return v * scalar; 108 103 } … … 128 123 return [u.x / v.x, u.y / v.y, u.z / v.z]; 129 124 } 130 vec3(T)& ?/=?(vec3(T)& v, T scalar) with (v){125 vec3(T)& ?/=?(vec3(T)& v, T scalar) { 131 126 v = v / scalar; 132 127 return v; -
libcfa/src/vec/vec4.hfa
r94df8de r250dbae 10 10 } 11 11 12 13 12 forall (otype T) { 14 13 static inline { … … 31 30 } 32 31 33 // Assignment34 32 void ?=?(vec4(T)& vec, vec4(T) other) with (vec) { 35 33 [x,y,z,w] = other.[x,y,z,w]; … … 44 42 // - 45 43 forall(| subtract(T)) { 46 vec4(T) ?-?(vec4(T) u, vec4(T) v) { // TODO( can't make this const ref )44 vec4(T) ?-?(vec4(T) u, vec4(T) v) { 47 45 return [u.x - v.x, u.y - v.y, u.z - v.z, u.w - v.w]; 48 46 } … … 52 50 } 53 51 } 54 55 52 forall(| negate(T)) { 56 53 vec4(T) -?(vec4(T) v) with (v) { … … 58 55 } 59 56 } 60 61 57 forall(| { T --?(T&); }) { 62 58 vec4(T)& --?(vec4(T)& v) { … … 102 98 // * 103 99 forall(| multiply(T)) { 104 vec4(T) ?*?(vec4(T) v, T scalar) with (v) { // TODO (can't make this const ref)100 vec4(T) ?*?(vec4(T) v, T scalar) with (v) { 105 101 return [x * scalar, y * scalar, z * scalar, w * scalar]; 106 102 } 107 vec4(T) ?*?(T scalar, vec4(T) v) { // TODO (can't make this const ref)103 vec4(T) ?*?(T scalar, vec4(T) v) { 108 104 return v * scalar; 109 105 } … … 121 117 } 122 118 123 // Scalar Division119 // / 124 120 forall(| divide(T)) { 125 121 vec4(T) ?/?(vec4(T) v, T scalar) with (v) { … … 129 125 return [u.x / v.x, u.y / v.y, u.z / v.z, u.w / v.w]; 130 126 } 131 vec4(T)& ?/=?(vec4(T)& v, T scalar) with (v){127 vec4(T)& ?/=?(vec4(T)& v, T scalar) { 132 128 v = v / scalar; 133 129 return v; … … 253 249 } 254 250 255 // Relational Operators251 // relational 256 252 forall(| equality(T)) { 257 253 bool ?==?(vec4(T) u, vec4(T) v) with (u) {
Note: See TracChangeset
for help on using the changeset viewer.