1 | /* ------------------ */ |
---|
2 | /* --- nrlinalg.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 | |
---|
18 | #include "mypredef.h" |
---|
19 | #include "nrtype.h" |
---|
20 | #include "nrdef.h" |
---|
21 | #include "nrmacro.h" |
---|
22 | #include "nrkernel.h" |
---|
23 | |
---|
24 | #include "nrlinalg.h" |
---|
25 | |
---|
26 | |
---|
27 | /* ---------------------------------------------------------------------------------------- */ |
---|
28 | IMAGE_EXPORT(void) transpose_bmatrix(byte **S, long nrl,long nrh,long ncl, long nch, byte **D) |
---|
29 | /* ---------------------------------------------------------------------------------------- */ |
---|
30 | { |
---|
31 | int i, j; |
---|
32 | |
---|
33 | for(i=nrl; i<=nch; i++) { |
---|
34 | for(j=ncl; j<=nch; j++) { |
---|
35 | D[j][i] = S[i][j]; |
---|
36 | } |
---|
37 | } |
---|
38 | } |
---|
39 | /* ------------------------------------------------------------------------------------------- */ |
---|
40 | IMAGE_EXPORT(void) transpose_si16matrix(sint16 **S, long nrl,long nrh,long ncl, long nch, sint16 **D) |
---|
41 | /* ------------------------------------------------------------------------------------------- */ |
---|
42 | { |
---|
43 | int i, j; |
---|
44 | |
---|
45 | for(i=nrl; i<=nch; i++) { |
---|
46 | for(j=ncl; j<=nch; j++) { |
---|
47 | D[j][i] = S[i][j]; |
---|
48 | } |
---|
49 | } |
---|
50 | } |
---|
51 | /* ------------------------------------------------------------------------------------------- */ |
---|
52 | IMAGE_EXPORT(void) transpose_ui16matrix(uint16 **S, long nrl,long nrh,long ncl, long nch, uint16 **D) |
---|
53 | /* ------------------------------------------------------------------------------------------- */ |
---|
54 | { |
---|
55 | int i, j; |
---|
56 | |
---|
57 | for(i=nrl; i<=nch; i++) { |
---|
58 | for(j=ncl; j<=nch; j++) { |
---|
59 | D[j][i] = S[i][j]; |
---|
60 | } |
---|
61 | } |
---|
62 | } |
---|
63 | /* ----------------------------------------------------------------------------------------------- */ |
---|
64 | IMAGE_EXPORT(void) transpose_si32matrix(sint32 **S, long nrl,long nrh,long ncl, long nch, sint32 **D) |
---|
65 | /* ----------------------------------------------------------------------------------------------- */ |
---|
66 | { |
---|
67 | int i, j; |
---|
68 | |
---|
69 | for(i=nrl; i<=nch; i++) { |
---|
70 | for(j=ncl; j<=nch; j++) { |
---|
71 | D[j][i] = S[i][j]; |
---|
72 | } |
---|
73 | } |
---|
74 | } |
---|
75 | /* ----------------------------------------------------------------------------------------------- */ |
---|
76 | IMAGE_EXPORT(void) transpose_ui32matrix(uint32 **S, long nrl,long nrh,long ncl, long nch, uint32 **D) |
---|
77 | /* ----------------------------------------------------------------------------------------------- */ |
---|
78 | { |
---|
79 | int i, j; |
---|
80 | |
---|
81 | for(i=nrl; i<=nch; i++) { |
---|
82 | for(j=ncl; j<=nch; j++) { |
---|
83 | D[j][i] = S[i][j]; |
---|
84 | } |
---|
85 | } |
---|
86 | } |
---|
87 | /* ----------------------------------------------------------------------------------------- */ |
---|
88 | IMAGE_EXPORT(void) transpose_f32matrix(float32 **S, long nrl,long nrh,long ncl, long nch, float32 **D) |
---|
89 | /* ----------------------------------------------------------------------------------------- */ |
---|
90 | { |
---|
91 | int i, j; |
---|
92 | |
---|
93 | for(i=nrl; i<=nch; i++) { |
---|
94 | for(j=ncl; j<=nch; j++) { |
---|
95 | D[j][i] = S[i][j]; |
---|
96 | } |
---|
97 | } |
---|
98 | } |
---|
99 | /* -------------------------------------------------------------------------------------------- */ |
---|
100 | IMAGE_EXPORT(void) transpose_dmatrix(float64 **S, long nrl,long nrh,long ncl, long nch, float64 **D) |
---|
101 | /* -------------------------------------------------------------------------------------------- */ |
---|
102 | { |
---|
103 | int i, j; |
---|
104 | |
---|
105 | for(i=nrl; i<=nch; i++) { |
---|
106 | for(j=ncl; j<=nch; j++) { |
---|
107 | D[j][i] = S[i][j]; |
---|
108 | } |
---|
109 | } |
---|
110 | } |
---|
111 | /* ------------------------------------------------------------------------------------------- */ |
---|
112 | IMAGE_EXPORT(void) transpose_rgb8matrix(rgb8 **S, long nrl,long nrh,long ncl, long nch, rgb8 **D) |
---|
113 | /* ------------------------------------------------------------------------------------------- */ |
---|
114 | { |
---|
115 | int i, j; |
---|
116 | |
---|
117 | for(i=nrl; i<=nch; i++) { |
---|
118 | for(j=ncl; j<=nch; j++) { |
---|
119 | D[j][i] = S[i][j]; |
---|
120 | } |
---|
121 | } |
---|
122 | } |
---|
123 | /* ------------------------------------------------------------------------------- */ |
---|
124 | IMAGE_EXPORT(void) transpose1_bmatrix(byte **S, long nrl,long nrh,long ncl, long nch) |
---|
125 | /* ------------------------------------------------------------------------------- */ |
---|
126 | { |
---|
127 | int i, j; |
---|
128 | byte t; |
---|
129 | |
---|
130 | for(i=nrl; i<=nch; i++) { |
---|
131 | for(j=i+1; j<=nch; j++) { |
---|
132 | t = S[j][i]; |
---|
133 | S[j][i] = S[i][j]; |
---|
134 | S[i][j] = t; |
---|
135 | } |
---|
136 | } |
---|
137 | } |
---|
138 | /* ---------------------------------------------------------------------------------- */ |
---|
139 | IMAGE_EXPORT(void) transpose1_si16matrix(sint16 **S, long nrl,long nrh,long ncl, long nch) |
---|
140 | /* ---------------------------------------------------------------------------------- */ |
---|
141 | { |
---|
142 | int i, j; |
---|
143 | int16 t; |
---|
144 | |
---|
145 | for(i=nrl; i<=nch; i++) { |
---|
146 | for(j=i+1; j<=nch; j++) { |
---|
147 | t = S[j][i]; |
---|
148 | S[j][i] = S[i][j]; |
---|
149 | S[i][j] = t; |
---|
150 | } |
---|
151 | } |
---|
152 | } |
---|
153 | /* ------------------------------------------------------------------------------------ */ |
---|
154 | IMAGE_EXPORT(void) transpose1_ui16matrix(uint16 **S, long nrl,long nrh,long ncl, long nch) |
---|
155 | /* ------------------------------------------------------------------------------------ */ |
---|
156 | { |
---|
157 | int i, j; |
---|
158 | uint16 t; |
---|
159 | |
---|
160 | for(i=nrl; i<=nch; i++) { |
---|
161 | for(j=i+1; j<=nch; j++) { |
---|
162 | t = S[j][i]; |
---|
163 | S[j][i] = S[i][j]; |
---|
164 | S[i][j] = t; |
---|
165 | } |
---|
166 | } |
---|
167 | } |
---|
168 | /* ---------------------------------------------------------------------------------- */ |
---|
169 | IMAGE_EXPORT(void) transpose1_si32matrix(sint32 **S, long nrl,long nrh,long ncl, long nch) |
---|
170 | /* ---------------------------------------------------------------------------------- */ |
---|
171 | { |
---|
172 | int i, j; |
---|
173 | int32 t; |
---|
174 | |
---|
175 | for(i=nrl; i<=nch; i++) { |
---|
176 | for(j=i+1; j<=nch; j++) { |
---|
177 | t = S[j][i]; |
---|
178 | S[j][i] = S[i][j]; |
---|
179 | S[i][j] = t; |
---|
180 | } |
---|
181 | } |
---|
182 | } |
---|
183 | /* ------------------------------------------------------------------------------------ */ |
---|
184 | IMAGE_EXPORT(void) transpose1_ui32matrix(uint32 **S, long nrl,long nrh,long ncl, long nch) |
---|
185 | /* ------------------------------------------------------------------------------------ */ |
---|
186 | { |
---|
187 | int i, j; |
---|
188 | uint32 t; |
---|
189 | |
---|
190 | for(i=nrl; i<=nch; i++) { |
---|
191 | for(j=i+1; j<=nch; j++) { |
---|
192 | t = S[j][i]; |
---|
193 | S[j][i] = S[i][j]; |
---|
194 | S[i][j] = t; |
---|
195 | } |
---|
196 | } |
---|
197 | } |
---|
198 | /* ------------------------------------------------------------------------------- */ |
---|
199 | IMAGE_EXPORT(void) transpose1_f32matrix(float32 **S, long nrl,long nrh,long ncl, long nch) |
---|
200 | /* ------------------------------------------------------------------------------- */ |
---|
201 | { |
---|
202 | int i, j; |
---|
203 | float t; |
---|
204 | |
---|
205 | for(i=nrl; i<=nch; i++) { |
---|
206 | for(j=i+1; j<=nch; j++) { |
---|
207 | t = S[j][i]; |
---|
208 | S[j][i] = S[i][j]; |
---|
209 | S[i][j] = t; |
---|
210 | } |
---|
211 | } |
---|
212 | } |
---|
213 | /* --------------------------------------------------------------------------------- */ |
---|
214 | IMAGE_EXPORT(void) transpose1_f64matrix(float64 **S, long nrl,long nrh,long ncl, long nch) |
---|
215 | /* --------------------------------------------------------------------------------- */ |
---|
216 | { |
---|
217 | int i, j; |
---|
218 | double t; |
---|
219 | |
---|
220 | for(i=nrl; i<=nch; i++) { |
---|
221 | for(j=i+1; j<=nch; j++) { |
---|
222 | t = S[j][i]; |
---|
223 | S[j][i] = S[i][j]; |
---|
224 | S[i][j] = t; |
---|
225 | } |
---|
226 | } |
---|
227 | } |
---|
228 | /* ---------------------------------------------------------------------------------- */ |
---|
229 | IMAGE_EXPORT(void) transpose1_rgb8matrix(rgb8 **S, long nrl,long nrh,long ncl, long nch) |
---|
230 | /* ---------------------------------------------------------------------------------- */ |
---|
231 | { |
---|
232 | int i, j; |
---|
233 | rgb8 t; |
---|
234 | |
---|
235 | for(i=nrl; i<=nch; i++) { |
---|
236 | for(j=i+1; j<=nch; j++) { |
---|
237 | t = S[j][i]; |
---|
238 | S[j][i] = S[i][j]; |
---|
239 | S[i][j] = t; |
---|
240 | } |
---|
241 | } |
---|
242 | } |
---|