1 | /* ----------------- */ |
---|
2 | /* --- nrbool1.c --- */ |
---|
3 | /* ----------------- */ |
---|
4 | |
---|
5 | /* |
---|
6 | * Copyright (c) 2000-2014, Lionel Lacassagne, All rights reserved |
---|
7 | * Univ Paris Sud XI, CNRS |
---|
8 | * |
---|
9 | * Distributed under the Boost Software License, Version 1.0 |
---|
10 | * see accompanying file LICENSE.txt or copy it at |
---|
11 | * http://www.boost.org/LICENSE_1_0.txt |
---|
12 | */ |
---|
13 | |
---|
14 | #include <stdio.h> |
---|
15 | #include <stddef.h> |
---|
16 | #include <stdlib.h> |
---|
17 | #include <math.h> // fabs |
---|
18 | |
---|
19 | #include "nrc_os_config.h" |
---|
20 | #include "mypredef.h" |
---|
21 | #include "nrtype.h" |
---|
22 | #include "nrdef.h" |
---|
23 | #include "nrmacro.h" |
---|
24 | #include "nrkernel.h" |
---|
25 | |
---|
26 | #include "nrbool1.h" |
---|
27 | |
---|
28 | /* |
---|
29 | * ----------- |
---|
30 | * --- Not --- |
---|
31 | * ----------- |
---|
32 | */ |
---|
33 | |
---|
34 | #undef not_type_vector |
---|
35 | #define not_type_vector(t) \ |
---|
36 | void short_name(t,not_,vector)(t * X, int32_t ncl, int32_t nch, t * Y) \ |
---|
37 | { \ |
---|
38 | for (int32_t j = ncl; j <= nch; j++) { \ |
---|
39 | Y[j] = ~X[j]; \ |
---|
40 | } \ |
---|
41 | } |
---|
42 | |
---|
43 | not_type_vector(int8_t); |
---|
44 | not_type_vector(uint8_t); |
---|
45 | not_type_vector(int16_t); |
---|
46 | not_type_vector(uint16_t); |
---|
47 | not_type_vector(int32_t); |
---|
48 | not_type_vector(uint32_t); |
---|
49 | not_type_vector(int64_t); |
---|
50 | not_type_vector(uint64_t); |
---|
51 | |
---|
52 | |
---|
53 | /* ----------------------------------------------------------------- */ |
---|
54 | void not_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 * Y) |
---|
55 | /* ----------------------------------------------------------------- */ |
---|
56 | { |
---|
57 | for (int32_t j = ncl; j <= nch; j++) { |
---|
58 | RGB8_NOT(X[j], Y[j]); |
---|
59 | } |
---|
60 | } |
---|
61 | |
---|
62 | /* -------------------------------------------------------------------- */ |
---|
63 | void not_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 * Y) |
---|
64 | /* -------------------------------------------------------------------- */ |
---|
65 | { |
---|
66 | for (int32_t j = ncl; j <= nch; j++) { |
---|
67 | RGBX8_NOT(X[j], Y[j]); |
---|
68 | } |
---|
69 | } |
---|
70 | |
---|
71 | /* |
---|
72 | * ----------- |
---|
73 | * --- Or --- |
---|
74 | * ----------- |
---|
75 | */ |
---|
76 | |
---|
77 | #undef or_type_vector |
---|
78 | #define or_type_vector(t) \ |
---|
79 | void short_name(t,or_,vector)(t * X, int32_t ncl, int32_t nch, t * Y, t * Z) \ |
---|
80 | { \ |
---|
81 | for (int32_t j = ncl; j <= nch; j++) { \ |
---|
82 | Z[j] = X[j] | Y[j]; \ |
---|
83 | } \ |
---|
84 | } |
---|
85 | |
---|
86 | or_type_vector(int8_t); |
---|
87 | or_type_vector(uint8_t); |
---|
88 | or_type_vector(int16_t); |
---|
89 | or_type_vector(uint16_t); |
---|
90 | or_type_vector(int32_t); |
---|
91 | or_type_vector(uint32_t); |
---|
92 | or_type_vector(int64_t); |
---|
93 | or_type_vector(uint64_t); |
---|
94 | |
---|
95 | |
---|
96 | /* ------------------------------------------------------------------------- */ |
---|
97 | void or_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 * Y, rgb8 * Z) |
---|
98 | /* ------------------------------------------------------------------------- */ |
---|
99 | { |
---|
100 | for (int32_t j = ncl; j <= nch; j++) { |
---|
101 | RGB8_OR(X[j], Y[j], Z[j]); |
---|
102 | } |
---|
103 | } |
---|
104 | /* ----------------------------------------------------------------------------- */ |
---|
105 | void or_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 * Y, rgbx8 * Z) |
---|
106 | /* ----------------------------------------------------------------------------- */ |
---|
107 | { |
---|
108 | for (int32_t j = ncl; j <= nch; j++) { |
---|
109 | RGBX8_OR(X[j], Y[j], Z[j]); |
---|
110 | } |
---|
111 | } |
---|
112 | |
---|
113 | |
---|
114 | #undef orc_type_vector |
---|
115 | #define orc_type_vector(t) \ |
---|
116 | void short_name(t,orc_,vector)(t * X, int32_t ncl, int32_t nch, t y, t * Z) \ |
---|
117 | { \ |
---|
118 | for (int32_t j = ncl; j <= nch; j++) { \ |
---|
119 | Z[j] = X[j] | y; \ |
---|
120 | } \ |
---|
121 | } |
---|
122 | |
---|
123 | orc_type_vector(int8_t); |
---|
124 | orc_type_vector(uint8_t); |
---|
125 | orc_type_vector(int16_t); |
---|
126 | orc_type_vector(uint16_t); |
---|
127 | orc_type_vector(int32_t); |
---|
128 | orc_type_vector(uint32_t); |
---|
129 | orc_type_vector(int64_t); |
---|
130 | orc_type_vector(uint64_t); |
---|
131 | |
---|
132 | |
---|
133 | /* ------------------------------------------------------------------------- */ |
---|
134 | void orc_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 y, rgb8 * Z) |
---|
135 | /* ------------------------------------------------------------------------- */ |
---|
136 | { |
---|
137 | for (int32_t j = ncl; j <= nch; j++) { |
---|
138 | RGB8_OR(X[j], y, Z[j]); |
---|
139 | } |
---|
140 | } |
---|
141 | |
---|
142 | /* ----------------------------------------------------------------------------- */ |
---|
143 | void orc_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 y, rgbx8 * Z) |
---|
144 | /* ----------------------------------------------------------------------------- */ |
---|
145 | { |
---|
146 | for (int32_t j = ncl; j <= nch; j++) { |
---|
147 | RGBX8_OR(X[j], y, Z[j]); |
---|
148 | } |
---|
149 | } |
---|
150 | |
---|
151 | |
---|
152 | /* |
---|
153 | * ----------- |
---|
154 | * --- XOR --- |
---|
155 | * ----------- |
---|
156 | */ |
---|
157 | |
---|
158 | #undef xor_type_vector |
---|
159 | #define xor_type_vector(t) \ |
---|
160 | void short_name(t,xor_,vector)(t * X, int32_t ncl, int32_t nch, t * Y, t * Z) \ |
---|
161 | { \ |
---|
162 | for (int32_t j = ncl; j <= nch; j++) { \ |
---|
163 | Z[j] = X[j] ^ Y[j]; \ |
---|
164 | } \ |
---|
165 | } |
---|
166 | |
---|
167 | xor_type_vector(int8_t); |
---|
168 | xor_type_vector(uint8_t); |
---|
169 | xor_type_vector(int16_t); |
---|
170 | xor_type_vector(uint16_t); |
---|
171 | xor_type_vector(int32_t); |
---|
172 | xor_type_vector(uint32_t); |
---|
173 | xor_type_vector(int64_t); |
---|
174 | xor_type_vector(uint64_t); |
---|
175 | |
---|
176 | |
---|
177 | /* -------------------------------------------------------------------------- */ |
---|
178 | void xor_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 * Y, rgb8 * Z) |
---|
179 | /* -------------------------------------------------------------------------- */ |
---|
180 | { |
---|
181 | for (int32_t j = ncl; j <= nch; j++) { |
---|
182 | RGB8_XOR(X[j], Y[j], Z[j]); |
---|
183 | } |
---|
184 | } |
---|
185 | |
---|
186 | /* ------------------------------------------------------------------------------ */ |
---|
187 | void xor_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 * Y, rgbx8 * Z) |
---|
188 | /* ------------------------------------------------------------------------------ */ |
---|
189 | { |
---|
190 | for (int32_t j = ncl; j <= nch; j++) { |
---|
191 | RGBX8_XOR(X[j], Y[j], Z[j]); |
---|
192 | } |
---|
193 | } |
---|
194 | |
---|
195 | |
---|
196 | #undef xorc_type_vector |
---|
197 | #define xorc_type_vector(t) \ |
---|
198 | void short_name(t,xorc_,vector)(t * X, int32_t ncl, int32_t nch, t y, t * Z) \ |
---|
199 | { \ |
---|
200 | for (int32_t j = ncl; j <= nch; j++) { \ |
---|
201 | Z[j] = X[j] ^ y; \ |
---|
202 | } \ |
---|
203 | } |
---|
204 | |
---|
205 | xorc_type_vector(int8_t); |
---|
206 | xorc_type_vector(uint8_t); |
---|
207 | xorc_type_vector(int16_t); |
---|
208 | xorc_type_vector(uint16_t); |
---|
209 | xorc_type_vector(int32_t); |
---|
210 | xorc_type_vector(uint32_t); |
---|
211 | xorc_type_vector(int64_t); |
---|
212 | xorc_type_vector(uint64_t); |
---|
213 | |
---|
214 | |
---|
215 | /* -------------------------------------------------------------------------- */ |
---|
216 | void xorc_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 y, rgb8 * Z) |
---|
217 | /* -------------------------------------------------------------------------- */ |
---|
218 | { |
---|
219 | for (int32_t j = ncl; j <= nch; j++) { |
---|
220 | RGB8_XOR(X[j], y, Z[j]); |
---|
221 | } |
---|
222 | } |
---|
223 | |
---|
224 | /* ------------------------------------------------------------------------------ */ |
---|
225 | void xorc_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 y, rgbx8 * Z) |
---|
226 | /* ------------------------------------------------------------------------------ */ |
---|
227 | { |
---|
228 | for (int32_t j = ncl; j <= nch; j++) { |
---|
229 | RGBX8_XOR(X[j], y, Z[j]); |
---|
230 | } |
---|
231 | } |
---|
232 | |
---|
233 | |
---|
234 | /* |
---|
235 | * ----------- |
---|
236 | * --- AND --- |
---|
237 | * ----------- |
---|
238 | */ |
---|
239 | |
---|
240 | |
---|
241 | #undef and_type_vector |
---|
242 | #define and_type_vector(t) \ |
---|
243 | void short_name(t,and_,vector)(t * X, int32_t ncl, int32_t nch, t * Y, t * Z) \ |
---|
244 | { \ |
---|
245 | for (int32_t j = ncl; j <= nch; j++) { \ |
---|
246 | Z[j] = X[j] & Y[j]; \ |
---|
247 | } \ |
---|
248 | } |
---|
249 | |
---|
250 | and_type_vector(int8_t); |
---|
251 | and_type_vector(uint8_t); |
---|
252 | and_type_vector(int16_t); |
---|
253 | and_type_vector(uint16_t); |
---|
254 | and_type_vector(int32_t); |
---|
255 | and_type_vector(uint32_t); |
---|
256 | and_type_vector(int64_t); |
---|
257 | and_type_vector(uint64_t); |
---|
258 | |
---|
259 | |
---|
260 | /* -------------------------------------------------------------------------- */ |
---|
261 | void and_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 * Y, rgb8 * Z) |
---|
262 | /* -------------------------------------------------------------------------- */ |
---|
263 | { |
---|
264 | for (int32_t j = ncl; j <= nch; j++) { |
---|
265 | RGB8_AND(X[j], Y[j], Z[j]); |
---|
266 | } |
---|
267 | } |
---|
268 | |
---|
269 | /* ------------------------------------------------------------------------------ */ |
---|
270 | void and_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 * Y, rgbx8 * Z) |
---|
271 | /* ------------------------------------------------------------------------------ */ |
---|
272 | { |
---|
273 | for (int32_t j = ncl; j <= nch; j++) { |
---|
274 | RGBX8_AND(X[j], Y[j], Z[j]); |
---|
275 | } |
---|
276 | } |
---|
277 | |
---|
278 | |
---|
279 | #undef andc_type_vector |
---|
280 | #define andc_type_vector(t) \ |
---|
281 | void short_name(t,andc_,vector)(t * X, int32_t ncl, int32_t nch, t y, t * Z) \ |
---|
282 | { \ |
---|
283 | for (int32_t j = ncl; j <= nch; j++) { \ |
---|
284 | Z[j] = X[j] ^ y; \ |
---|
285 | } \ |
---|
286 | } |
---|
287 | |
---|
288 | andc_type_vector(int8_t); |
---|
289 | andc_type_vector(uint8_t); |
---|
290 | andc_type_vector(int16_t); |
---|
291 | andc_type_vector(uint16_t); |
---|
292 | andc_type_vector(int32_t); |
---|
293 | andc_type_vector(uint32_t); |
---|
294 | andc_type_vector(int64_t); |
---|
295 | andc_type_vector(uint64_t); |
---|
296 | |
---|
297 | |
---|
298 | /* -------------------------------------------------------------------------- */ |
---|
299 | void andc_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 y, rgb8 * Z) |
---|
300 | /* -------------------------------------------------------------------------- */ |
---|
301 | { |
---|
302 | for (int32_t j = ncl; j <= nch; j++) { |
---|
303 | RGB8_AND(X[j], y, Z[j]); |
---|
304 | } |
---|
305 | } |
---|
306 | |
---|
307 | /* ------------------------------------------------------------------------------ */ |
---|
308 | void andc_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 y, rgbx8 * Z) |
---|
309 | /* ------------------------------------------------------------------------------ */ |
---|
310 | { |
---|
311 | for (int32_t j = ncl; j <= nch; j++) { |
---|
312 | RGBX8_AND(X[j], y, Z[j]); |
---|
313 | } |
---|
314 | } |
---|
315 | |
---|
316 | |
---|
317 | // Local Variables: |
---|
318 | // tab-width: 4 |
---|
319 | // c-basic-offset: 4 |
---|
320 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
321 | // indent-tabs-mode: nil |
---|
322 | // End: |
---|
323 | |
---|
324 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
325 | |
---|