| 1 | /* ------------------ */ |
|---|
| 2 | /* --- nrarith0.h --- */ |
|---|
| 3 | /* ------------------ */ |
|---|
| 4 | |
|---|
| 5 | /* |
|---|
| 6 | * Copyright (c) 2000-2014, Lionel Lacassagne, All rights reserved |
|---|
| 7 | * Univ Paris Sud XI, CNRS |
|---|
| 8 | */ |
|---|
| 9 | |
|---|
| 10 | #ifndef __NRARITH0_H__ |
|---|
| 11 | #define __NRARITH0_H__ |
|---|
| 12 | |
|---|
| 13 | /* ---------- */ |
|---|
| 14 | /* -- Swap -- */ |
|---|
| 15 | /* ---------- */ |
|---|
| 16 | |
|---|
| 17 | #define type_swap(t) \ |
|---|
| 18 | void short_name(t,,swap)(t * a, t * b) |
|---|
| 19 | |
|---|
| 20 | type_swap(int8_t); |
|---|
| 21 | type_swap(int16_t); |
|---|
| 22 | type_swap(int32_t); |
|---|
| 23 | type_swap(int64_t); |
|---|
| 24 | type_swap(float); |
|---|
| 25 | type_swap(double); |
|---|
| 26 | type_swap(rgb8); |
|---|
| 27 | type_swap(rgbx8); |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | /* --------- */ |
|---|
| 31 | /* -- Min -- */ |
|---|
| 32 | /* --------- */ |
|---|
| 33 | |
|---|
| 34 | #define type_min(t) \ |
|---|
| 35 | t short_name(t,,min)(t x1, t x2); \ |
|---|
| 36 | t short_name(t,,min2)(t x1, t x2); \ |
|---|
| 37 | t short_name(t,,min3)(t x1, t x2, t x3); \ |
|---|
| 38 | t short_name(t,,min4)(t x1, t x2, t x3, t x4); \ |
|---|
| 39 | t short_name(t,,min5)(t x1, t x2, t x3, t x4, t x5) \ |
|---|
| 40 | |
|---|
| 41 | type_min(float); |
|---|
| 42 | type_min(double); |
|---|
| 43 | type_min(int8_t); |
|---|
| 44 | type_min(uint8_t); |
|---|
| 45 | type_min(int16_t); |
|---|
| 46 | type_min(uint16_t); |
|---|
| 47 | type_min(int32_t); |
|---|
| 48 | type_min(uint32_t); |
|---|
| 49 | type_min(rgb8); |
|---|
| 50 | |
|---|
| 51 | |
|---|
| 52 | /* --------- */ |
|---|
| 53 | /* -- Max -- */ |
|---|
| 54 | /* --------- */ |
|---|
| 55 | |
|---|
| 56 | #define type_max(t) \ |
|---|
| 57 | t short_name(t,,max)(t x1, t x2); \ |
|---|
| 58 | t short_name(t,,max2)(t x1, t x2); \ |
|---|
| 59 | t short_name(t,,max3)(t x1, t x2, t x3); \ |
|---|
| 60 | t short_name(t,,max4)(t x1, t x2, t x3, t x4); \ |
|---|
| 61 | t short_name(t,,max5)(t x1, t x2, t x3, t x4, t x5) \ |
|---|
| 62 | |
|---|
| 63 | type_max(float); |
|---|
| 64 | type_max(double); |
|---|
| 65 | type_max(int8_t); |
|---|
| 66 | type_max(uint8_t); |
|---|
| 67 | type_max(int16_t); |
|---|
| 68 | type_max(uint16_t); |
|---|
| 69 | type_max(int32_t); |
|---|
| 70 | type_max(uint32_t); |
|---|
| 71 | type_max(rgb8); |
|---|
| 72 | |
|---|
| 73 | |
|---|
| 74 | /* ----------- */ |
|---|
| 75 | /* -- Other -- */ |
|---|
| 76 | /* ----------- */ |
|---|
| 77 | |
|---|
| 78 | int32_t i32bit(int32_t x, int32_t n); |
|---|
| 79 | int32_t sym_int32(int32_t x); |
|---|
| 80 | int32_t myLog2(int32_t x); |
|---|
| 81 | int32_t next_power2(int32_t x); |
|---|
| 82 | int32_t myGCD(int32_t u, int32_t v); |
|---|
| 83 | int32_t myLCM(int32_t u, int32_t v); |
|---|
| 84 | |
|---|
| 85 | #endif |
|---|
| 86 | |
|---|
| 87 | // Local Variables: |
|---|
| 88 | // tab-width: 4 |
|---|
| 89 | // c-basic-offset: 4 |
|---|
| 90 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
|---|
| 91 | // indent-tabs-mode: nil |
|---|
| 92 | // End: |
|---|
| 93 | |
|---|
| 94 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
|---|
| 95 | |
|---|