[aefb247] | 1 | #include <vec/vec4.hfa> |
---|
[94df8de] | 2 | #include <fstream.hfa> |
---|
| 3 | #include <limits.hfa> |
---|
| 4 | |
---|
| 5 | int main(void) { |
---|
| 6 | vec4(int) v1 = {1,2,3,4}; |
---|
| 7 | sout | "ctor(x,y):" | v1; |
---|
| 8 | |
---|
| 9 | vec4(int) v2 = v1; |
---|
| 10 | sout | "copy ctor:" | v2; |
---|
| 11 | |
---|
| 12 | { |
---|
| 13 | vec4(int) u = {11, -5, 7, 11}; |
---|
| 14 | vec4(int) v = {2, 3, 7, 2}; |
---|
| 15 | sout | "?/?(vec)" | (u / v); |
---|
| 16 | sout | "?/=?(vec)" | (u /= v); |
---|
| 17 | } |
---|
| 18 | |
---|
| 19 | { |
---|
| 20 | vec4(int) u = {1, -3, 100, 1}; |
---|
| 21 | sout | "++?" | ++u; |
---|
| 22 | } |
---|
| 23 | |
---|
| 24 | { |
---|
| 25 | vec4(int) u = {1, -3, 100, 3}; |
---|
| 26 | sout | "--?" | --u; |
---|
| 27 | } |
---|
| 28 | { |
---|
| 29 | vec4(int) u = {1, -3, 100, 1}; |
---|
| 30 | sout | "?++(part 1)" | u++; |
---|
| 31 | sout | "?++(part 2)" | u; |
---|
| 32 | } |
---|
| 33 | { |
---|
| 34 | vec4(int) u = {1, -3, 100, 3}; |
---|
| 35 | sout | "?--(part 1)" | u--; |
---|
| 36 | sout | "?--(part 2)" | u; |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | // % |
---|
| 40 | { |
---|
| 41 | vec4(int) u = {-12, 123, 100, 5}; |
---|
| 42 | sout | "?%?(int)" | (u % 2); |
---|
| 43 | sout | "?%=?(int)" | (u %= 2); |
---|
| 44 | } |
---|
| 45 | { |
---|
| 46 | vec4(int) u = {-12, 27, 100, 14}; |
---|
| 47 | vec4(int) v = {5, 4, 13, 5}; |
---|
| 48 | sout | "?%?(vec)" | (u % v); |
---|
| 49 | sout | "?%=?(vec)" | (u %= v); |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | |
---|
| 53 | // & |
---|
| 54 | { |
---|
| 55 | vec4(int) u = {5, 1, 8, 15}; |
---|
| 56 | sout | "?&?(int)" | (u & (1 << 3)); |
---|
| 57 | sout | "?&=?(int)" | (u &= (1 << 3)); |
---|
| 58 | } |
---|
| 59 | { |
---|
| 60 | vec4(int) u = {5, 6, 5, 13}; |
---|
| 61 | vec4(int) v = {3, 7, 3, 7}; |
---|
| 62 | sout | "?&?(vec)" | (u & v); |
---|
| 63 | sout | "?&=?(vec)" | (u &= v); |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | // | |
---|
| 67 | { |
---|
| 68 | vec4(int) u = {5, 1, 5, 8}; |
---|
| 69 | sout | "?|?(int)" | (u | 2); |
---|
| 70 | sout | "?|=?(int)" | (u |= 2); |
---|
| 71 | } |
---|
| 72 | { |
---|
| 73 | vec4(int) u = {5, 1, 5, 2}; |
---|
| 74 | vec4(int) v = {2, 1, 2, 8}; |
---|
| 75 | sout | "?|?(vec)" | (u | v); |
---|
| 76 | sout | "?|=?(vec)" | (u |= v); |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | // ^ |
---|
| 80 | { |
---|
| 81 | vec4(int) u = {9, 5, 8, 13}; |
---|
| 82 | sout | "?^?(int)" | (u ^ 5); |
---|
| 83 | sout | "?^=?(int)" | (u ^= 5); |
---|
| 84 | } |
---|
| 85 | { |
---|
| 86 | vec4(int) u = {9, 5, 8, 13}; |
---|
| 87 | vec4(int) v = {5, 0, 1, 7}; |
---|
| 88 | sout | "?^?(vec)" | (u ^ v); |
---|
| 89 | sout | "?^=?(vec)" | (u ^= v); |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | // << |
---|
| 93 | { |
---|
| 94 | vec4(int) u = {2, 1, 4, 6}; |
---|
| 95 | sout | "?<<?(int)" | (u << 1); |
---|
| 96 | sout | "?<<=?(int)" | (u <<= 1); |
---|
| 97 | } |
---|
| 98 | { |
---|
| 99 | vec4(int) u = {1, 1, 1, 4}; |
---|
| 100 | vec4(int) v = {5, 2, 1, 1}; |
---|
| 101 | sout | "?<<?(vec)" | (u << v); |
---|
| 102 | sout | "?<<=?(vec)" | (u <<= v); |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | // >> |
---|
| 106 | { |
---|
| 107 | vec4(int) u = {2, 1, 4, 6}; |
---|
| 108 | sout | "?>>?(int)" | (u >> 1); |
---|
| 109 | sout | "?>>=?(int)" | (u >>= 1); |
---|
| 110 | } |
---|
| 111 | { |
---|
| 112 | vec4(int) u = {5, 7, 8, 32}; |
---|
| 113 | vec4(int) v = {1, 2, 2, 3}; |
---|
| 114 | sout | "?>>?(vec)" | (u >> v); |
---|
| 115 | sout | "?>>=?(vec)" | (u >>= v); |
---|
| 116 | } |
---|
| 117 | |
---|
| 118 | // ~ |
---|
| 119 | { |
---|
| 120 | vec4(int) u = {5, 2, 1, -1}; |
---|
| 121 | sout | "~?" | (~u); |
---|
| 122 | } |
---|
| 123 | |
---|
| 124 | v1 = (vec4(int)){2, 3, 4, 5}; |
---|
| 125 | v2 = (vec4(int)){13, 2, -7, -3}; |
---|
| 126 | sout | "dot:" | dot(v1, v2); |
---|
| 127 | |
---|
| 128 | v1 = (vec4(int)){2,3,4,5}; |
---|
| 129 | sout | "length_squared:" | length_squared(v1); |
---|
| 130 | } |
---|