1 | // Copyright (C) 2010-2015 Conrad Sanderson |
---|
2 | // Copyright (C) 2010-2015 NICTA (www.nicta.com.au) |
---|
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 eop_core |
---|
10 | //! @{ |
---|
11 | |
---|
12 | |
---|
13 | #undef arma_applier_1u |
---|
14 | #undef arma_applier_1a |
---|
15 | #undef arma_applier_2 |
---|
16 | #undef arma_applier_3 |
---|
17 | #undef operatorA |
---|
18 | |
---|
19 | |
---|
20 | #if defined(ARMA_SIMPLE_LOOPS) |
---|
21 | #define arma_applier_1u(operatorA) \ |
---|
22 | {\ |
---|
23 | for(uword i=0; i<n_elem; ++i)\ |
---|
24 | {\ |
---|
25 | out_mem[i] operatorA eop_core<eop_type>::process(P[i], k);\ |
---|
26 | }\ |
---|
27 | } |
---|
28 | #else |
---|
29 | #define arma_applier_1u(operatorA) \ |
---|
30 | {\ |
---|
31 | uword i,j;\ |
---|
32 | \ |
---|
33 | for(i=0, j=1; j<n_elem; i+=2, j+=2)\ |
---|
34 | {\ |
---|
35 | eT tmp_i = P[i];\ |
---|
36 | eT tmp_j = P[j];\ |
---|
37 | \ |
---|
38 | tmp_i = eop_core<eop_type>::process(tmp_i, k);\ |
---|
39 | tmp_j = eop_core<eop_type>::process(tmp_j, k);\ |
---|
40 | \ |
---|
41 | out_mem[i] operatorA tmp_i;\ |
---|
42 | out_mem[j] operatorA tmp_j;\ |
---|
43 | }\ |
---|
44 | \ |
---|
45 | if(i < n_elem)\ |
---|
46 | {\ |
---|
47 | out_mem[i] operatorA eop_core<eop_type>::process(P[i], k);\ |
---|
48 | }\ |
---|
49 | } |
---|
50 | #endif |
---|
51 | |
---|
52 | |
---|
53 | #if defined(ARMA_SIMPLE_LOOPS) |
---|
54 | #define arma_applier_1a(operatorA) \ |
---|
55 | {\ |
---|
56 | for(uword i=0; i<n_elem; ++i)\ |
---|
57 | {\ |
---|
58 | out_mem[i] operatorA eop_core<eop_type>::process(P.at_alt(i), k);\ |
---|
59 | }\ |
---|
60 | } |
---|
61 | #else |
---|
62 | #define arma_applier_1a(operatorA) \ |
---|
63 | {\ |
---|
64 | uword i,j;\ |
---|
65 | \ |
---|
66 | for(i=0, j=1; j<n_elem; i+=2, j+=2)\ |
---|
67 | {\ |
---|
68 | eT tmp_i = P.at_alt(i);\ |
---|
69 | eT tmp_j = P.at_alt(j);\ |
---|
70 | \ |
---|
71 | tmp_i = eop_core<eop_type>::process(tmp_i, k);\ |
---|
72 | tmp_j = eop_core<eop_type>::process(tmp_j, k);\ |
---|
73 | \ |
---|
74 | out_mem[i] operatorA tmp_i;\ |
---|
75 | out_mem[j] operatorA tmp_j;\ |
---|
76 | }\ |
---|
77 | \ |
---|
78 | if(i < n_elem)\ |
---|
79 | {\ |
---|
80 | out_mem[i] operatorA eop_core<eop_type>::process(P.at_alt(i), k);\ |
---|
81 | }\ |
---|
82 | } |
---|
83 | #endif |
---|
84 | |
---|
85 | |
---|
86 | #define arma_applier_2(operatorA) \ |
---|
87 | {\ |
---|
88 | if(n_rows != 1)\ |
---|
89 | {\ |
---|
90 | for(uword col=0; col<n_cols; ++col)\ |
---|
91 | {\ |
---|
92 | uword i,j;\ |
---|
93 | \ |
---|
94 | for(i=0, j=1; j<n_rows; i+=2, j+=2)\ |
---|
95 | {\ |
---|
96 | eT tmp_i = P.at(i,col);\ |
---|
97 | eT tmp_j = P.at(j,col);\ |
---|
98 | \ |
---|
99 | tmp_i = eop_core<eop_type>::process(tmp_i, k);\ |
---|
100 | tmp_j = eop_core<eop_type>::process(tmp_j, k);\ |
---|
101 | \ |
---|
102 | *out_mem operatorA tmp_i; out_mem++;\ |
---|
103 | *out_mem operatorA tmp_j; out_mem++;\ |
---|
104 | }\ |
---|
105 | \ |
---|
106 | if(i < n_rows)\ |
---|
107 | {\ |
---|
108 | *out_mem operatorA eop_core<eop_type>::process(P.at(i,col), k); out_mem++;\ |
---|
109 | }\ |
---|
110 | }\ |
---|
111 | }\ |
---|
112 | else\ |
---|
113 | {\ |
---|
114 | for(uword count=0; count < n_cols; ++count)\ |
---|
115 | {\ |
---|
116 | out_mem[count] operatorA eop_core<eop_type>::process(P.at(0,count), k);\ |
---|
117 | }\ |
---|
118 | }\ |
---|
119 | } |
---|
120 | |
---|
121 | |
---|
122 | |
---|
123 | #define arma_applier_3(operatorA) \ |
---|
124 | {\ |
---|
125 | for(uword slice=0; slice<n_slices; ++slice)\ |
---|
126 | {\ |
---|
127 | for(uword col=0; col<n_cols; ++col)\ |
---|
128 | {\ |
---|
129 | uword i,j;\ |
---|
130 | \ |
---|
131 | for(i=0, j=1; j<n_rows; i+=2, j+=2)\ |
---|
132 | {\ |
---|
133 | eT tmp_i = P.at(i,col,slice);\ |
---|
134 | eT tmp_j = P.at(j,col,slice);\ |
---|
135 | \ |
---|
136 | tmp_i = eop_core<eop_type>::process(tmp_i, k);\ |
---|
137 | tmp_j = eop_core<eop_type>::process(tmp_j, k);\ |
---|
138 | \ |
---|
139 | *out_mem operatorA tmp_i; out_mem++; \ |
---|
140 | *out_mem operatorA tmp_j; out_mem++; \ |
---|
141 | }\ |
---|
142 | \ |
---|
143 | if(i < n_rows)\ |
---|
144 | {\ |
---|
145 | *out_mem operatorA eop_core<eop_type>::process(P.at(i,col,slice), k); out_mem++; \ |
---|
146 | }\ |
---|
147 | }\ |
---|
148 | }\ |
---|
149 | } |
---|
150 | |
---|
151 | |
---|
152 | |
---|
153 | // |
---|
154 | // matrices |
---|
155 | |
---|
156 | |
---|
157 | |
---|
158 | template<typename eop_type> |
---|
159 | template<typename outT, typename T1> |
---|
160 | arma_hot |
---|
161 | inline |
---|
162 | void |
---|
163 | eop_core<eop_type>::apply(outT& out, const eOp<T1, eop_type>& x) |
---|
164 | { |
---|
165 | arma_extra_debug_sigprint(); |
---|
166 | |
---|
167 | typedef typename T1::elem_type eT; |
---|
168 | |
---|
169 | // NOTE: we're assuming that the matrix has already been set to the correct size and there is no aliasing; |
---|
170 | // size setting and alias checking is done by either the Mat contructor or operator=() |
---|
171 | |
---|
172 | const eT k = x.aux; |
---|
173 | eT* out_mem = out.memptr(); |
---|
174 | |
---|
175 | if(Proxy<T1>::prefer_at_accessor == false) |
---|
176 | { |
---|
177 | const uword n_elem = x.get_n_elem(); |
---|
178 | |
---|
179 | if(memory::is_aligned(out_mem)) |
---|
180 | { |
---|
181 | memory::mark_as_aligned(out_mem); |
---|
182 | |
---|
183 | if(x.P.is_aligned()) |
---|
184 | { |
---|
185 | typename Proxy<T1>::aligned_ea_type P = x.P.get_aligned_ea(); |
---|
186 | |
---|
187 | arma_applier_1a(=); |
---|
188 | } |
---|
189 | else |
---|
190 | { |
---|
191 | typename Proxy<T1>::ea_type P = x.P.get_ea(); |
---|
192 | |
---|
193 | arma_applier_1u(=); |
---|
194 | } |
---|
195 | } |
---|
196 | else |
---|
197 | { |
---|
198 | typename Proxy<T1>::ea_type P = x.P.get_ea(); |
---|
199 | |
---|
200 | arma_applier_1u(=); |
---|
201 | } |
---|
202 | } |
---|
203 | else |
---|
204 | { |
---|
205 | const uword n_rows = x.get_n_rows(); |
---|
206 | const uword n_cols = x.get_n_cols(); |
---|
207 | |
---|
208 | const Proxy<T1>& P = x.P; |
---|
209 | |
---|
210 | arma_applier_2(=); |
---|
211 | } |
---|
212 | } |
---|
213 | |
---|
214 | |
---|
215 | |
---|
216 | template<typename eop_type> |
---|
217 | template<typename T1> |
---|
218 | arma_hot |
---|
219 | inline |
---|
220 | void |
---|
221 | eop_core<eop_type>::apply_inplace_plus(Mat<typename T1::elem_type>& out, const eOp<T1, eop_type>& x) |
---|
222 | { |
---|
223 | arma_extra_debug_sigprint(); |
---|
224 | |
---|
225 | typedef typename T1::elem_type eT; |
---|
226 | |
---|
227 | const uword n_rows = x.get_n_rows(); |
---|
228 | const uword n_cols = x.get_n_cols(); |
---|
229 | |
---|
230 | arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "addition"); |
---|
231 | |
---|
232 | const eT k = x.aux; |
---|
233 | eT* out_mem = out.memptr(); |
---|
234 | |
---|
235 | if(Proxy<T1>::prefer_at_accessor == false) |
---|
236 | { |
---|
237 | const uword n_elem = x.get_n_elem(); |
---|
238 | |
---|
239 | if(memory::is_aligned(out_mem)) |
---|
240 | { |
---|
241 | memory::mark_as_aligned(out_mem); |
---|
242 | |
---|
243 | if(x.P.is_aligned()) |
---|
244 | { |
---|
245 | typename Proxy<T1>::aligned_ea_type P = x.P.get_aligned_ea(); |
---|
246 | |
---|
247 | arma_applier_1a(+=); |
---|
248 | } |
---|
249 | else |
---|
250 | { |
---|
251 | typename Proxy<T1>::ea_type P = x.P.get_ea(); |
---|
252 | |
---|
253 | arma_applier_1u(+=); |
---|
254 | } |
---|
255 | } |
---|
256 | else |
---|
257 | { |
---|
258 | typename Proxy<T1>::ea_type P = x.P.get_ea(); |
---|
259 | |
---|
260 | arma_applier_1u(+=); |
---|
261 | } |
---|
262 | } |
---|
263 | else |
---|
264 | { |
---|
265 | const Proxy<T1>& P = x.P; |
---|
266 | |
---|
267 | arma_applier_2(+=); |
---|
268 | } |
---|
269 | } |
---|
270 | |
---|
271 | |
---|
272 | |
---|
273 | template<typename eop_type> |
---|
274 | template<typename T1> |
---|
275 | arma_hot |
---|
276 | inline |
---|
277 | void |
---|
278 | eop_core<eop_type>::apply_inplace_minus(Mat<typename T1::elem_type>& out, const eOp<T1, eop_type>& x) |
---|
279 | { |
---|
280 | arma_extra_debug_sigprint(); |
---|
281 | |
---|
282 | typedef typename T1::elem_type eT; |
---|
283 | |
---|
284 | const uword n_rows = x.get_n_rows(); |
---|
285 | const uword n_cols = x.get_n_cols(); |
---|
286 | |
---|
287 | arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "subtraction"); |
---|
288 | |
---|
289 | const eT k = x.aux; |
---|
290 | eT* out_mem = out.memptr(); |
---|
291 | |
---|
292 | if(Proxy<T1>::prefer_at_accessor == false) |
---|
293 | { |
---|
294 | const uword n_elem = x.get_n_elem(); |
---|
295 | |
---|
296 | if(memory::is_aligned(out_mem)) |
---|
297 | { |
---|
298 | memory::mark_as_aligned(out_mem); |
---|
299 | |
---|
300 | if(x.P.is_aligned()) |
---|
301 | { |
---|
302 | typename Proxy<T1>::aligned_ea_type P = x.P.get_aligned_ea(); |
---|
303 | |
---|
304 | arma_applier_1a(-=); |
---|
305 | } |
---|
306 | else |
---|
307 | { |
---|
308 | typename Proxy<T1>::ea_type P = x.P.get_ea(); |
---|
309 | |
---|
310 | arma_applier_1u(-=); |
---|
311 | } |
---|
312 | } |
---|
313 | else |
---|
314 | { |
---|
315 | typename Proxy<T1>::ea_type P = x.P.get_ea(); |
---|
316 | |
---|
317 | arma_applier_1u(-=); |
---|
318 | } |
---|
319 | } |
---|
320 | else |
---|
321 | { |
---|
322 | const Proxy<T1>& P = x.P; |
---|
323 | |
---|
324 | arma_applier_2(-=); |
---|
325 | } |
---|
326 | } |
---|
327 | |
---|
328 | |
---|
329 | |
---|
330 | template<typename eop_type> |
---|
331 | template<typename T1> |
---|
332 | arma_hot |
---|
333 | inline |
---|
334 | void |
---|
335 | eop_core<eop_type>::apply_inplace_schur(Mat<typename T1::elem_type>& out, const eOp<T1, eop_type>& x) |
---|
336 | { |
---|
337 | arma_extra_debug_sigprint(); |
---|
338 | |
---|
339 | typedef typename T1::elem_type eT; |
---|
340 | |
---|
341 | const uword n_rows = x.get_n_rows(); |
---|
342 | const uword n_cols = x.get_n_cols(); |
---|
343 | |
---|
344 | arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "element-wise multiplication"); |
---|
345 | |
---|
346 | const eT k = x.aux; |
---|
347 | eT* out_mem = out.memptr(); |
---|
348 | |
---|
349 | if(Proxy<T1>::prefer_at_accessor == false) |
---|
350 | { |
---|
351 | const uword n_elem = x.get_n_elem(); |
---|
352 | |
---|
353 | if(memory::is_aligned(out_mem)) |
---|
354 | { |
---|
355 | memory::mark_as_aligned(out_mem); |
---|
356 | |
---|
357 | if(x.P.is_aligned()) |
---|
358 | { |
---|
359 | typename Proxy<T1>::aligned_ea_type P = x.P.get_aligned_ea(); |
---|
360 | |
---|
361 | arma_applier_1a(*=); |
---|
362 | } |
---|
363 | else |
---|
364 | { |
---|
365 | typename Proxy<T1>::ea_type P = x.P.get_ea(); |
---|
366 | |
---|
367 | arma_applier_1u(*=); |
---|
368 | } |
---|
369 | } |
---|
370 | else |
---|
371 | { |
---|
372 | typename Proxy<T1>::ea_type P = x.P.get_ea(); |
---|
373 | |
---|
374 | arma_applier_1u(*=); |
---|
375 | } |
---|
376 | } |
---|
377 | else |
---|
378 | { |
---|
379 | const Proxy<T1>& P = x.P; |
---|
380 | |
---|
381 | arma_applier_2(*=); |
---|
382 | } |
---|
383 | } |
---|
384 | |
---|
385 | |
---|
386 | |
---|
387 | template<typename eop_type> |
---|
388 | template<typename T1> |
---|
389 | arma_hot |
---|
390 | inline |
---|
391 | void |
---|
392 | eop_core<eop_type>::apply_inplace_div(Mat<typename T1::elem_type>& out, const eOp<T1, eop_type>& x) |
---|
393 | { |
---|
394 | arma_extra_debug_sigprint(); |
---|
395 | |
---|
396 | typedef typename T1::elem_type eT; |
---|
397 | |
---|
398 | const uword n_rows = x.get_n_rows(); |
---|
399 | const uword n_cols = x.get_n_cols(); |
---|
400 | |
---|
401 | arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "element-wise division"); |
---|
402 | |
---|
403 | const eT k = x.aux; |
---|
404 | eT* out_mem = out.memptr(); |
---|
405 | |
---|
406 | if(Proxy<T1>::prefer_at_accessor == false) |
---|
407 | { |
---|
408 | const uword n_elem = x.get_n_elem(); |
---|
409 | |
---|
410 | if(memory::is_aligned(out_mem)) |
---|
411 | { |
---|
412 | memory::mark_as_aligned(out_mem); |
---|
413 | |
---|
414 | if(x.P.is_aligned()) |
---|
415 | { |
---|
416 | typename Proxy<T1>::aligned_ea_type P = x.P.get_aligned_ea(); |
---|
417 | |
---|
418 | arma_applier_1a(/=); |
---|
419 | } |
---|
420 | else |
---|
421 | { |
---|
422 | typename Proxy<T1>::ea_type P = x.P.get_ea(); |
---|
423 | |
---|
424 | arma_applier_1u(/=); |
---|
425 | } |
---|
426 | } |
---|
427 | else |
---|
428 | { |
---|
429 | typename Proxy<T1>::ea_type P = x.P.get_ea(); |
---|
430 | |
---|
431 | arma_applier_1u(/=); |
---|
432 | } |
---|
433 | } |
---|
434 | else |
---|
435 | { |
---|
436 | const Proxy<T1>& P = x.P; |
---|
437 | |
---|
438 | arma_applier_2(/=); |
---|
439 | } |
---|
440 | } |
---|
441 | |
---|
442 | |
---|
443 | |
---|
444 | // |
---|
445 | // cubes |
---|
446 | |
---|
447 | |
---|
448 | |
---|
449 | template<typename eop_type> |
---|
450 | template<typename T1> |
---|
451 | arma_hot |
---|
452 | inline |
---|
453 | void |
---|
454 | eop_core<eop_type>::apply(Cube<typename T1::elem_type>& out, const eOpCube<T1, eop_type>& x) |
---|
455 | { |
---|
456 | arma_extra_debug_sigprint(); |
---|
457 | |
---|
458 | typedef typename T1::elem_type eT; |
---|
459 | |
---|
460 | // NOTE: we're assuming that the matrix has already been set to the correct size and there is no aliasing; |
---|
461 | // size setting and alias checking is done by either the Mat contructor or operator=() |
---|
462 | |
---|
463 | const eT k = x.aux; |
---|
464 | eT* out_mem = out.memptr(); |
---|
465 | |
---|
466 | if(ProxyCube<T1>::prefer_at_accessor == false) |
---|
467 | { |
---|
468 | const uword n_elem = out.n_elem; |
---|
469 | |
---|
470 | if(memory::is_aligned(out_mem)) |
---|
471 | { |
---|
472 | memory::mark_as_aligned(out_mem); |
---|
473 | |
---|
474 | if(x.P.is_aligned()) |
---|
475 | { |
---|
476 | typename ProxyCube<T1>::aligned_ea_type P = x.P.get_aligned_ea(); |
---|
477 | |
---|
478 | arma_applier_1a(=); |
---|
479 | } |
---|
480 | else |
---|
481 | { |
---|
482 | typename ProxyCube<T1>::ea_type P = x.P.get_ea(); |
---|
483 | |
---|
484 | arma_applier_1u(=); |
---|
485 | } |
---|
486 | } |
---|
487 | else |
---|
488 | { |
---|
489 | typename ProxyCube<T1>::ea_type P = x.P.get_ea(); |
---|
490 | |
---|
491 | arma_applier_1u(=); |
---|
492 | } |
---|
493 | } |
---|
494 | else |
---|
495 | { |
---|
496 | const uword n_rows = x.get_n_rows(); |
---|
497 | const uword n_cols = x.get_n_cols(); |
---|
498 | const uword n_slices = x.get_n_slices(); |
---|
499 | |
---|
500 | const ProxyCube<T1>& P = x.P; |
---|
501 | |
---|
502 | arma_applier_3(=); |
---|
503 | } |
---|
504 | } |
---|
505 | |
---|
506 | |
---|
507 | |
---|
508 | template<typename eop_type> |
---|
509 | template<typename T1> |
---|
510 | arma_hot |
---|
511 | inline |
---|
512 | void |
---|
513 | eop_core<eop_type>::apply_inplace_plus(Cube<typename T1::elem_type>& out, const eOpCube<T1, eop_type>& x) |
---|
514 | { |
---|
515 | arma_extra_debug_sigprint(); |
---|
516 | |
---|
517 | typedef typename T1::elem_type eT; |
---|
518 | |
---|
519 | const uword n_rows = x.get_n_rows(); |
---|
520 | const uword n_cols = x.get_n_cols(); |
---|
521 | const uword n_slices = x.get_n_slices(); |
---|
522 | |
---|
523 | arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "addition"); |
---|
524 | |
---|
525 | const eT k = x.aux; |
---|
526 | eT* out_mem = out.memptr(); |
---|
527 | |
---|
528 | if(ProxyCube<T1>::prefer_at_accessor == false) |
---|
529 | { |
---|
530 | const uword n_elem = out.n_elem; |
---|
531 | |
---|
532 | if(memory::is_aligned(out_mem)) |
---|
533 | { |
---|
534 | memory::mark_as_aligned(out_mem); |
---|
535 | |
---|
536 | if(x.P.is_aligned()) |
---|
537 | { |
---|
538 | typename ProxyCube<T1>::aligned_ea_type P = x.P.get_aligned_ea(); |
---|
539 | |
---|
540 | arma_applier_1a(+=); |
---|
541 | } |
---|
542 | else |
---|
543 | { |
---|
544 | typename ProxyCube<T1>::ea_type P = x.P.get_ea(); |
---|
545 | |
---|
546 | arma_applier_1u(+=); |
---|
547 | } |
---|
548 | } |
---|
549 | else |
---|
550 | { |
---|
551 | typename ProxyCube<T1>::ea_type P = x.P.get_ea(); |
---|
552 | |
---|
553 | arma_applier_1u(+=); |
---|
554 | } |
---|
555 | } |
---|
556 | else |
---|
557 | { |
---|
558 | const ProxyCube<T1>& P = x.P; |
---|
559 | |
---|
560 | arma_applier_3(+=); |
---|
561 | } |
---|
562 | } |
---|
563 | |
---|
564 | |
---|
565 | |
---|
566 | template<typename eop_type> |
---|
567 | template<typename T1> |
---|
568 | arma_hot |
---|
569 | inline |
---|
570 | void |
---|
571 | eop_core<eop_type>::apply_inplace_minus(Cube<typename T1::elem_type>& out, const eOpCube<T1, eop_type>& x) |
---|
572 | { |
---|
573 | arma_extra_debug_sigprint(); |
---|
574 | |
---|
575 | typedef typename T1::elem_type eT; |
---|
576 | |
---|
577 | const uword n_rows = x.get_n_rows(); |
---|
578 | const uword n_cols = x.get_n_cols(); |
---|
579 | const uword n_slices = x.get_n_slices(); |
---|
580 | |
---|
581 | arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "subtraction"); |
---|
582 | |
---|
583 | const eT k = x.aux; |
---|
584 | eT* out_mem = out.memptr(); |
---|
585 | |
---|
586 | if(ProxyCube<T1>::prefer_at_accessor == false) |
---|
587 | { |
---|
588 | const uword n_elem = out.n_elem; |
---|
589 | |
---|
590 | if(memory::is_aligned(out_mem)) |
---|
591 | { |
---|
592 | memory::mark_as_aligned(out_mem); |
---|
593 | |
---|
594 | if(x.P.is_aligned()) |
---|
595 | { |
---|
596 | typename ProxyCube<T1>::aligned_ea_type P = x.P.get_aligned_ea(); |
---|
597 | |
---|
598 | arma_applier_1a(-=); |
---|
599 | } |
---|
600 | else |
---|
601 | { |
---|
602 | typename ProxyCube<T1>::ea_type P = x.P.get_ea(); |
---|
603 | |
---|
604 | arma_applier_1u(-=); |
---|
605 | } |
---|
606 | } |
---|
607 | else |
---|
608 | { |
---|
609 | typename ProxyCube<T1>::ea_type P = x.P.get_ea(); |
---|
610 | |
---|
611 | arma_applier_1u(-=); |
---|
612 | } |
---|
613 | } |
---|
614 | else |
---|
615 | { |
---|
616 | const ProxyCube<T1>& P = x.P; |
---|
617 | |
---|
618 | arma_applier_3(-=); |
---|
619 | } |
---|
620 | } |
---|
621 | |
---|
622 | |
---|
623 | |
---|
624 | template<typename eop_type> |
---|
625 | template<typename T1> |
---|
626 | arma_hot |
---|
627 | inline |
---|
628 | void |
---|
629 | eop_core<eop_type>::apply_inplace_schur(Cube<typename T1::elem_type>& out, const eOpCube<T1, eop_type>& x) |
---|
630 | { |
---|
631 | arma_extra_debug_sigprint(); |
---|
632 | |
---|
633 | typedef typename T1::elem_type eT; |
---|
634 | |
---|
635 | const uword n_rows = x.get_n_rows(); |
---|
636 | const uword n_cols = x.get_n_cols(); |
---|
637 | const uword n_slices = x.get_n_slices(); |
---|
638 | |
---|
639 | arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "element-wise multiplication"); |
---|
640 | |
---|
641 | const eT k = x.aux; |
---|
642 | eT* out_mem = out.memptr(); |
---|
643 | |
---|
644 | if(ProxyCube<T1>::prefer_at_accessor == false) |
---|
645 | { |
---|
646 | const uword n_elem = out.n_elem; |
---|
647 | |
---|
648 | if(memory::is_aligned(out_mem)) |
---|
649 | { |
---|
650 | memory::mark_as_aligned(out_mem); |
---|
651 | |
---|
652 | if(x.P.is_aligned()) |
---|
653 | { |
---|
654 | typename ProxyCube<T1>::aligned_ea_type P = x.P.get_aligned_ea(); |
---|
655 | |
---|
656 | arma_applier_1a(*=); |
---|
657 | } |
---|
658 | else |
---|
659 | { |
---|
660 | typename ProxyCube<T1>::ea_type P = x.P.get_ea(); |
---|
661 | |
---|
662 | arma_applier_1u(*=); |
---|
663 | } |
---|
664 | } |
---|
665 | else |
---|
666 | { |
---|
667 | typename ProxyCube<T1>::ea_type P = x.P.get_ea(); |
---|
668 | |
---|
669 | arma_applier_1u(*=); |
---|
670 | } |
---|
671 | } |
---|
672 | else |
---|
673 | { |
---|
674 | const ProxyCube<T1>& P = x.P; |
---|
675 | |
---|
676 | arma_applier_3(*=); |
---|
677 | } |
---|
678 | } |
---|
679 | |
---|
680 | |
---|
681 | |
---|
682 | template<typename eop_type> |
---|
683 | template<typename T1> |
---|
684 | arma_hot |
---|
685 | inline |
---|
686 | void |
---|
687 | eop_core<eop_type>::apply_inplace_div(Cube<typename T1::elem_type>& out, const eOpCube<T1, eop_type>& x) |
---|
688 | { |
---|
689 | arma_extra_debug_sigprint(); |
---|
690 | |
---|
691 | typedef typename T1::elem_type eT; |
---|
692 | |
---|
693 | const uword n_rows = x.get_n_rows(); |
---|
694 | const uword n_cols = x.get_n_cols(); |
---|
695 | const uword n_slices = x.get_n_slices(); |
---|
696 | |
---|
697 | arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "element-wise division"); |
---|
698 | |
---|
699 | const eT k = x.aux; |
---|
700 | eT* out_mem = out.memptr(); |
---|
701 | |
---|
702 | if(ProxyCube<T1>::prefer_at_accessor == false) |
---|
703 | { |
---|
704 | const uword n_elem = out.n_elem; |
---|
705 | |
---|
706 | if(memory::is_aligned(out_mem)) |
---|
707 | { |
---|
708 | memory::mark_as_aligned(out_mem); |
---|
709 | |
---|
710 | if(x.P.is_aligned()) |
---|
711 | { |
---|
712 | typename ProxyCube<T1>::aligned_ea_type P = x.P.get_aligned_ea(); |
---|
713 | |
---|
714 | arma_applier_1a(/=); |
---|
715 | } |
---|
716 | else |
---|
717 | { |
---|
718 | typename ProxyCube<T1>::ea_type P = x.P.get_ea(); |
---|
719 | |
---|
720 | arma_applier_1u(/=); |
---|
721 | } |
---|
722 | } |
---|
723 | else |
---|
724 | { |
---|
725 | typename ProxyCube<T1>::ea_type P = x.P.get_ea(); |
---|
726 | |
---|
727 | arma_applier_1u(/=); |
---|
728 | } |
---|
729 | } |
---|
730 | else |
---|
731 | { |
---|
732 | const ProxyCube<T1>& P = x.P; |
---|
733 | |
---|
734 | arma_applier_3(/=); |
---|
735 | } |
---|
736 | } |
---|
737 | |
---|
738 | |
---|
739 | |
---|
740 | // |
---|
741 | // common |
---|
742 | |
---|
743 | |
---|
744 | |
---|
745 | template<typename eop_type> |
---|
746 | template<typename eT> |
---|
747 | arma_hot |
---|
748 | arma_pure |
---|
749 | arma_inline |
---|
750 | eT |
---|
751 | eop_core<eop_type>::process(const eT, const eT) |
---|
752 | { |
---|
753 | arma_stop("eop_core::process(): unhandled eop_type"); |
---|
754 | return eT(0); |
---|
755 | } |
---|
756 | |
---|
757 | |
---|
758 | |
---|
759 | template<> template<typename eT> arma_hot arma_const arma_inline eT |
---|
760 | eop_core<eop_scalar_plus >::process(const eT val, const eT k) { return val + k; } |
---|
761 | |
---|
762 | template<> template<typename eT> arma_hot arma_const arma_inline eT |
---|
763 | eop_core<eop_scalar_minus_pre >::process(const eT val, const eT k) { return k - val; } |
---|
764 | |
---|
765 | template<> template<typename eT> arma_hot arma_const arma_inline eT |
---|
766 | eop_core<eop_scalar_minus_post>::process(const eT val, const eT k) { return val - k; } |
---|
767 | |
---|
768 | template<> template<typename eT> arma_hot arma_const arma_inline eT |
---|
769 | eop_core<eop_scalar_times >::process(const eT val, const eT k) { return val * k; } |
---|
770 | |
---|
771 | template<> template<typename eT> arma_hot arma_const arma_inline eT |
---|
772 | eop_core<eop_scalar_div_pre >::process(const eT val, const eT k) { return k / val; } |
---|
773 | |
---|
774 | template<> template<typename eT> arma_hot arma_const arma_inline eT |
---|
775 | eop_core<eop_scalar_div_post >::process(const eT val, const eT k) { return val / k; } |
---|
776 | |
---|
777 | template<> template<typename eT> arma_hot arma_const arma_inline eT |
---|
778 | eop_core<eop_square >::process(const eT val, const eT ) { return val*val; } |
---|
779 | |
---|
780 | template<> template<typename eT> arma_hot arma_const arma_inline eT |
---|
781 | eop_core<eop_neg >::process(const eT val, const eT ) { return eop_aux::neg(val); } |
---|
782 | |
---|
783 | template<> template<typename eT> arma_hot arma_pure arma_inline eT |
---|
784 | eop_core<eop_sqrt >::process(const eT val, const eT ) { return eop_aux::sqrt(val); } |
---|
785 | |
---|
786 | template<> template<typename eT> arma_hot arma_pure arma_inline eT |
---|
787 | eop_core<eop_log >::process(const eT val, const eT ) { return eop_aux::log(val); } |
---|
788 | |
---|
789 | template<> template<typename eT> arma_hot arma_pure arma_inline eT |
---|
790 | eop_core<eop_log2 >::process(const eT val, const eT ) { return eop_aux::log2(val); } |
---|
791 | |
---|
792 | template<> template<typename eT> arma_hot arma_pure arma_inline eT |
---|
793 | eop_core<eop_log10 >::process(const eT val, const eT ) { return eop_aux::log10(val); } |
---|
794 | |
---|
795 | template<> template<typename eT> arma_hot arma_pure arma_inline eT |
---|
796 | eop_core<eop_trunc_log >::process(const eT val, const eT ) { return arma::trunc_log(val); } |
---|
797 | |
---|
798 | template<> template<typename eT> arma_hot arma_pure arma_inline eT |
---|
799 | eop_core<eop_exp >::process(const eT val, const eT ) { return eop_aux::exp(val); } |
---|
800 | |
---|
801 | template<> template<typename eT> arma_hot arma_pure arma_inline eT |
---|
802 | eop_core<eop_exp2 >::process(const eT val, const eT ) { return eop_aux::exp2(val); } |
---|
803 | |
---|
804 | template<> template<typename eT> arma_hot arma_pure arma_inline eT |
---|
805 | eop_core<eop_exp10 >::process(const eT val, const eT ) { return eop_aux::exp10(val); } |
---|
806 | |
---|
807 | template<> template<typename eT> arma_hot arma_pure arma_inline eT |
---|
808 | eop_core<eop_trunc_exp >::process(const eT val, const eT ) { return arma::trunc_exp(val); } |
---|
809 | |
---|
810 | template<> template<typename eT> arma_hot arma_pure arma_inline eT |
---|
811 | eop_core<eop_cos >::process(const eT val, const eT ) { return eop_aux::cos(val); } |
---|
812 | |
---|
813 | template<> template<typename eT> arma_hot arma_pure arma_inline eT |
---|
814 | eop_core<eop_sin >::process(const eT val, const eT ) { return eop_aux::sin(val); } |
---|
815 | |
---|
816 | template<> template<typename eT> arma_hot arma_pure arma_inline eT |
---|
817 | eop_core<eop_tan >::process(const eT val, const eT ) { return eop_aux::tan(val); } |
---|
818 | |
---|
819 | template<> template<typename eT> arma_hot arma_pure arma_inline eT |
---|
820 | eop_core<eop_acos >::process(const eT val, const eT ) { return eop_aux::acos(val); } |
---|
821 | |
---|
822 | template<> template<typename eT> arma_hot arma_pure arma_inline eT |
---|
823 | eop_core<eop_asin >::process(const eT val, const eT ) { return eop_aux::asin(val); } |
---|
824 | |
---|
825 | template<> template<typename eT> arma_hot arma_pure arma_inline eT |
---|
826 | eop_core<eop_atan >::process(const eT val, const eT ) { return eop_aux::atan(val); } |
---|
827 | |
---|
828 | template<> template<typename eT> arma_hot arma_pure arma_inline eT |
---|
829 | eop_core<eop_cosh >::process(const eT val, const eT ) { return eop_aux::cosh(val); } |
---|
830 | |
---|
831 | template<> template<typename eT> arma_hot arma_pure arma_inline eT |
---|
832 | eop_core<eop_sinh >::process(const eT val, const eT ) { return eop_aux::sinh(val); } |
---|
833 | |
---|
834 | template<> template<typename eT> arma_hot arma_pure arma_inline eT |
---|
835 | eop_core<eop_tanh >::process(const eT val, const eT ) { return eop_aux::tanh(val); } |
---|
836 | |
---|
837 | template<> template<typename eT> arma_hot arma_pure arma_inline eT |
---|
838 | eop_core<eop_acosh >::process(const eT val, const eT ) { return eop_aux::acosh(val); } |
---|
839 | |
---|
840 | template<> template<typename eT> arma_hot arma_pure arma_inline eT |
---|
841 | eop_core<eop_asinh >::process(const eT val, const eT ) { return eop_aux::asinh(val); } |
---|
842 | |
---|
843 | template<> template<typename eT> arma_hot arma_pure arma_inline eT |
---|
844 | eop_core<eop_atanh >::process(const eT val, const eT ) { return eop_aux::atanh(val); } |
---|
845 | |
---|
846 | template<> template<typename eT> arma_hot arma_pure arma_inline eT |
---|
847 | eop_core<eop_eps >::process(const eT val, const eT ) { return eop_aux::direct_eps(val); } |
---|
848 | |
---|
849 | template<> template<typename eT> arma_hot arma_pure arma_inline eT |
---|
850 | eop_core<eop_abs >::process(const eT val, const eT ) { return eop_aux::arma_abs(val); } |
---|
851 | |
---|
852 | template<> template<typename eT> arma_hot arma_pure arma_inline eT |
---|
853 | eop_core<eop_conj >::process(const eT val, const eT ) { return eop_aux::conj(val); } |
---|
854 | |
---|
855 | template<> template<typename eT> arma_hot arma_pure arma_inline eT |
---|
856 | eop_core<eop_pow >::process(const eT val, const eT k) { return eop_aux::pow(val, k); } |
---|
857 | |
---|
858 | template<> template<typename eT> arma_hot arma_pure arma_inline eT |
---|
859 | eop_core<eop_floor >::process(const eT val, const eT ) { return eop_aux::floor(val); } |
---|
860 | |
---|
861 | template<> template<typename eT> arma_hot arma_pure arma_inline eT |
---|
862 | eop_core<eop_ceil >::process(const eT val, const eT ) { return eop_aux::ceil(val); } |
---|
863 | |
---|
864 | template<> template<typename eT> arma_hot arma_pure arma_inline eT |
---|
865 | eop_core<eop_round >::process(const eT val, const eT ) { return eop_aux::round(val); } |
---|
866 | |
---|
867 | template<> template<typename eT> arma_hot arma_pure arma_inline eT |
---|
868 | eop_core<eop_sign >::process(const eT val, const eT ) { return eop_aux::sign(val); } |
---|
869 | |
---|
870 | |
---|
871 | #undef arma_applier_1u |
---|
872 | #undef arma_applier_1a |
---|
873 | #undef arma_applier_2 |
---|
874 | #undef arma_applier_3 |
---|
875 | |
---|
876 | |
---|
877 | |
---|
878 | //! @} |
---|