1 | /* ------------------ */ |
---|
2 | /* --- nrmem2XX.c --- */ |
---|
3 | /* ------------------ */ |
---|
4 | |
---|
5 | /* |
---|
6 | * Copyright (c) 2000-2014, Lionel Lacassagne, All rights reserved |
---|
7 | * Univ Paris Sud XI, CNRS |
---|
8 | */ |
---|
9 | |
---|
10 | #include "def.h" |
---|
11 | #include "nrmem1.h" |
---|
12 | #include "nrmem2.h" |
---|
13 | #include "nrmem2X.h" |
---|
14 | #include "nrmem2XX.h" |
---|
15 | |
---|
16 | /* ---------------------------- */ |
---|
17 | /* --- Left & right Rotate --- */ |
---|
18 | /* ---------------------------- */ |
---|
19 | // (i,j) -> (n-j,i) -> (n-i,n-j) -> (j,n-i) -> |
---|
20 | |
---|
21 | |
---|
22 | #undef rotate_type_matrix |
---|
23 | #define rotate_type_matrix(t) \ |
---|
24 | void short_name(t,lrotate_,matrix)(t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** D) \ |
---|
25 | { \ |
---|
26 | int32_t n = nrl + nrh; \ |
---|
27 | for (int32_t i = nrl; i <= nrh; i++) { \ |
---|
28 | for (int32_t j = ncl; j <= nch; j++) { \ |
---|
29 | D[n - j][i] = S[i][j]; \ |
---|
30 | } \ |
---|
31 | } \ |
---|
32 | } \ |
---|
33 | void short_name(t,rrotate_,matrix)(t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** D) \ |
---|
34 | { \ |
---|
35 | int32_t n = nrl + nrh; \ |
---|
36 | for (int32_t i = nrl; i <= nrh; i++) { \ |
---|
37 | for (int32_t j = ncl; j <= nch; j++) { \ |
---|
38 | D[i][j] = S[n - j][i]; \ |
---|
39 | } \ |
---|
40 | } \ |
---|
41 | } \ |
---|
42 | void short_name(t,lrotate1_,matrix)(t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch) \ |
---|
43 | int32_t n = nrl + nrh; \ |
---|
44 | t temp; \ |
---|
45 | for (int32_t i = nrl; i <= nrh; i++) { \ |
---|
46 | for (int32_t j = ncl; j <= nch; j++) { \ |
---|
47 | temp = S[n - j][i]; \ |
---|
48 | S[n - j][i] = S[i][j]; \ |
---|
49 | S[i][j] = temp; \ |
---|
50 | } \ |
---|
51 | } \ |
---|
52 | } \ |
---|
53 | void short_name(t,rrotate1_,matrix)(t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch) \ |
---|
54 | { \ |
---|
55 | int32_t n = nrl + nrh; \ |
---|
56 | t temp; \ |
---|
57 | for (int32_t i = nrl; i <= nrh; i++) { \ |
---|
58 | for (int32_t j = ncl; j <= nch; j++) { \ |
---|
59 | temp = S[i][j]; \ |
---|
60 | S[i][j] = S[n - j][i]; \ |
---|
61 | S[n - j][i] = temp; \ |
---|
62 | } \ |
---|
63 | } \ |
---|
64 | } |
---|
65 | |
---|
66 | rotate_type_matrix(int8_t); |
---|
67 | rotate_type_matrix(uint8_t); |
---|
68 | rotate_type_matrix(int16_t); |
---|
69 | rotate_type_matrix(uint16_t); |
---|
70 | rotate_type_matrix(int32_t); |
---|
71 | rotate_type_matrix(uint32_t); |
---|
72 | rotate_type_matrix(int64_t); |
---|
73 | rotate_type_matrix(uint64_t); |
---|
74 | rotate_type_matrix(float); |
---|
75 | rotate_type_matrix(double); |
---|
76 | rotate_type_matrix(rgb8); |
---|
77 | rotate_type_matrix(rgbx8); |
---|
78 | |
---|
79 | |
---|
80 | |
---|
81 | /* ---------------------------------- */ |
---|
82 | /* --- Horizontal & Vertical Flip --- */ |
---|
83 | /* ---------------------------------- */ |
---|
84 | |
---|
85 | |
---|
86 | #undef flip_type_matrix |
---|
87 | #define flip_type_matrix(t) \ |
---|
88 | void short_name(t,hflip_,matrix)(t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** D) \ |
---|
89 | { \ |
---|
90 | int32_t n = ncl + nch; \ |
---|
91 | for (int32_t i = nrl; i <= nrh; i++) { \ |
---|
92 | for (int32_t j = ncl; j <= nch; j++) { \ |
---|
93 | D[i][n - j] = S[i][j]; \ |
---|
94 | } \ |
---|
95 | } \ |
---|
96 | } \ |
---|
97 | void short_name(t,vflip_,matrix)(t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** D) \ |
---|
98 | { \ |
---|
99 | int32_t n = nrl + nrh; \ |
---|
100 | for (int32_t i = nrl; i <= nrh; i++) { \ |
---|
101 | for (int32_t j = ncl; j <= nch; j++) { \ |
---|
102 | D[n - i][j] = S[i][j]; \ |
---|
103 | } \ |
---|
104 | } \ |
---|
105 | } \ |
---|
106 | void short_name(t,hflip1_,matrix)(t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch) \ |
---|
107 | { \ |
---|
108 | int32_t n = ncl + nch; \ |
---|
109 | t temp; \ |
---|
110 | for (int32_t i = nrl; i <= nrh; i++) { \ |
---|
111 | for (int32_t j = ncl; j <= nch; j++) { \ |
---|
112 | temp = S[i][n - j]; \ |
---|
113 | S[i][n - j] = S[i][j]; \ |
---|
114 | S[i][j] = temp; \ |
---|
115 | } \ |
---|
116 | } \ |
---|
117 | } \ |
---|
118 | void short_name(t,vflip1_,matrix)(t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch) \ |
---|
119 | { \ |
---|
120 | int32_t n = ncl + nch; \ |
---|
121 | t temp; \ |
---|
122 | for (int32_t i = nrl; i <= nrh; i++) { \ |
---|
123 | for (int32_t j = ncl; j <= nch; j++) { \ |
---|
124 | temp = S[n - i][j]; \ |
---|
125 | S[n - i][j] = S[i][j]; \ |
---|
126 | S[i][j] = temp; \ |
---|
127 | } \ |
---|
128 | } \ |
---|
129 | } |
---|
130 | |
---|
131 | flip_type_matrix(int8_t); |
---|
132 | flip_type_matrix(uint8_t); |
---|
133 | flip_type_matrix(int16_t); |
---|
134 | flip_type_matrix(uint16_t); |
---|
135 | flip_type_matrix(int32_t); |
---|
136 | flip_type_matrix(uint32_t); |
---|
137 | flip_type_matrix(int64_t); |
---|
138 | flip_type_matrix(uint64_t); |
---|
139 | flip_type_matrix(float); |
---|
140 | flip_type_matrix(double); |
---|
141 | flip_type_matrix(rgb8); |
---|
142 | flip_type_matrix(rgbx8); |
---|
143 | |
---|
144 | |
---|
145 | |
---|
146 | // Local Variables: |
---|
147 | // tab-width: 4 |
---|
148 | // c-basic-offset: 4 |
---|
149 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
150 | // indent-tabs-mode: nil |
---|
151 | // End: |
---|
152 | |
---|
153 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
154 | |
---|