/
oh_vectors_unity_buildtest.cpp
181 lines (147 loc) · 2.64 KB
/
oh_vectors_unity_buildtest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#pragma once
#include <stdint.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include <intrin.h>
#include <math.h>
typedef uint8_t Byte;
typedef uint32_t UInt32;
typedef int32_t Int32;
typedef int64_t Int64;
typedef uint32_t Boolean;
typedef float Single;
typedef double Double;
#define Min(X, Y) (((X) < (Y)) ? (X) : (Y))
#define Max(X, Y) (((X) > (Y)) ? (X) : (Y))
inline Int32 Pow2Rem(Int32 A, Int32 Pow2)
{
return A & ((1 << Pow2) - 1);
}
inline Int32 Pow2Div(Int32 A, Int32 Pow2)
{
return A >> Pow2;
}
inline Int32 Pow2CeilDiv(Int32 A, Int32 Pow2)
{
return (A >> Pow2) + ((A & ((1 << Pow2) - 1)) != 0);
}
inline Int32 Pow2Mult(Int32 A, Int32 Pow2)
{
return A << Pow2;
}
inline Int32 Pow2Mult(Int64 A, Int64 Pow2)
{
return A << Pow2;
}
inline Byte Pow2Rem(Byte A, Byte Pow2)
{
return A & ((1 << Pow2) - 1);
}
inline Byte Pow2Div(Byte A, Byte Pow2)
{
return A >> Pow2;
}
inline Byte Pow2CeilDiv(Byte A, Byte Pow2)
{
return (A >> Pow2) + ((A & ((1 << Pow2) - 1)) != 0);
}
inline Byte Pow2Mult(Byte A, Byte Pow2)
{
return A << Pow2;
}
inline Single Sqrt(Single A)
{
return sqrtf(A);
}
inline Int32 Div(Int32 A, Int32 B)
{
Int32 q = A/B, r = A%B;
if ((r > 0 && B < 0) || (r < 0 && B > 0))
return q-1;
else
return q;
}
inline Int32 CeilDiv(Int32 A, Int32 B)
{
return (A/B) + ((A%B!=0)
? !((A>0)^(B>0))
: 0);
}
inline Int32 Rem(Int32 A, Int32 B)
{
Int32 r = A%B;
if ((r > 0 && B < 0) || (r < 0 && B > 0))
return r+B;
else
return r;
}
inline Single Div(Single A, Single B)
{
return A/B;
}
inline Byte Div(Byte A, Byte B)
{
return A/B;
}
inline Double Div(Double A, Double B)
{
return A/B;
}
inline Byte CeilDiv(Byte A, Byte B)
{
return (A/B) + ((A%B!=0)
? !((A>0)^(B>0))
: 0);
}
inline Byte Rem(Byte A, Byte B)
{
return A%B;
}
inline Int32 FloorIF(Single x)
{
return (Int32)floorf(x);
}
inline Int32 CeilIF(Single x)
{
return (Int32)ceilf(x);
}
inline Byte FloorBF(Single x)
{
return (Byte)floorf(x);
}
inline Byte CeilBF(Single x)
{
return (Byte)ceilf(x);
}
inline Int32 FloorID(Double x)
{
return (Int32)floor(x);
}
inline Int32 CeilID(Double x)
{
return (Int32)ceil(x);
}
inline Byte FloorBD(Double x)
{
return (Byte)floor(x);
}
inline Byte CeilBD(Double x)
{
return (Byte)ceil(x);
}
#include "oh_vectors_unity.h"
double Example(VectorB2 byteVector)
{
auto six = MkVectorB2(6); // (6, 6)
return Volume(
MkVectorD4B(
SwizzXXYY(
ElRem(byteVector, six)
)
)
);
}
Int32 main()
{
}