Mercurial > hg > segmenter-vamp-plugin
comparison armadillo-3.900.4/include/armadillo_bits/Row_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 Row | |
10 //! @{ | |
11 | |
12 | |
13 //! construct an empty row vector | |
14 template<typename eT> | |
15 inline | |
16 Row<eT>::Row() | |
17 : Mat<eT>(arma_vec_indicator(), 2) | |
18 { | |
19 arma_extra_debug_sigprint(); | |
20 } | |
21 | |
22 | |
23 | |
24 template<typename eT> | |
25 inline | |
26 Row<eT>::Row(const Row<eT>& X) | |
27 : Mat<eT>(arma_vec_indicator(), 1, X.n_elem, 2) | |
28 { | |
29 arma_extra_debug_sigprint(); | |
30 | |
31 arrayops::copy((*this).memptr(), X.memptr(), X.n_elem); | |
32 } | |
33 | |
34 | |
35 | |
36 //! construct a row vector with the specified number of n_elem | |
37 template<typename eT> | |
38 inline | |
39 Row<eT>::Row(const uword in_n_elem) | |
40 : Mat<eT>(arma_vec_indicator(), 1, in_n_elem, 2) | |
41 { | |
42 arma_extra_debug_sigprint(); | |
43 } | |
44 | |
45 | |
46 | |
47 template<typename eT> | |
48 inline | |
49 Row<eT>::Row(const uword in_n_rows, const uword in_n_cols) | |
50 : Mat<eT>(arma_vec_indicator(), 2) | |
51 { | |
52 arma_extra_debug_sigprint(); | |
53 | |
54 Mat<eT>::init_warm(in_n_rows, in_n_cols); | |
55 } | |
56 | |
57 | |
58 | |
59 template<typename eT> | |
60 inline | |
61 Row<eT>::Row(const char* text) | |
62 { | |
63 arma_extra_debug_sigprint(); | |
64 | |
65 access::rw(Mat<eT>::vec_state) = 2; | |
66 | |
67 Mat<eT>::operator=(text); | |
68 } | |
69 | |
70 | |
71 | |
72 template<typename eT> | |
73 inline | |
74 const Row<eT>& | |
75 Row<eT>::operator=(const char* text) | |
76 { | |
77 arma_extra_debug_sigprint(); | |
78 | |
79 Mat<eT>::operator=(text); | |
80 | |
81 return *this; | |
82 } | |
83 | |
84 | |
85 | |
86 template<typename eT> | |
87 inline | |
88 Row<eT>::Row(const std::string& text) | |
89 { | |
90 arma_extra_debug_sigprint(); | |
91 | |
92 access::rw(Mat<eT>::vec_state) = 2; | |
93 | |
94 Mat<eT>::operator=(text); | |
95 } | |
96 | |
97 | |
98 | |
99 template<typename eT> | |
100 inline | |
101 const Row<eT>& | |
102 Row<eT>::operator=(const std::string& text) | |
103 { | |
104 arma_extra_debug_sigprint(); | |
105 | |
106 Mat<eT>::operator=(text); | |
107 | |
108 return *this; | |
109 } | |
110 | |
111 | |
112 | |
113 //! create a row vector from std::vector | |
114 template<typename eT> | |
115 inline | |
116 Row<eT>::Row(const std::vector<eT>& x) | |
117 : Mat<eT>(arma_vec_indicator(), 1, uword(x.size()), 2) | |
118 { | |
119 arma_extra_debug_sigprint_this(this); | |
120 | |
121 if(x.size() > 0) | |
122 { | |
123 arrayops::copy( Mat<eT>::memptr(), &(x[0]), uword(x.size()) ); | |
124 } | |
125 } | |
126 | |
127 | |
128 | |
129 //! create a row vector from std::vector | |
130 template<typename eT> | |
131 inline | |
132 const Row<eT>& | |
133 Row<eT>::operator=(const std::vector<eT>& x) | |
134 { | |
135 arma_extra_debug_sigprint(); | |
136 | |
137 Mat<eT>::init_warm(1, uword(x.size())); | |
138 | |
139 if(x.size() > 0) | |
140 { | |
141 arrayops::copy( Mat<eT>::memptr(), &(x[0]), uword(x.size()) ); | |
142 } | |
143 | |
144 return *this; | |
145 } | |
146 | |
147 | |
148 | |
149 #if defined(ARMA_USE_CXX11) | |
150 | |
151 template<typename eT> | |
152 inline | |
153 Row<eT>::Row(const std::initializer_list<eT>& list) | |
154 { | |
155 arma_extra_debug_sigprint(); | |
156 | |
157 access::rw(Mat<eT>::vec_state) = 2; | |
158 | |
159 Mat<eT>::operator=(list); | |
160 } | |
161 | |
162 | |
163 | |
164 template<typename eT> | |
165 inline | |
166 const Row<eT>& | |
167 Row<eT>::operator=(const std::initializer_list<eT>& list) | |
168 { | |
169 arma_extra_debug_sigprint(); | |
170 | |
171 Mat<eT>::operator=(list); | |
172 | |
173 return *this; | |
174 } | |
175 | |
176 #endif | |
177 | |
178 | |
179 | |
180 template<typename eT> | |
181 inline | |
182 Row<eT>::Row(const SpRow<eT>& X) | |
183 : Mat<eT>(arma_vec_indicator(), 1, X.n_elem, 1) | |
184 { | |
185 arma_extra_debug_sigprint_this(this); | |
186 | |
187 arrayops::inplace_set(Mat<eT>::memptr(), eT(0), X.n_elem); | |
188 | |
189 for(typename SpRow<eT>::const_iterator it = X.begin(); it != X.end(); ++it) | |
190 at(it.col()) = (*it); | |
191 } | |
192 | |
193 | |
194 | |
195 template<typename eT> | |
196 inline | |
197 const Row<eT>& | |
198 Row<eT>::operator=(const eT val) | |
199 { | |
200 arma_extra_debug_sigprint(); | |
201 | |
202 Mat<eT>::operator=(val); | |
203 | |
204 return *this; | |
205 } | |
206 | |
207 | |
208 | |
209 template<typename eT> | |
210 template<typename T1> | |
211 inline | |
212 Row<eT>::Row(const Base<eT,T1>& X) | |
213 : Mat<eT>(arma_vec_indicator(), 2) | |
214 { | |
215 arma_extra_debug_sigprint(); | |
216 | |
217 Mat<eT>::operator=(X.get_ref()); | |
218 } | |
219 | |
220 | |
221 | |
222 template<typename eT> | |
223 template<typename T1> | |
224 inline | |
225 const Row<eT>& | |
226 Row<eT>::operator=(const Base<eT,T1>& X) | |
227 { | |
228 arma_extra_debug_sigprint(); | |
229 | |
230 Mat<eT>::operator=(X.get_ref()); | |
231 | |
232 return *this; | |
233 } | |
234 | |
235 | |
236 | |
237 //! construct a row vector from a given auxiliary array | |
238 template<typename eT> | |
239 inline | |
240 Row<eT>::Row(eT* aux_mem, const uword aux_length, const bool copy_aux_mem, const bool strict) | |
241 : Mat<eT>(aux_mem, 1, aux_length, copy_aux_mem, strict) | |
242 { | |
243 arma_extra_debug_sigprint(); | |
244 | |
245 access::rw(Mat<eT>::vec_state) = 2; | |
246 } | |
247 | |
248 | |
249 | |
250 //! construct a row vector from a given auxiliary array | |
251 template<typename eT> | |
252 inline | |
253 Row<eT>::Row(const eT* aux_mem, const uword aux_length) | |
254 : Mat<eT>(aux_mem, 1, aux_length) | |
255 { | |
256 arma_extra_debug_sigprint(); | |
257 | |
258 access::rw(Mat<eT>::vec_state) = 2; | |
259 } | |
260 | |
261 | |
262 | |
263 template<typename eT> | |
264 template<typename T1, typename T2> | |
265 inline | |
266 Row<eT>::Row | |
267 ( | |
268 const Base<typename Row<eT>::pod_type, T1>& A, | |
269 const Base<typename Row<eT>::pod_type, T2>& B | |
270 ) | |
271 { | |
272 arma_extra_debug_sigprint(); | |
273 | |
274 access::rw(Mat<eT>::vec_state) = 2; | |
275 | |
276 Mat<eT>::init(A,B); | |
277 } | |
278 | |
279 | |
280 | |
281 template<typename eT> | |
282 template<typename T1> | |
283 inline | |
284 Row<eT>::Row(const BaseCube<eT,T1>& X) | |
285 { | |
286 arma_extra_debug_sigprint(); | |
287 | |
288 access::rw(Mat<eT>::vec_state) = 2; | |
289 | |
290 Mat<eT>::operator=(X); | |
291 } | |
292 | |
293 | |
294 | |
295 template<typename eT> | |
296 template<typename T1> | |
297 inline | |
298 const Row<eT>& | |
299 Row<eT>::operator=(const BaseCube<eT,T1>& X) | |
300 { | |
301 arma_extra_debug_sigprint(); | |
302 | |
303 Mat<eT>::operator=(X); | |
304 | |
305 return *this; | |
306 } | |
307 | |
308 | |
309 | |
310 template<typename eT> | |
311 inline | |
312 Row<eT>::Row(const subview_cube<eT>& X) | |
313 { | |
314 arma_extra_debug_sigprint(); | |
315 | |
316 access::rw(Mat<eT>::vec_state) = 2; | |
317 | |
318 Mat<eT>::operator=(X); | |
319 } | |
320 | |
321 | |
322 | |
323 template<typename eT> | |
324 inline | |
325 const Row<eT>& | |
326 Row<eT>::operator=(const subview_cube<eT>& X) | |
327 { | |
328 arma_extra_debug_sigprint(); | |
329 | |
330 Mat<eT>::operator=(X); | |
331 | |
332 return *this; | |
333 } | |
334 | |
335 | |
336 | |
337 template<typename eT> | |
338 inline | |
339 mat_injector< Row<eT> > | |
340 Row<eT>::operator<<(const eT val) | |
341 { | |
342 return mat_injector< Row<eT> >(*this, val); | |
343 } | |
344 | |
345 | |
346 | |
347 template<typename eT> | |
348 arma_inline | |
349 const Op<Row<eT>,op_htrans> | |
350 Row<eT>::t() const | |
351 { | |
352 return Op<Row<eT>,op_htrans>(*this); | |
353 } | |
354 | |
355 | |
356 | |
357 template<typename eT> | |
358 arma_inline | |
359 const Op<Row<eT>,op_htrans> | |
360 Row<eT>::ht() const | |
361 { | |
362 return Op<Row<eT>,op_htrans>(*this); | |
363 } | |
364 | |
365 | |
366 | |
367 template<typename eT> | |
368 arma_inline | |
369 const Op<Row<eT>,op_strans> | |
370 Row<eT>::st() const | |
371 { | |
372 return Op<Row<eT>,op_strans>(*this); | |
373 } | |
374 | |
375 | |
376 | |
377 template<typename eT> | |
378 arma_inline | |
379 eT& | |
380 Row<eT>::col(const uword col_num) | |
381 { | |
382 arma_debug_check( (col_num >= Mat<eT>::n_cols), "Row::col(): index out of bounds" ); | |
383 | |
384 return access::rw(Mat<eT>::mem[col_num]); | |
385 } | |
386 | |
387 | |
388 | |
389 template<typename eT> | |
390 arma_inline | |
391 eT | |
392 Row<eT>::col(const uword col_num) const | |
393 { | |
394 arma_debug_check( (col_num >= Mat<eT>::n_cols), "Row::col(): index out of bounds" ); | |
395 | |
396 return Mat<eT>::mem[col_num]; | |
397 } | |
398 | |
399 | |
400 | |
401 template<typename eT> | |
402 arma_inline | |
403 subview_row<eT> | |
404 Row<eT>::cols(const uword in_col1, const uword in_col2) | |
405 { | |
406 arma_extra_debug_sigprint(); | |
407 | |
408 arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= Mat<eT>::n_cols) ), "Row::cols(): indices out of bounds or incorrectly used"); | |
409 | |
410 const uword subview_n_cols = in_col2 - in_col1 + 1; | |
411 | |
412 return subview_row<eT>(*this, 0, in_col1, subview_n_cols); | |
413 } | |
414 | |
415 | |
416 | |
417 template<typename eT> | |
418 arma_inline | |
419 const subview_row<eT> | |
420 Row<eT>::cols(const uword in_col1, const uword in_col2) const | |
421 { | |
422 arma_extra_debug_sigprint(); | |
423 | |
424 arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= Mat<eT>::n_cols) ), "Row::cols(): indices out of bounds or incorrectly used"); | |
425 | |
426 const uword subview_n_cols = in_col2 - in_col1 + 1; | |
427 | |
428 return subview_row<eT>(*this, 0, in_col1, subview_n_cols); | |
429 } | |
430 | |
431 | |
432 | |
433 template<typename eT> | |
434 arma_inline | |
435 subview_row<eT> | |
436 Row<eT>::subvec(const uword in_col1, const uword in_col2) | |
437 { | |
438 arma_extra_debug_sigprint(); | |
439 | |
440 arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= Mat<eT>::n_cols) ), "Row::subvec(): indices out of bounds or incorrectly used"); | |
441 | |
442 const uword subview_n_cols = in_col2 - in_col1 + 1; | |
443 | |
444 return subview_row<eT>(*this, 0, in_col1, subview_n_cols); | |
445 } | |
446 | |
447 | |
448 | |
449 template<typename eT> | |
450 arma_inline | |
451 const subview_row<eT> | |
452 Row<eT>::subvec(const uword in_col1, const uword in_col2) const | |
453 { | |
454 arma_extra_debug_sigprint(); | |
455 | |
456 arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= Mat<eT>::n_cols) ), "Row::subvec(): indices out of bounds or incorrectly used"); | |
457 | |
458 const uword subview_n_cols = in_col2 - in_col1 + 1; | |
459 | |
460 return subview_row<eT>(*this, 0, in_col1, subview_n_cols); | |
461 } | |
462 | |
463 | |
464 | |
465 template<typename eT> | |
466 arma_inline | |
467 subview_row<eT> | |
468 Row<eT>::subvec(const span& col_span) | |
469 { | |
470 arma_extra_debug_sigprint(); | |
471 | |
472 const bool col_all = col_span.whole; | |
473 | |
474 const uword local_n_cols = Mat<eT>::n_cols; | |
475 | |
476 const uword in_col1 = col_all ? 0 : col_span.a; | |
477 const uword in_col2 = col_span.b; | |
478 const uword subvec_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1; | |
479 | |
480 arma_debug_check( ( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) ), "Row::subvec(): indices out of bounds or incorrectly used"); | |
481 | |
482 return subview_row<eT>(*this, 0, in_col1, subvec_n_cols); | |
483 } | |
484 | |
485 | |
486 | |
487 template<typename eT> | |
488 arma_inline | |
489 const subview_row<eT> | |
490 Row<eT>::subvec(const span& col_span) const | |
491 { | |
492 arma_extra_debug_sigprint(); | |
493 | |
494 const bool col_all = col_span.whole; | |
495 | |
496 const uword local_n_cols = Mat<eT>::n_cols; | |
497 | |
498 const uword in_col1 = col_all ? 0 : col_span.a; | |
499 const uword in_col2 = col_span.b; | |
500 const uword subvec_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1; | |
501 | |
502 arma_debug_check( ( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) ), "Row::subvec(): indices out of bounds or incorrectly used"); | |
503 | |
504 return subview_row<eT>(*this, 0, in_col1, subvec_n_cols); | |
505 } | |
506 | |
507 | |
508 | |
509 template<typename eT> | |
510 arma_inline | |
511 subview_row<eT> | |
512 Row<eT>::operator()(const span& col_span) | |
513 { | |
514 arma_extra_debug_sigprint(); | |
515 | |
516 return subvec(col_span); | |
517 } | |
518 | |
519 | |
520 | |
521 template<typename eT> | |
522 arma_inline | |
523 const subview_row<eT> | |
524 Row<eT>::operator()(const span& col_span) const | |
525 { | |
526 arma_extra_debug_sigprint(); | |
527 | |
528 return subvec(col_span); | |
529 } | |
530 | |
531 | |
532 | |
533 //! remove specified columns | |
534 template<typename eT> | |
535 inline | |
536 void | |
537 Row<eT>::shed_col(const uword col_num) | |
538 { | |
539 arma_extra_debug_sigprint(); | |
540 | |
541 arma_debug_check( col_num >= Mat<eT>::n_cols, "Row::shed_col(): index out of bounds"); | |
542 | |
543 shed_cols(col_num, col_num); | |
544 } | |
545 | |
546 | |
547 | |
548 //! remove specified columns | |
549 template<typename eT> | |
550 inline | |
551 void | |
552 Row<eT>::shed_cols(const uword in_col1, const uword in_col2) | |
553 { | |
554 arma_extra_debug_sigprint(); | |
555 | |
556 arma_debug_check | |
557 ( | |
558 (in_col1 > in_col2) || (in_col2 >= Mat<eT>::n_cols), | |
559 "Row::shed_cols(): indices out of bounds or incorrectly used" | |
560 ); | |
561 | |
562 const uword n_keep_front = in_col1; | |
563 const uword n_keep_back = Mat<eT>::n_cols - (in_col2 + 1); | |
564 | |
565 Row<eT> X(n_keep_front + n_keep_back); | |
566 | |
567 eT* X_mem = X.memptr(); | |
568 const eT* t_mem = (*this).memptr(); | |
569 | |
570 if(n_keep_front > 0) | |
571 { | |
572 arrayops::copy( X_mem, t_mem, n_keep_front ); | |
573 } | |
574 | |
575 if(n_keep_back > 0) | |
576 { | |
577 arrayops::copy( &(X_mem[n_keep_front]), &(t_mem[in_col2+1]), n_keep_back); | |
578 } | |
579 | |
580 Mat<eT>::steal_mem(X); | |
581 } | |
582 | |
583 | |
584 | |
585 //! insert N cols at the specified col position, | |
586 //! optionally setting the elements of the inserted cols to zero | |
587 template<typename eT> | |
588 inline | |
589 void | |
590 Row<eT>::insert_cols(const uword col_num, const uword N, const bool set_to_zero) | |
591 { | |
592 arma_extra_debug_sigprint(); | |
593 | |
594 const uword t_n_cols = Mat<eT>::n_cols; | |
595 | |
596 const uword A_n_cols = col_num; | |
597 const uword B_n_cols = t_n_cols - col_num; | |
598 | |
599 // insertion at col_num == n_cols is in effect an append operation | |
600 arma_debug_check( (col_num > t_n_cols), "Row::insert_cols(): index out of bounds"); | |
601 | |
602 if(N > 0) | |
603 { | |
604 Row<eT> out(t_n_cols + N); | |
605 | |
606 eT* out_mem = out.memptr(); | |
607 const eT* t_mem = (*this).memptr(); | |
608 | |
609 if(A_n_cols > 0) | |
610 { | |
611 arrayops::copy( out_mem, t_mem, A_n_cols ); | |
612 } | |
613 | |
614 if(B_n_cols > 0) | |
615 { | |
616 arrayops::copy( &(out_mem[col_num + N]), &(t_mem[col_num]), B_n_cols ); | |
617 } | |
618 | |
619 if(set_to_zero == true) | |
620 { | |
621 arrayops::inplace_set( &(out_mem[col_num]), eT(0), N ); | |
622 } | |
623 | |
624 Mat<eT>::steal_mem(out); | |
625 } | |
626 } | |
627 | |
628 | |
629 | |
630 //! insert the given object at the specified col position; | |
631 //! the given object must have one row | |
632 template<typename eT> | |
633 template<typename T1> | |
634 inline | |
635 void | |
636 Row<eT>::insert_cols(const uword col_num, const Base<eT,T1>& X) | |
637 { | |
638 arma_extra_debug_sigprint(); | |
639 | |
640 Mat<eT>::insert_cols(col_num, X); | |
641 } | |
642 | |
643 | |
644 | |
645 template<typename eT> | |
646 arma_inline | |
647 arma_warn_unused | |
648 eT& | |
649 Row<eT>::at(const uword i) | |
650 { | |
651 return access::rw(Mat<eT>::mem[i]); | |
652 } | |
653 | |
654 | |
655 | |
656 template<typename eT> | |
657 arma_inline | |
658 arma_warn_unused | |
659 const eT& | |
660 Row<eT>::at(const uword i) const | |
661 { | |
662 return Mat<eT>::mem[i]; | |
663 } | |
664 | |
665 | |
666 | |
667 template<typename eT> | |
668 arma_inline | |
669 arma_warn_unused | |
670 eT& | |
671 Row<eT>::at(const uword, const uword in_col) | |
672 { | |
673 return access::rw( Mat<eT>::mem[in_col] ); | |
674 } | |
675 | |
676 | |
677 | |
678 template<typename eT> | |
679 arma_inline | |
680 arma_warn_unused | |
681 const eT& | |
682 Row<eT>::at(const uword, const uword in_col) const | |
683 { | |
684 return Mat<eT>::mem[in_col]; | |
685 } | |
686 | |
687 | |
688 | |
689 template<typename eT> | |
690 inline | |
691 typename Row<eT>::row_iterator | |
692 Row<eT>::begin_row(const uword row_num) | |
693 { | |
694 arma_extra_debug_sigprint(); | |
695 | |
696 arma_debug_check( (row_num >= Mat<eT>::n_rows), "begin_row(): index out of bounds"); | |
697 | |
698 return Mat<eT>::memptr(); | |
699 } | |
700 | |
701 | |
702 | |
703 template<typename eT> | |
704 inline | |
705 typename Row<eT>::const_row_iterator | |
706 Row<eT>::begin_row(const uword row_num) const | |
707 { | |
708 arma_extra_debug_sigprint(); | |
709 | |
710 arma_debug_check( (row_num >= Mat<eT>::n_rows), "begin_row(): index out of bounds"); | |
711 | |
712 return Mat<eT>::memptr(); | |
713 } | |
714 | |
715 | |
716 | |
717 template<typename eT> | |
718 inline | |
719 typename Row<eT>::row_iterator | |
720 Row<eT>::end_row(const uword row_num) | |
721 { | |
722 arma_extra_debug_sigprint(); | |
723 | |
724 arma_debug_check( (row_num >= Mat<eT>::n_rows), "end_row(): index out of bounds"); | |
725 | |
726 return Mat<eT>::memptr() + Mat<eT>::n_cols; | |
727 } | |
728 | |
729 | |
730 | |
731 template<typename eT> | |
732 inline | |
733 typename Row<eT>::const_row_iterator | |
734 Row<eT>::end_row(const uword row_num) const | |
735 { | |
736 arma_extra_debug_sigprint(); | |
737 | |
738 arma_debug_check( (row_num >= Mat<eT>::n_rows), "end_row(): index out of bounds"); | |
739 | |
740 return Mat<eT>::memptr() + Mat<eT>::n_cols; | |
741 } | |
742 | |
743 | |
744 | |
745 template<typename eT> | |
746 template<uword fixed_n_elem> | |
747 inline | |
748 Row<eT>::fixed<fixed_n_elem>::fixed() | |
749 : Row<eT>( arma_fixed_indicator(), fixed_n_elem, ((use_extra) ? mem_local_extra : Mat<eT>::mem_local) ) | |
750 { | |
751 arma_extra_debug_sigprint_this(this); | |
752 } | |
753 | |
754 | |
755 | |
756 template<typename eT> | |
757 template<uword fixed_n_elem> | |
758 arma_inline | |
759 Row<eT>::fixed<fixed_n_elem>::fixed(const fixed<fixed_n_elem>& X) | |
760 : Row<eT>( arma_fixed_indicator(), fixed_n_elem, ((use_extra) ? mem_local_extra : Mat<eT>::mem_local) ) | |
761 { | |
762 arma_extra_debug_sigprint_this(this); | |
763 | |
764 eT* dest = (use_extra) ? mem_local_extra : Mat<eT>::mem_local; | |
765 | |
766 arrayops::copy( dest, X.mem, fixed_n_elem ); | |
767 } | |
768 | |
769 | |
770 | |
771 template<typename eT> | |
772 template<uword fixed_n_elem> | |
773 arma_inline | |
774 Row<eT>::fixed<fixed_n_elem>::fixed(const subview_cube<eT>& X) | |
775 : Row<eT>( arma_fixed_indicator(), fixed_n_elem, ((use_extra) ? mem_local_extra : Mat<eT>::mem_local) ) | |
776 { | |
777 arma_extra_debug_sigprint_this(this); | |
778 | |
779 Row<eT>::operator=(X); | |
780 } | |
781 | |
782 | |
783 | |
784 template<typename eT> | |
785 template<uword fixed_n_elem> | |
786 template<typename T1> | |
787 arma_inline | |
788 Row<eT>::fixed<fixed_n_elem>::fixed(const Base<eT,T1>& A) | |
789 : Row<eT>( arma_fixed_indicator(), fixed_n_elem, ((use_extra) ? mem_local_extra : Mat<eT>::mem_local) ) | |
790 { | |
791 arma_extra_debug_sigprint_this(this); | |
792 | |
793 Row<eT>::operator=(A.get_ref()); | |
794 } | |
795 | |
796 | |
797 | |
798 template<typename eT> | |
799 template<uword fixed_n_elem> | |
800 template<typename T1, typename T2> | |
801 arma_inline | |
802 Row<eT>::fixed<fixed_n_elem>::fixed(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B) | |
803 : Row<eT>( arma_fixed_indicator(), fixed_n_elem, ((use_extra) ? mem_local_extra : Mat<eT>::mem_local) ) | |
804 { | |
805 arma_extra_debug_sigprint_this(this); | |
806 | |
807 Row<eT>::init(A,B); | |
808 } | |
809 | |
810 | |
811 | |
812 template<typename eT> | |
813 template<uword fixed_n_elem> | |
814 inline | |
815 Row<eT>::fixed<fixed_n_elem>::fixed(const eT* aux_mem) | |
816 : Row<eT>( arma_fixed_indicator(), fixed_n_elem, ((use_extra) ? mem_local_extra : Mat<eT>::mem_local) ) | |
817 { | |
818 arma_extra_debug_sigprint_this(this); | |
819 | |
820 eT* dest = (use_extra) ? mem_local_extra : Mat<eT>::mem_local; | |
821 | |
822 arrayops::copy( dest, aux_mem, fixed_n_elem ); | |
823 } | |
824 | |
825 | |
826 | |
827 template<typename eT> | |
828 template<uword fixed_n_elem> | |
829 inline | |
830 Row<eT>::fixed<fixed_n_elem>::fixed(const char* text) | |
831 : Row<eT>( arma_fixed_indicator(), fixed_n_elem, ((use_extra) ? mem_local_extra : Mat<eT>::mem_local) ) | |
832 { | |
833 arma_extra_debug_sigprint_this(this); | |
834 | |
835 Row<eT>::operator=(text); | |
836 } | |
837 | |
838 | |
839 | |
840 template<typename eT> | |
841 template<uword fixed_n_elem> | |
842 inline | |
843 Row<eT>::fixed<fixed_n_elem>::fixed(const std::string& text) | |
844 : Row<eT>( arma_fixed_indicator(), fixed_n_elem, ((use_extra) ? mem_local_extra : Mat<eT>::mem_local) ) | |
845 { | |
846 arma_extra_debug_sigprint_this(this); | |
847 | |
848 Row<eT>::operator=(text); | |
849 } | |
850 | |
851 | |
852 | |
853 template<typename eT> | |
854 template<uword fixed_n_elem> | |
855 template<typename T1> | |
856 const Row<eT>& | |
857 Row<eT>::fixed<fixed_n_elem>::operator=(const Base<eT,T1>& A) | |
858 { | |
859 arma_extra_debug_sigprint(); | |
860 | |
861 Row<eT>::operator=(A.get_ref()); | |
862 | |
863 return *this; | |
864 } | |
865 | |
866 | |
867 | |
868 template<typename eT> | |
869 template<uword fixed_n_elem> | |
870 const Row<eT>& | |
871 Row<eT>::fixed<fixed_n_elem>::operator=(const eT val) | |
872 { | |
873 arma_extra_debug_sigprint(); | |
874 | |
875 Row<eT>::operator=(val); | |
876 | |
877 return *this; | |
878 } | |
879 | |
880 | |
881 | |
882 template<typename eT> | |
883 template<uword fixed_n_elem> | |
884 const Row<eT>& | |
885 Row<eT>::fixed<fixed_n_elem>::operator=(const char* text) | |
886 { | |
887 arma_extra_debug_sigprint(); | |
888 | |
889 Row<eT>::operator=(text); | |
890 | |
891 return *this; | |
892 } | |
893 | |
894 | |
895 | |
896 template<typename eT> | |
897 template<uword fixed_n_elem> | |
898 const Row<eT>& | |
899 Row<eT>::fixed<fixed_n_elem>::operator=(const std::string& text) | |
900 { | |
901 arma_extra_debug_sigprint(); | |
902 | |
903 Row<eT>::operator=(text); | |
904 | |
905 return *this; | |
906 } | |
907 | |
908 | |
909 | |
910 template<typename eT> | |
911 template<uword fixed_n_elem> | |
912 const Row<eT>& | |
913 Row<eT>::fixed<fixed_n_elem>::operator=(const subview_cube<eT>& X) | |
914 { | |
915 arma_extra_debug_sigprint(); | |
916 | |
917 Row<eT>::operator=(X); | |
918 | |
919 return *this; | |
920 } | |
921 | |
922 | |
923 | |
924 #if defined(ARMA_USE_CXX11) | |
925 | |
926 template<typename eT> | |
927 template<uword fixed_n_elem> | |
928 inline | |
929 Row<eT>::fixed<fixed_n_elem>::fixed(const std::initializer_list<eT>& list) | |
930 : Row<eT>( arma_fixed_indicator(), fixed_n_elem, ((use_extra) ? mem_local_extra : Mat<eT>::mem_local) ) | |
931 { | |
932 arma_extra_debug_sigprint_this(this); | |
933 | |
934 (*this).operator=(list); | |
935 } | |
936 | |
937 | |
938 | |
939 template<typename eT> | |
940 template<uword fixed_n_elem> | |
941 inline | |
942 const Row<eT>& | |
943 Row<eT>::fixed<fixed_n_elem>::operator=(const std::initializer_list<eT>& list) | |
944 { | |
945 arma_extra_debug_sigprint(); | |
946 | |
947 const uword N = list.size(); | |
948 | |
949 arma_debug_check( (N > fixed_n_elem), "Row::fixed: initialiser list is too long" ); | |
950 | |
951 eT* this_mem = (*this).memptr(); | |
952 | |
953 arrayops::copy( this_mem, list.begin(), N ); | |
954 | |
955 for(uword iq=N; iq < fixed_n_elem; ++iq) { this_mem[iq] = eT(0); } | |
956 | |
957 return *this; | |
958 } | |
959 | |
960 #endif | |
961 | |
962 | |
963 | |
964 template<typename eT> | |
965 template<uword fixed_n_elem> | |
966 arma_inline | |
967 const Op< typename Row<eT>::template fixed<fixed_n_elem>::Row_fixed_type, op_htrans > | |
968 Row<eT>::fixed<fixed_n_elem>::t() const | |
969 { | |
970 return Op< typename Row<eT>::template fixed<fixed_n_elem>::Row_fixed_type, op_htrans >(*this); | |
971 } | |
972 | |
973 | |
974 | |
975 template<typename eT> | |
976 template<uword fixed_n_elem> | |
977 arma_inline | |
978 const Op< typename Row<eT>::template fixed<fixed_n_elem>::Row_fixed_type, op_htrans > | |
979 Row<eT>::fixed<fixed_n_elem>::ht() const | |
980 { | |
981 return Op< typename Row<eT>::template fixed<fixed_n_elem>::Row_fixed_type, op_htrans >(*this); | |
982 } | |
983 | |
984 | |
985 | |
986 template<typename eT> | |
987 template<uword fixed_n_elem> | |
988 arma_inline | |
989 const Op< typename Row<eT>::template fixed<fixed_n_elem>::Row_fixed_type, op_strans > | |
990 Row<eT>::fixed<fixed_n_elem>::st() const | |
991 { | |
992 return Op< typename Row<eT>::template fixed<fixed_n_elem>::Row_fixed_type, op_strans >(*this); | |
993 } | |
994 | |
995 | |
996 | |
997 template<typename eT> | |
998 template<uword fixed_n_elem> | |
999 arma_inline | |
1000 arma_warn_unused | |
1001 const eT& | |
1002 Row<eT>::fixed<fixed_n_elem>::at_alt(const uword ii) const | |
1003 { | |
1004 #if defined(ARMA_HAVE_ALIGNED_ATTRIBUTE) | |
1005 | |
1006 return (use_extra) ? mem_local_extra[ii] : Mat<eT>::mem_local[ii]; | |
1007 | |
1008 #else | |
1009 const eT* mem_aligned = (use_extra) ? mem_local_extra : Mat<eT>::mem_local; | |
1010 | |
1011 memory::mark_as_aligned(mem_aligned); | |
1012 | |
1013 return mem_aligned[ii]; | |
1014 #endif | |
1015 } | |
1016 | |
1017 | |
1018 | |
1019 template<typename eT> | |
1020 template<uword fixed_n_elem> | |
1021 arma_inline | |
1022 arma_warn_unused | |
1023 eT& | |
1024 Row<eT>::fixed<fixed_n_elem>::operator[] (const uword ii) | |
1025 { | |
1026 return (use_extra) ? mem_local_extra[ii] : Mat<eT>::mem_local[ii]; | |
1027 } | |
1028 | |
1029 | |
1030 | |
1031 template<typename eT> | |
1032 template<uword fixed_n_elem> | |
1033 arma_inline | |
1034 arma_warn_unused | |
1035 const eT& | |
1036 Row<eT>::fixed<fixed_n_elem>::operator[] (const uword ii) const | |
1037 { | |
1038 return (use_extra) ? mem_local_extra[ii] : Mat<eT>::mem_local[ii]; | |
1039 } | |
1040 | |
1041 | |
1042 | |
1043 template<typename eT> | |
1044 template<uword fixed_n_elem> | |
1045 arma_inline | |
1046 arma_warn_unused | |
1047 eT& | |
1048 Row<eT>::fixed<fixed_n_elem>::at(const uword ii) | |
1049 { | |
1050 return (use_extra) ? mem_local_extra[ii] : Mat<eT>::mem_local[ii]; | |
1051 } | |
1052 | |
1053 | |
1054 | |
1055 template<typename eT> | |
1056 template<uword fixed_n_elem> | |
1057 arma_inline | |
1058 arma_warn_unused | |
1059 const eT& | |
1060 Row<eT>::fixed<fixed_n_elem>::at(const uword ii) const | |
1061 { | |
1062 return (use_extra) ? mem_local_extra[ii] : Mat<eT>::mem_local[ii]; | |
1063 } | |
1064 | |
1065 | |
1066 | |
1067 template<typename eT> | |
1068 template<uword fixed_n_elem> | |
1069 arma_inline | |
1070 arma_warn_unused | |
1071 eT& | |
1072 Row<eT>::fixed<fixed_n_elem>::operator() (const uword ii) | |
1073 { | |
1074 arma_debug_check( (ii >= fixed_n_elem), "Row::operator(): index out of bounds"); | |
1075 | |
1076 return (use_extra) ? mem_local_extra[ii] : Mat<eT>::mem_local[ii]; | |
1077 } | |
1078 | |
1079 | |
1080 | |
1081 template<typename eT> | |
1082 template<uword fixed_n_elem> | |
1083 arma_inline | |
1084 arma_warn_unused | |
1085 const eT& | |
1086 Row<eT>::fixed<fixed_n_elem>::operator() (const uword ii) const | |
1087 { | |
1088 arma_debug_check( (ii >= fixed_n_elem), "Row::operator(): index out of bounds"); | |
1089 | |
1090 return (use_extra) ? mem_local_extra[ii] : Mat<eT>::mem_local[ii]; | |
1091 } | |
1092 | |
1093 | |
1094 | |
1095 template<typename eT> | |
1096 template<uword fixed_n_elem> | |
1097 arma_inline | |
1098 arma_warn_unused | |
1099 eT& | |
1100 Row<eT>::fixed<fixed_n_elem>::at(const uword, const uword in_col) | |
1101 { | |
1102 return (use_extra) ? mem_local_extra[in_col] : Mat<eT>::mem_local[in_col]; | |
1103 } | |
1104 | |
1105 | |
1106 | |
1107 template<typename eT> | |
1108 template<uword fixed_n_elem> | |
1109 arma_inline | |
1110 arma_warn_unused | |
1111 const eT& | |
1112 Row<eT>::fixed<fixed_n_elem>::at(const uword, const uword in_col) const | |
1113 { | |
1114 return (use_extra) ? mem_local_extra[in_col] : Mat<eT>::mem_local[in_col]; | |
1115 } | |
1116 | |
1117 | |
1118 | |
1119 template<typename eT> | |
1120 template<uword fixed_n_elem> | |
1121 arma_inline | |
1122 arma_warn_unused | |
1123 eT& | |
1124 Row<eT>::fixed<fixed_n_elem>::operator() (const uword in_row, const uword in_col) | |
1125 { | |
1126 arma_debug_check( ((in_row > 0) || (in_col >= fixed_n_elem)), "Row::operator(): index out of bounds" ); | |
1127 | |
1128 return (use_extra) ? mem_local_extra[in_col] : Mat<eT>::mem_local[in_col]; | |
1129 } | |
1130 | |
1131 | |
1132 | |
1133 template<typename eT> | |
1134 template<uword fixed_n_elem> | |
1135 arma_inline | |
1136 arma_warn_unused | |
1137 const eT& | |
1138 Row<eT>::fixed<fixed_n_elem>::operator() (const uword in_row, const uword in_col) const | |
1139 { | |
1140 arma_debug_check( ((in_row > 0) || (in_col >= fixed_n_elem)), "Row::operator(): index out of bounds" ); | |
1141 | |
1142 return (use_extra) ? mem_local_extra[in_col] : Mat<eT>::mem_local[in_col]; | |
1143 } | |
1144 | |
1145 | |
1146 | |
1147 template<typename eT> | |
1148 template<uword fixed_n_elem> | |
1149 arma_inline | |
1150 arma_warn_unused | |
1151 eT* | |
1152 Row<eT>::fixed<fixed_n_elem>::memptr() | |
1153 { | |
1154 return (use_extra) ? mem_local_extra : Mat<eT>::mem_local; | |
1155 } | |
1156 | |
1157 | |
1158 | |
1159 template<typename eT> | |
1160 template<uword fixed_n_elem> | |
1161 arma_inline | |
1162 arma_warn_unused | |
1163 const eT* | |
1164 Row<eT>::fixed<fixed_n_elem>::memptr() const | |
1165 { | |
1166 return (use_extra) ? mem_local_extra : Mat<eT>::mem_local; | |
1167 } | |
1168 | |
1169 | |
1170 | |
1171 template<typename eT> | |
1172 template<uword fixed_n_elem> | |
1173 arma_hot | |
1174 inline | |
1175 const Row<eT>& | |
1176 Row<eT>::fixed<fixed_n_elem>::fill(const eT val) | |
1177 { | |
1178 arma_extra_debug_sigprint(); | |
1179 | |
1180 eT* mem_use = (use_extra) ? &(mem_local_extra[0]) : &(Mat<eT>::mem_local[0]); | |
1181 | |
1182 arrayops::inplace_set_fixed<eT,fixed_n_elem>( mem_use, val ); | |
1183 | |
1184 return *this; | |
1185 } | |
1186 | |
1187 | |
1188 | |
1189 template<typename eT> | |
1190 template<uword fixed_n_elem> | |
1191 arma_hot | |
1192 inline | |
1193 const Row<eT>& | |
1194 Row<eT>::fixed<fixed_n_elem>::zeros() | |
1195 { | |
1196 arma_extra_debug_sigprint(); | |
1197 | |
1198 eT* mem_use = (use_extra) ? &(mem_local_extra[0]) : &(Mat<eT>::mem_local[0]); | |
1199 | |
1200 arrayops::inplace_set_fixed<eT,fixed_n_elem>( mem_use, eT(0) ); | |
1201 | |
1202 return *this; | |
1203 } | |
1204 | |
1205 | |
1206 | |
1207 template<typename eT> | |
1208 template<uword fixed_n_elem> | |
1209 arma_hot | |
1210 inline | |
1211 const Row<eT>& | |
1212 Row<eT>::fixed<fixed_n_elem>::ones() | |
1213 { | |
1214 arma_extra_debug_sigprint(); | |
1215 | |
1216 eT* mem_use = (use_extra) ? &(mem_local_extra[0]) : &(Mat<eT>::mem_local[0]); | |
1217 | |
1218 arrayops::inplace_set_fixed<eT,fixed_n_elem>( mem_use, eT(1) ); | |
1219 | |
1220 return *this; | |
1221 } | |
1222 | |
1223 | |
1224 | |
1225 template<typename eT> | |
1226 inline | |
1227 Row<eT>::Row(const arma_fixed_indicator&, const uword in_n_elem, const eT* in_mem) | |
1228 : Mat<eT>(arma_fixed_indicator(), 1, in_n_elem, 2, in_mem) | |
1229 { | |
1230 arma_extra_debug_sigprint_this(this); | |
1231 } | |
1232 | |
1233 | |
1234 | |
1235 #ifdef ARMA_EXTRA_ROW_MEAT | |
1236 #include ARMA_INCFILE_WRAP(ARMA_EXTRA_ROW_MEAT) | |
1237 #endif | |
1238 | |
1239 | |
1240 | |
1241 //! @} |