comparison armadillo-3.900.4/include/armadillo_bits/op_cx_scalar_meat.hpp @ 49:1ec0e2823891

Switch to using subrepo copies of qm-dsp, nnls-chroma, vamp-plugin-sdk; update Armadillo version; assume build without external BLAS/LAPACK
author Chris Cannam
date Thu, 13 Jun 2013 10:25:24 +0100
parents
children
comparison
equal deleted inserted replaced
48:69251e11a913 49:1ec0e2823891
1 // Copyright (C) 2008-2013 NICTA (www.nicta.com.au)
2 // Copyright (C) 2008-2013 Conrad Sanderson
3 //
4 // This Source Code Form is subject to the terms of the Mozilla Public
5 // License, v. 2.0. If a copy of the MPL was not distributed with this
6 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
8
9 //! \addtogroup op_cx_scalar
10 //! @{
11
12
13
14 template<typename T1>
15 inline
16 void
17 op_cx_scalar_times::apply
18 (
19 Mat< typename std::complex<typename T1::pod_type> >& out,
20 const mtOp<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_times>& X
21 )
22 {
23 arma_extra_debug_sigprint();
24
25 typedef typename std::complex<typename T1::pod_type> eT;
26
27 const Proxy<T1> A(X.m);
28
29 const uword n_rows = A.get_n_rows();
30 const uword n_cols = A.get_n_cols();
31
32 out.set_size(n_rows, n_cols);
33
34 const eT k = X.aux_out_eT;
35 eT* out_mem = out.memptr();
36
37 if(Proxy<T1>::prefer_at_accessor == false)
38 {
39 const uword n_elem = A.get_n_elem();
40
41 for(uword i=0; i<n_elem; ++i)
42 {
43 out_mem[i] = A[i] * k;
44 }
45 }
46 else
47 {
48 for(uword col=0; col < n_cols; ++col)
49 for(uword row=0; row < n_rows; ++row)
50 {
51 *out_mem = A.at(row,col) * k; ++out_mem;
52 }
53 }
54 }
55
56
57
58 template<typename T1>
59 inline
60 void
61 op_cx_scalar_plus::apply
62 (
63 Mat< typename std::complex<typename T1::pod_type> >& out,
64 const mtOp<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_plus>& X
65 )
66 {
67 arma_extra_debug_sigprint();
68
69 typedef typename std::complex<typename T1::pod_type> eT;
70
71 const Proxy<T1> A(X.m);
72
73 const uword n_rows = A.get_n_rows();
74 const uword n_cols = A.get_n_cols();
75
76 out.set_size(n_rows, n_cols);
77
78 const eT k = X.aux_out_eT;
79 eT* out_mem = out.memptr();
80
81 if(Proxy<T1>::prefer_at_accessor == false)
82 {
83 const uword n_elem = A.get_n_elem();
84
85 for(uword i=0; i<n_elem; ++i)
86 {
87 out_mem[i] = A[i] + k;
88 }
89 }
90 else
91 {
92 for(uword col=0; col < n_cols; ++col)
93 for(uword row=0; row < n_rows; ++row)
94 {
95 *out_mem = A.at(row,col) + k; ++out_mem;
96 }
97 }
98 }
99
100
101
102 template<typename T1>
103 inline
104 void
105 op_cx_scalar_minus_pre::apply
106 (
107 Mat< typename std::complex<typename T1::pod_type> >& out,
108 const mtOp<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_minus_pre>& X
109 )
110 {
111 arma_extra_debug_sigprint();
112
113 typedef typename std::complex<typename T1::pod_type> eT;
114
115 const Proxy<T1> A(X.m);
116
117 const uword n_rows = A.get_n_rows();
118 const uword n_cols = A.get_n_cols();
119
120 out.set_size(n_rows, n_cols);
121
122 const eT k = X.aux_out_eT;
123 eT* out_mem = out.memptr();
124
125 if(Proxy<T1>::prefer_at_accessor == false)
126 {
127 const uword n_elem = A.get_n_elem();
128
129 for(uword i=0; i<n_elem; ++i)
130 {
131 out_mem[i] = k - A[i];
132 }
133 }
134 else
135 {
136 for(uword col=0; col < n_cols; ++col)
137 for(uword row=0; row < n_rows; ++row)
138 {
139 *out_mem = k - A.at(row,col); ++out_mem;
140 }
141 }
142 }
143
144
145
146 template<typename T1>
147 inline
148 void
149 op_cx_scalar_minus_post::apply
150 (
151 Mat< typename std::complex<typename T1::pod_type> >& out,
152 const mtOp<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_minus_post>& X
153 )
154 {
155 arma_extra_debug_sigprint();
156
157 typedef typename std::complex<typename T1::pod_type> eT;
158
159 const Proxy<T1> A(X.m);
160
161 const uword n_rows = A.get_n_rows();
162 const uword n_cols = A.get_n_cols();
163
164 out.set_size(n_rows, n_cols);
165
166 const eT k = X.aux_out_eT;
167 eT* out_mem = out.memptr();
168
169 if(Proxy<T1>::prefer_at_accessor == false)
170 {
171 const uword n_elem = A.get_n_elem();
172
173 for(uword i=0; i<n_elem; ++i)
174 {
175 out_mem[i] = A[i] - k;
176 }
177 }
178 else
179 {
180 for(uword col=0; col < n_cols; ++col)
181 for(uword row=0; row < n_rows; ++row)
182 {
183 *out_mem = A.at(row,col) - k; ++out_mem;
184 }
185 }
186 }
187
188
189
190 template<typename T1>
191 inline
192 void
193 op_cx_scalar_div_pre::apply
194 (
195 Mat< typename std::complex<typename T1::pod_type> >& out,
196 const mtOp<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_div_pre>& X
197 )
198 {
199 arma_extra_debug_sigprint();
200
201 typedef typename std::complex<typename T1::pod_type> eT;
202
203 const Proxy<T1> A(X.m);
204
205 const uword n_rows = A.get_n_rows();
206 const uword n_cols = A.get_n_cols();
207
208 out.set_size(n_rows, n_cols);
209
210 const eT k = X.aux_out_eT;
211 eT* out_mem = out.memptr();
212
213 if(Proxy<T1>::prefer_at_accessor == false)
214 {
215 const uword n_elem = A.get_n_elem();
216
217 for(uword i=0; i<n_elem; ++i)
218 {
219 out_mem[i] = k / A[i];
220 }
221 }
222 else
223 {
224 for(uword col=0; col < n_cols; ++col)
225 for(uword row=0; row < n_rows; ++row)
226 {
227 *out_mem = k / A.at(row,col); ++out_mem;
228 }
229 }
230 }
231
232
233
234 template<typename T1>
235 inline
236 void
237 op_cx_scalar_div_post::apply
238 (
239 Mat< typename std::complex<typename T1::pod_type> >& out,
240 const mtOp<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_div_post>& X
241 )
242 {
243 arma_extra_debug_sigprint();
244
245 typedef typename std::complex<typename T1::pod_type> eT;
246
247 const Proxy<T1> A(X.m);
248
249 const uword n_rows = A.get_n_rows();
250 const uword n_cols = A.get_n_cols();
251
252 out.set_size(n_rows, n_cols);
253
254 const eT k = X.aux_out_eT;
255 eT* out_mem = out.memptr();
256
257 if(Proxy<T1>::prefer_at_accessor == false)
258 {
259 const uword n_elem = A.get_n_elem();
260
261 for(uword i=0; i<n_elem; ++i)
262 {
263 out_mem[i] = A[i] / k;
264 }
265 }
266 else
267 {
268 for(uword col=0; col < n_cols; ++col)
269 for(uword row=0; row < n_rows; ++row)
270 {
271 *out_mem = A.at(row,col) / k; ++out_mem;
272 }
273 }
274 }
275
276
277
278 //
279 //
280 //
281
282
283
284 template<typename T1>
285 inline
286 void
287 op_cx_scalar_times::apply
288 (
289 Cube< typename std::complex<typename T1::pod_type> >& out,
290 const mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_times>& X
291 )
292 {
293 arma_extra_debug_sigprint();
294
295 typedef typename std::complex<typename T1::pod_type> eT;
296
297 const ProxyCube<T1> A(X.m);
298
299 out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
300
301 const eT k = X.aux_out_eT;
302 const uword n_elem = out.n_elem;
303 eT* out_mem = out.memptr();
304
305 // TODO: implement handling for ProxyCube<T1>::prefer_at_accessor == true
306 for(uword i=0; i<n_elem; ++i)
307 {
308 out_mem[i] = A[i] * k;
309 }
310 }
311
312
313
314 template<typename T1>
315 inline
316 void
317 op_cx_scalar_plus::apply
318 (
319 Cube< typename std::complex<typename T1::pod_type> >& out,
320 const mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_plus>& X
321 )
322 {
323 arma_extra_debug_sigprint();
324
325 typedef typename std::complex<typename T1::pod_type> eT;
326
327 const ProxyCube<T1> A(X.m);
328
329 out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
330
331 const eT k = X.aux_out_eT;
332 const uword n_elem = out.n_elem;
333 eT* out_mem = out.memptr();
334
335 for(uword i=0; i<n_elem; ++i)
336 {
337 out_mem[i] = A[i] + k;
338 }
339 }
340
341
342
343 template<typename T1>
344 inline
345 void
346 op_cx_scalar_minus_pre::apply
347 (
348 Cube< typename std::complex<typename T1::pod_type> >& out,
349 const mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_minus_pre>& X
350 )
351 {
352 arma_extra_debug_sigprint();
353
354 typedef typename std::complex<typename T1::pod_type> eT;
355
356 const ProxyCube<T1> A(X.m);
357
358 out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
359
360 const eT k = X.aux_out_eT;
361 const uword n_elem = out.n_elem;
362 eT* out_mem = out.memptr();
363
364 for(uword i=0; i<n_elem; ++i)
365 {
366 out_mem[i] = k - A[i];
367 }
368 }
369
370
371
372 template<typename T1>
373 inline
374 void
375 op_cx_scalar_minus_post::apply
376 (
377 Cube< typename std::complex<typename T1::pod_type> >& out,
378 const mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_minus_post>& X
379 )
380 {
381 arma_extra_debug_sigprint();
382
383 typedef typename std::complex<typename T1::pod_type> eT;
384
385 const ProxyCube<T1> A(X.m);
386
387 out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
388
389 const eT k = X.aux_out_eT;
390 const uword n_elem = out.n_elem;
391 eT* out_mem = out.memptr();
392
393 for(uword i=0; i<n_elem; ++i)
394 {
395 out_mem[i] = A[i] - k;
396 }
397 }
398
399
400
401 template<typename T1>
402 inline
403 void
404 op_cx_scalar_div_pre::apply
405 (
406 Cube< typename std::complex<typename T1::pod_type> >& out,
407 const mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_div_pre>& X
408 )
409 {
410 arma_extra_debug_sigprint();
411
412 typedef typename std::complex<typename T1::pod_type> eT;
413
414 const ProxyCube<T1> A(X.m);
415
416 out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
417
418 const eT k = X.aux_out_eT;
419 const uword n_elem = out.n_elem;
420 eT* out_mem = out.memptr();
421
422 for(uword i=0; i<n_elem; ++i)
423 {
424 out_mem[i] = k / A[i];
425 }
426 }
427
428
429
430 template<typename T1>
431 inline
432 void
433 op_cx_scalar_div_post::apply
434 (
435 Cube< typename std::complex<typename T1::pod_type> >& out,
436 const mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_div_post>& X
437 )
438 {
439 arma_extra_debug_sigprint();
440
441 typedef typename std::complex<typename T1::pod_type> eT;
442
443 const ProxyCube<T1> A(X.m);
444
445 out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
446
447 const eT k = X.aux_out_eT;
448 const uword n_elem = out.n_elem;
449 eT* out_mem = out.memptr();
450
451 for(uword i=0; i<n_elem; ++i)
452 {
453 out_mem[i] = A[i] / k;
454 }
455 }
456
457
458
459 //! @}