Changeset 94df8de
 Timestamp:
 Dec 30, 2019, 11:57:42 AM (3 years ago)
 Branches:
 armeh, enum, forallpointerdecay, jacob/cs343translation, master, newastuniqueexpr, pthreademulation, qualifiedEnum
 Children:
 250dbae
 Parents:
 0b3cdad
 Files:

 2 added
 1 edited
Legend:
 Unmodified
 Added
 Removed

libcfa/src/vec/vec4.hfa
r0b3cdad r94df8de 42 42 // Primitive mathematical operations 43 43 44 // Subtraction 45 44 //  46 45 forall( subtract(T)) { 47 46 vec4(T) ??(vec4(T) u, vec4(T) v) { // TODO( can't make this const ref ) … … 60 59 } 61 60 62 // Addition 61 forall( { T ?(T&); }) { 62 vec4(T)& ?(vec4(T)& v) { 63 v.x; 64 v.y; 65 v.z; 66 v.w; 67 return v; 68 } 69 vec4(T) ?(vec4(T)& v) { 70 vec4(T) copy = v; 71 v; 72 return copy; 73 } 74 } 75 76 // + 63 77 forall( add(T)) { 64 vec4(T) ?+?(vec4(T) u, vec4(T) v) { // TODO( can't make this const ref )78 vec4(T) ?+?(vec4(T) u, vec4(T) v) { 65 79 return [u.x + v.x, u.y + v.y, u.z + v.z, u.w + v.w]; 66 80 } … … 71 85 } 72 86 73 // Scalar Multiplication 87 forall( { T ++?(T&); }) { 88 vec4(T)& ++?(vec4(T)& v) { 89 ++v.x; 90 ++v.y; 91 ++v.z; 92 ++v.w; 93 return v; 94 } 95 vec4(T) ?++(vec4(T)& v) { 96 vec4(T) copy = v; 97 ++v; 98 return copy; 99 } 100 } 101 102 // * 74 103 forall( multiply(T)) { 75 104 vec4(T) ?*?(vec4(T) v, T scalar) with (v) { // TODO (can't make this const ref) … … 79 108 return v * scalar; 80 109 } 110 vec4(T) ?*?(vec4(T) u, vec4(T) v) { 111 return [u.x * v.x, u.y * v.y, u.z * v.z, u.w * v.w]; 112 } 81 113 vec4(T)& ?*=?(vec4(T)& v, T scalar) { 82 114 v = v * scalar; 83 115 return v; 116 } 117 vec4(T)& ?*=?(vec4(T)& u, vec4(T) v) { 118 u = u * v; 119 return u; 84 120 } 85 121 } … … 90 126 return [x / scalar, y / scalar, z / scalar, w / scalar]; 91 127 } 128 vec4(T) ?/?(vec4(T) u, vec4(T) v) { 129 return [u.x / v.x, u.y / v.y, u.z / v.z, u.w / v.w]; 130 } 92 131 vec4(T)& ?/=?(vec4(T)& v, T scalar) with (v) { 93 132 v = v / scalar; 94 133 return v; 95 134 } 135 vec4(T)& ?/=?(vec4(T)& u, vec4(T) v) { 136 u = u / v; 137 return u; 138 } 139 } 140 141 // % 142 forall( { T ?%?(T,T); }) { 143 vec4(T) ?%?(vec4(T) v, T scalar) with (v) { 144 return [x % scalar, y % scalar, z % scalar, w % scalar]; 145 } 146 vec4(T)& ?%=?(vec4(T)& u, T scalar) { 147 u = u % scalar; 148 return u; 149 } 150 vec4(T) ?%?(vec4(T) u, vec4(T) v) { 151 return [u.x % v.x, u.y % v.y, u.z % v.z, u.w % v.w]; 152 } 153 vec4(T)& ?%=?(vec4(T)& u, vec4(T) v) { 154 u = u % v; 155 return u; 156 } 157 } 158 159 // & 160 forall( { T ?&?(T,T); }) { 161 vec4(T) ?&?(vec4(T) v, T scalar) with (v) { 162 return [x & scalar, y & scalar, z & scalar, w & scalar]; 163 } 164 vec4(T)& ?&=?(vec4(T)& u, T scalar) { 165 u = u & scalar; 166 return u; 167 } 168 vec4(T) ?&?(vec4(T) u, vec4(T) v) { 169 return [u.x & v.x, u.y & v.y, u.z & v.z, u.w & v.w]; 170 } 171 vec4(T)& ?&=?(vec4(T)& u, vec4(T) v) { 172 u = u & v; 173 return u; 174 } 175 } 176 177 //  178 forall( { T ??(T,T); }) { 179 vec4(T) ??(vec4(T) v, T scalar) with (v) { 180 return [x  scalar, y  scalar, z  scalar, w  scalar]; 181 } 182 vec4(T)& ?=?(vec4(T)& u, T scalar) { 183 u = u  scalar; 184 return u; 185 } 186 vec4(T) ??(vec4(T) u, vec4(T) v) { 187 return [u.x  v.x, u.y  v.y, u.z  v.z, u.w  v.w]; 188 } 189 vec4(T)& ?=?(vec4(T)& u, vec4(T) v) { 190 u = u  v; 191 return u; 192 } 193 } 194 195 // ^ 196 forall( { T ?^?(T,T); }) { 197 vec4(T) ?^?(vec4(T) v, T scalar) with (v) { 198 return [x ^ scalar, y ^ scalar, z ^ scalar, w ^ scalar]; 199 } 200 vec4(T)& ?^=?(vec4(T)& u, T scalar) { 201 u = u ^ scalar; 202 return u; 203 } 204 vec4(T) ?^?(vec4(T) u, vec4(T) v) { 205 return [u.x ^ v.x, u.y ^ v.y, u.z ^ v.z, u.w ^ v.w]; 206 } 207 vec4(T)& ?^=?(vec4(T)& u, vec4(T) v) { 208 u = u ^ v; 209 return u; 210 } 211 } 212 213 // << 214 forall( { T ?<<?(T,T); }) { 215 vec4(T) ?<<?(vec4(T) v, T scalar) with (v) { 216 return [x << scalar, y << scalar, z << scalar, w << scalar]; 217 } 218 vec4(T)& ?<<=?(vec4(T)& u, T scalar) { 219 u = u << scalar; 220 return u; 221 } 222 vec4(T) ?<<?(vec4(T) u, vec4(T) v) { 223 return [u.x << v.x, u.y << v.y, u.z << v.z, u.w << v.w]; 224 } 225 vec4(T)& ?<<=?(vec4(T)& u, vec4(T) v) { 226 u = u << v; 227 return u; 228 } 229 } 230 231 // >> 232 forall( { T ?>>?(T,T); }) { 233 vec4(T) ?>>?(vec4(T) v, T scalar) with (v) { 234 return [x >> scalar, y >> scalar, z >> scalar, w >> scalar]; 235 } 236 vec4(T)& ?>>=?(vec4(T)& u, T scalar) { 237 u = u >> scalar; 238 return u; 239 } 240 vec4(T) ?>>?(vec4(T) u, vec4(T) v) { 241 return [u.x >> v.x, u.y >> v.y, u.z >> v.z, u.w >> v.w]; 242 } 243 vec4(T)& ?>>=?(vec4(T)& u, vec4(T) v) { 244 u = u >> v; 245 return u; 246 } 247 } 248 249 // ~ 250 forall( { T ~?(T); }) 251 vec4(T) ~?(vec4(T) v) with (v) { 252 return [~x, ~y, ~z, ~w]; 96 253 } 97 254
Note: See TracChangeset
for help on using the changeset viewer.