1
+ package glm_.vec1.operators
2
+
3
+ import glm_.i
4
+ import glm_.vec1.Vec1i
5
+ import glm_.vec1.Vec1i.Companion.div
6
+ import glm_.vec1.Vec1i.Companion.minus
7
+ import glm_.vec1.Vec1i.Companion.plus
8
+ import glm_.vec1.Vec1i.Companion.rem
9
+ import glm_.vec1.Vec1i.Companion.times
10
+
11
+ /* *
12
+ * Created by GBarbieri on 08.11.2016.
13
+ */
14
+ interface vec1i_operators {
15
+
16
+ fun plus (res : Vec1i , a : Vec1i , bX : Int ): Vec1i {
17
+ res.x = a.x + bX
18
+ return res
19
+ }
20
+
21
+ fun minus (res : Vec1i , a : Vec1i , bX : Int ): Vec1i {
22
+ res.x = a.x - bX
23
+ return res
24
+ }
25
+
26
+ fun minus (res : Vec1i , aX : Int , b : Vec1i ): Vec1i {
27
+ res.x = aX - b.x
28
+ return res
29
+ }
30
+
31
+ fun times (res : Vec1i , a : Vec1i , bX : Int ): Vec1i {
32
+ res.x = a.x * bX
33
+ return res
34
+ }
35
+
36
+ fun div (res : Vec1i , a : Vec1i , bX : Int ): Vec1i {
37
+ res.x = a.x / bX
38
+ return res
39
+ }
40
+
41
+ fun div (res : Vec1i , aX : Int , b : Vec1i ): Vec1i {
42
+ res.x = aX / b.x
43
+ return res
44
+ }
45
+
46
+ fun rem (res : Vec1i , a : Vec1i , bX : Int ): Vec1i {
47
+ res.x = a.x % bX
48
+ return res
49
+ }
50
+
51
+ fun rem (res : Vec1i , aX : Int , b : Vec1i ): Vec1i {
52
+ res.x = aX % b.x
53
+ return res
54
+ }
55
+
56
+ fun and (res : Vec1i , a : Vec1i , bX : Int ): Vec1i {
57
+ res.x = a.x and bX
58
+ return res
59
+ }
60
+
61
+ fun or (res : Vec1i , a : Vec1i , bX : Int ): Vec1i {
62
+ res.x = a.x or bX
63
+ return res
64
+ }
65
+
66
+ fun xor (res : Vec1i , a : Vec1i , bX : Int ): Vec1i {
67
+ res.x = a.x xor bX
68
+ return res
69
+ }
70
+
71
+ fun shl (res : Vec1i , a : Vec1i , bX : Int ): Vec1i {
72
+ res.x = a.x shl bX
73
+ return res
74
+ }
75
+
76
+ fun shr (res : Vec1i , a : Vec1i , bX : Int ): Vec1i {
77
+ res.x = a.x shr bX
78
+ return res
79
+ }
80
+
81
+ fun inv (res : Vec1i , a : Vec1i ): Vec1i {
82
+ res.x = a.x.inv ()
83
+ return res
84
+ }
85
+ }
86
+
87
+
88
+ // -- Specific binary arithmetic operators --
89
+
90
+ infix operator fun Int.plus (b : Vec1i ) = plus(Vec1i (), b, this )
91
+ fun Int.plus (b : Vec1i , res : Vec1i ) = plus(res, b, this )
92
+ infix fun Int.plus_ (b : Vec1i ) = plus(b, b, this )
93
+
94
+ infix operator fun Int.minus (b : Vec1i ) = minus(Vec1i (), this , b)
95
+ fun Int.minus (b : Vec1i , res : Vec1i ) = minus(res, b, this )
96
+ infix fun Int.minus_ (b : Vec1i ) = minus(b, this , b)
97
+
98
+ infix operator fun Int.times (b : Vec1i ) = times(Vec1i (), b, this )
99
+ fun Int.times (b : Vec1i , res : Vec1i ) = times(res, b, this )
100
+ infix fun Int.times_ (b : Vec1i ) = times(b, b, this )
101
+
102
+ infix operator fun Int.div (b : Vec1i ) = div(Vec1i (), this , b)
103
+ fun Int.div (b : Vec1i , res : Vec1i ) = div(res, b, this )
104
+ infix fun Int.div_ (b : Vec1i ) = div(b, this , b)
105
+
106
+ infix operator fun Int.rem (b : Vec1i ) = rem(Vec1i (), this , b)
107
+ fun Int.rem (b : Vec1i , res : Vec1i ) = rem(res, b, this )
108
+ infix fun Int.rem_ (b : Vec1i ) = rem(b, this , b)
109
+
110
+
111
+ // -- Generic binary arithmetic operators --
112
+
113
+ infix operator fun Number.plus (b : Vec1i ) = plus(Vec1i (), b, this .i)
114
+ fun Number.plus (b : Vec1i , res : Vec1i ) = plus(res, b, this .i)
115
+ infix fun Number.plus_ (b : Vec1i ) = plus(b, b, this .i)
116
+
117
+ infix operator fun Number.minus (b : Vec1i ) = minus(Vec1i (), this .i, b)
118
+ fun Number.minus (b : Vec1i , res : Vec1i ) = minus(res, b, this .i)
119
+ infix fun Number.minus_ (b : Vec1i ) = minus(b, this .i, b)
120
+
121
+ infix operator fun Number.times (b : Vec1i ) = times(Vec1i (), b, this .i)
122
+ fun Number.times (b : Vec1i , res : Vec1i ) = times(res, b, this .i)
123
+ infix fun Number.times_ (b : Vec1i ) = times(b, b, this .i)
124
+
125
+ infix operator fun Number.div (b : Vec1i ) = div(Vec1i (), this .i, b)
126
+ fun Number.div (b : Vec1i , res : Vec1i ) = div(res, b, this .i)
127
+ infix fun Number.div_ (b : Vec1i ) = div(b, this .i, b)
128
+
129
+ infix operator fun Number.rem (b : Vec1i ) = rem(Vec1i (), this .i, b)
130
+ fun Number.rem (b : Vec1i , res : Vec1i ) = rem(res, b, this .i)
131
+ infix fun Number.rem_ (b : Vec1i ) = rem(b, this .i, b)
0 commit comments