fn_conv_to.hpp
Go to the documentation of this file.
1 // Copyright (C) 2008-2010 NICTA (www.nicta.com.au)
2 // Copyright (C) 2008-2010 Conrad Sanderson
3 //
4 // This file is part of the Armadillo C++ library.
5 // It is provided without any warranty of fitness
6 // for any purpose. You can redistribute this file
7 // and/or modify it under the terms of the GNU
8 // Lesser General Public License (LGPL) as published
9 // by the Free Software Foundation, either version 3
10 // of the License or (at your option) any later version.
11 // (see http://www.opensource.org/licenses for more info)
12 
13 
16 
17 
18 
21 template<typename out_eT>
22 class conv_to
23  {
24  public:
25 
26  template<typename in_eT, typename T1>
27  inline static out_eT from(const Base<in_eT, T1>& in, const typename arma_not_cx<in_eT>::result* junk = 0);
28 
29  template<typename in_eT, typename T1>
30  inline static out_eT from(const Base<in_eT, T1>& in, const typename arma_cx_only<in_eT>::result* junk = 0);
31 
32  template<typename in_eT, typename T1>
33  inline static out_eT from(const BaseCube<in_eT, T1>& in, const typename arma_not_cx<in_eT>::result* junk = 0);
34 
35  template<typename in_eT, typename T1>
36  inline static out_eT from(const BaseCube<in_eT, T1>& in, const typename arma_cx_only<in_eT>::result* junk = 0);
37  };
38 
39 
40 
41 template<typename out_eT>
42 template<typename in_eT, typename T1>
43 inline
44 out_eT
46  {
48 
49  arma_ignore(junk);
50 
52 
53  const unwrap<T1> tmp(in.get_ref());
54  const Mat<in_eT>& X = tmp.M;
55 
56  arma_debug_check( (X.n_elem != 1), "conv_to(): given object doesn't have exactly one element" );
57 
58  return out_eT(X.mem[0]);
59  }
60 
61 
62 
63 template<typename out_eT>
64 template<typename in_eT, typename T1>
65 inline
66 out_eT
68  {
70 
71  arma_ignore(junk);
72 
74 
75  const unwrap<T1> tmp(in.get_ref());
76  const Mat<in_eT>& X = tmp.M;
77 
78  arma_debug_check( (X.n_elem != 1), "conv_to(): given object doesn't have exactly one element" );
79 
80  out_eT out;
81 
82  arrayops::convert_cx_scalar(out, X.mem[0]);
83 
84  return out;
85  }
86 
87 
88 
89 template<typename out_eT>
90 template<typename in_eT, typename T1>
91 inline
92 out_eT
94  {
96 
97  arma_ignore(junk);
98 
100 
101  const unwrap_cube<T1> tmp(in.get_ref());
102  const Cube<in_eT>& X = tmp.M;
103 
104  arma_debug_check( (X.n_elem != 1), "conv_to(): given object doesn't have exactly one element" );
105 
106  return out_eT(X.mem[0]);
107  }
108 
109 
110 
111 template<typename out_eT>
112 template<typename in_eT, typename T1>
113 inline
114 out_eT
116  {
118 
119  arma_ignore(junk);
120 
122 
123  const unwrap_cube<T1> tmp(in.get_ref());
124  const Cube<in_eT>& X = tmp.M;
125 
126  arma_debug_check( (X.n_elem != 1), "conv_to(): given object doesn't have exactly one element" );
127 
128  out_eT out;
129 
130  arrayops::convert_cx_scalar(out, X.mem[0]);
131 
132  return out;
133  }
134 
135 
136 
139 template<typename out_eT>
140 class conv_to< Mat<out_eT> >
141  {
142  public:
143 
144  template<typename in_eT, typename T1>
145  inline static Mat<out_eT> from(const Base<in_eT, T1>& in, const typename arma_not_cx<in_eT>::result* junk = 0);
146 
147  template<typename in_eT, typename T1>
148  inline static Mat<out_eT> from(const Base<in_eT, T1>& in, const typename arma_cx_only<in_eT>::result* junk = 0);
149 
150 
151 
152  template<typename in_eT>
153  inline static Mat<out_eT> from(const std::vector<in_eT>& in, const typename arma_not_cx<in_eT>::result* junk = 0);
154 
155  template<typename in_eT>
156  inline static Mat<out_eT> from(const std::vector<in_eT>& in, const typename arma_cx_only<in_eT>::result* junk = 0);
157 
158 
159 
160  template<typename in_eT>
161  inline static Mat<out_eT> from(const itpp::Mat<in_eT>& in, const typename arma_not_cx<in_eT>::result* junk = 0);
162 
163  template<typename in_eT>
164  inline static Mat<out_eT> from(const itpp::Mat<in_eT>& in, const typename arma_cx_only<in_eT>::result* junk = 0);
165 
166 
167 
168  template<typename in_eT>
169  inline static Mat<out_eT> from(const itpp::Vec<in_eT>& in, const typename arma_not_cx<in_eT>::result* junk = 0);
170 
171  template<typename in_eT>
172  inline static Mat<out_eT> from(const itpp::Vec<in_eT>& in, const typename arma_cx_only<in_eT>::result* junk = 0);
173  };
174 
175 
176 
177 template<typename out_eT>
178 template<typename in_eT, typename T1>
179 inline
182  {
184 
185  arma_ignore(junk);
186 
187  const unwrap<T1> tmp(in.get_ref());
188  const Mat<in_eT>& X = tmp.M;
189 
190  Mat<out_eT> out(X.n_rows, X.n_cols);
191 
192  arrayops::convert( out.memptr(), X.memptr(), out.n_elem );
193 
194  return out;
195  }
196 
197 
198 
199 template<typename out_eT>
200 template<typename in_eT, typename T1>
201 inline
204  {
206 
207  arma_ignore(junk);
208 
209  const unwrap<T1> tmp(in.get_ref());
210  const Mat<in_eT>& X = tmp.M;
211 
212  Mat<out_eT> out(X.n_rows, X.n_cols);
213 
214  arrayops::convert_cx( out.memptr(), X.memptr(), out.n_elem );
215 
216  return out;
217  }
218 
219 
220 
221 template<typename out_eT>
222 template<typename in_eT>
223 inline
225 conv_to< Mat<out_eT> >::from(const std::vector<in_eT>& in, const typename arma_not_cx<in_eT>::result* junk)
226  {
228 
229  arma_ignore(junk);
230 
231  Mat<out_eT> out(in.size(), 1);
232 
233  typename std::vector<in_eT>::const_iterator in_begin = in.begin();
234  typename std::vector<in_eT>::const_iterator in_end = in.end();
235 
236  typename Mat<out_eT>::iterator out_begin = out.begin();
237  typename Mat<out_eT>::iterator out_end = out.end();
238 
239  typename std::vector<in_eT>::const_iterator in_it;
240  typename Mat<out_eT>::iterator out_it;
241 
242  for(in_it = in_begin, out_it = out_begin; (in_it != in_end) && (out_it != out_end); ++in_it, ++out_it)
243  {
244  (*out_it) = out_eT(*in_it);
245  }
246 
247  return out;
248  }
249 
250 
251 
252 template<typename out_eT>
253 template<typename in_eT>
254 inline
256 conv_to< Mat<out_eT> >::from(const std::vector<in_eT>& in, const typename arma_cx_only<in_eT>::result* junk)
257  {
259 
260  arma_ignore(junk);
261 
262  Mat<out_eT> out(in.size(), 1);
263 
264  typename std::vector<in_eT>::const_iterator in_begin = in.begin();
265  typename std::vector<in_eT>::const_iterator in_end = in.end();
266 
267  typename Mat<out_eT>::iterator out_begin = out.begin();
268  typename Mat<out_eT>::iterator out_end = out.end();
269 
270  typename std::vector<in_eT>::const_iterator in_it;
271  typename Mat<out_eT>::iterator out_it;
272 
273  for(in_it = in_begin, out_it = out_begin; (in_it != in_end) && (out_it != out_end); ++in_it, ++out_it)
274  {
275  out_eT& out_elem = (*out_it);
276  const in_eT& in_elem = (*in_it);
277 
278  arrayops::convert_cx_scalar(out_elem, in_elem);
279  }
280 
281  return out;
282  }
283 
284 
285 
286 template<typename out_eT>
287 template<typename in_eT>
288 inline
291  {
293 
294  arma_ignore(junk);
295 
296  Mat<out_eT> out(in.rows(), in.cols());
297 
298  arrayops::convert( out.memptr(), in._data(), out.n_elem );
299 
300  return out;
301  }
302 
303 
304 
305 template<typename out_eT>
306 template<typename in_eT>
307 inline
310  {
312 
313  arma_ignore(junk);
314 
315  Mat<out_eT> out(in.rows(), in.cols());
316 
317  arrayops::convert_cx( out.memptr(), in._data(), out.n_elem );
318 
319  return out;
320  }
321 
322 
323 
324 template<typename out_eT>
325 template<typename in_eT>
326 inline
329  {
331 
332  arma_ignore(junk);
333 
334  Mat<out_eT> out(in.length(), 1);
335 
336  arrayops::convert( out.memptr(), in._data(), out.n_elem );
337 
338  return out;
339  }
340 
341 
342 
343 template<typename out_eT>
344 template<typename in_eT>
345 inline
348  {
350 
351  arma_ignore(junk);
352 
353  Mat<out_eT> out(in.length(), 1);
354 
355  arrayops::convert_cx( out.memptr(), in._data(), out.n_elem );
356 
357  return out;
358  }
359 
360 
361 
364 template<typename out_eT>
365 class conv_to< Row<out_eT> >
366  {
367  public:
368 
369  template<typename in_eT, typename T1>
370  inline static Row<out_eT> from(const Base<in_eT, T1>& in, const typename arma_not_cx<in_eT>::result* junk = 0);
371 
372  template<typename in_eT, typename T1>
373  inline static Row<out_eT> from(const Base<in_eT, T1>& in, const typename arma_cx_only<in_eT>::result* junk = 0);
374 
375 
376 
377  template<typename in_eT>
378  inline static Row<out_eT> from(const std::vector<in_eT>& in, const typename arma_not_cx<in_eT>::result* junk = 0);
379 
380  template<typename in_eT>
381  inline static Row<out_eT> from(const std::vector<in_eT>& in, const typename arma_cx_only<in_eT>::result* junk = 0);
382 
383 
384 
385  template<typename in_eT>
386  inline static Row<out_eT> from(const itpp::Mat<in_eT>& in, const typename arma_not_cx<in_eT>::result* junk = 0);
387 
388  template<typename in_eT>
389  inline static Row<out_eT> from(const itpp::Mat<in_eT>& in, const typename arma_cx_only<in_eT>::result* junk = 0);
390 
391 
392 
393  template<typename in_eT>
394  inline static Row<out_eT> from(const itpp::Vec<in_eT>& in, const typename arma_not_cx<in_eT>::result* junk = 0);
395 
396  template<typename in_eT>
397  inline static Row<out_eT> from(const itpp::Vec<in_eT>& in, const typename arma_cx_only<in_eT>::result* junk = 0);
398  };
399 
400 
401 
402 template<typename out_eT>
403 template<typename in_eT, typename T1>
404 inline
407  {
409 
410  arma_ignore(junk);
411 
412  const unwrap<T1> tmp(in.get_ref());
413  const Mat<in_eT>& X = tmp.M;
414 
415  arma_debug_check( (X.is_vec() == false), "conv_to(): given object can't be interpreted as a vector" );
416 
417  Row<out_eT> out(X.n_elem);
418 
419  arrayops::convert( out.memptr(), X.memptr(), out.n_elem );
420 
421  return out;
422  }
423 
424 
425 
426 template<typename out_eT>
427 template<typename in_eT, typename T1>
428 inline
431  {
433 
434  arma_ignore(junk);
435 
436  const unwrap<T1> tmp(in.get_ref());
437  const Mat<in_eT>& X = tmp.M;
438 
439  arma_debug_check( (X.is_vec() == false), "conv_to(): given object can't be interpreted as a vector" );
440 
441  Row<out_eT> out(X.n_rows, X.n_cols);
442 
443  arrayops::convert_cx( out.memptr(), X.memptr(), out.n_elem );
444 
445  return out;
446  }
447 
448 
449 
450 template<typename out_eT>
451 template<typename in_eT>
452 inline
454 conv_to< Row<out_eT> >::from(const std::vector<in_eT>& in, const typename arma_not_cx<in_eT>::result* junk)
455  {
457 
458  arma_ignore(junk);
459 
460  Row<out_eT> out( in.size() );
461 
462  typename std::vector<in_eT>::const_iterator in_begin = in.begin();
463  typename std::vector<in_eT>::const_iterator in_end = in.end();
464 
465  typename Col<out_eT>::iterator out_begin = out.begin();
466  typename Col<out_eT>::iterator out_end = out.end();
467 
468  typename std::vector<in_eT>::const_iterator in_it;
469  typename Col<out_eT>::iterator out_it;
470 
471  for(in_it = in_begin, out_it = out_begin; (in_it != in_end) && (out_it != out_end); ++in_it, ++out_it)
472  {
473  (*out_it) = out_eT(*in_it);
474  }
475 
476  return out;
477  }
478 
479 
480 
481 template<typename out_eT>
482 template<typename in_eT>
483 inline
485 conv_to< Row<out_eT> >::from(const std::vector<in_eT>& in, const typename arma_cx_only<in_eT>::result* junk)
486  {
488 
489  arma_ignore(junk);
490 
491  Row<out_eT> out( in.size() );
492 
493  typename std::vector<in_eT>::const_iterator in_begin = in.begin();
494  typename std::vector<in_eT>::const_iterator in_end = in.end();
495 
496  typename Col<out_eT>::iterator out_begin = out.begin();
497  typename Col<out_eT>::iterator out_end = out.end();
498 
499  typename std::vector<in_eT>::const_iterator in_it;
500  typename Col<out_eT>::iterator out_it;
501 
502  for(in_it = in_begin, out_it = out_begin; (in_it != in_end) && (out_it != out_end); ++in_it, ++out_it)
503  {
504  out_eT& out_elem = (*out_it);
505  const in_eT& in_elem = (*in_it);
506 
507  arrayops::convert_cx_scalar(out_elem, in_elem);
508  }
509 
510  return out;
511  }
512 
513 
514 
515 template<typename out_eT>
516 template<typename in_eT>
517 inline
520  {
522 
523  arma_ignore(junk);
524 
525  const bool is_vec = ( (in.rows() == 1) || (in.cols() == 1) );
526 
527  arma_debug_check( (is_vec == false), "conv_to(): given object can't be interpreted as a vector" );
528 
529  Row<out_eT> out(in.rows() * in.cols());
530 
531  arrayops::convert( out.memptr(), in._data(), out.n_elem );
532 
533  return out;
534  }
535 
536 
537 
538 template<typename out_eT>
539 template<typename in_eT>
540 inline
543  {
545 
546  arma_ignore(junk);
547 
548  //const bool is_vec = ( (in.rows() == 1) || (in.cols() == 1) );
549 
550  Row<out_eT> out(in.rows() * in.cols());
551 
552  arrayops::convert_cx( out.memptr(), in._data(), out.n_elem );
553 
554  return out;
555  }
556 
557 
558 
559 template<typename out_eT>
560 template<typename in_eT>
561 inline
564  {
566 
567  arma_ignore(junk);
568 
569  Row<out_eT> out(in.length());
570 
571  arrayops::convert( out.memptr(), in._data(), out.n_elem );
572 
573  return out;
574  }
575 
576 
577 
578 template<typename out_eT>
579 template<typename in_eT>
580 inline
583  {
585 
586  arma_ignore(junk);
587 
588  Row<out_eT> out(in.length());
589 
590  arrayops::convert_cx( out.memptr(), in._data(), out.n_elem );
591 
592  return out;
593  }
594 
595 
596 
599 template<typename out_eT>
600 class conv_to< Col<out_eT> >
601  {
602  public:
603 
604  template<typename in_eT, typename T1>
605  inline static Col<out_eT> from(const Base<in_eT, T1>& in, const typename arma_not_cx<in_eT>::result* junk = 0);
606 
607  template<typename in_eT, typename T1>
608  inline static Col<out_eT> from(const Base<in_eT, T1>& in, const typename arma_cx_only<in_eT>::result* junk = 0);
609 
610 
611 
612  template<typename in_eT>
613  inline static Col<out_eT> from(const std::vector<in_eT>& in, const typename arma_not_cx<in_eT>::result* junk = 0);
614 
615  template<typename in_eT>
616  inline static Col<out_eT> from(const std::vector<in_eT>& in, const typename arma_cx_only<in_eT>::result* junk = 0);
617 
618 
619 
620  template<typename in_eT>
621  inline static Col<out_eT> from(const itpp::Mat<in_eT>& in, const typename arma_not_cx<in_eT>::result* junk = 0);
622 
623  template<typename in_eT>
624  inline static Col<out_eT> from(const itpp::Mat<in_eT>& in, const typename arma_cx_only<in_eT>::result* junk = 0);
625 
626 
627 
628  template<typename in_eT>
629  inline static Col<out_eT> from(const itpp::Vec<in_eT>& in, const typename arma_not_cx<in_eT>::result* junk = 0);
630 
631  template<typename in_eT>
632  inline static Col<out_eT> from(const itpp::Vec<in_eT>& in, const typename arma_cx_only<in_eT>::result* junk = 0);
633  };
634 
635 
636 
637 template<typename out_eT>
638 template<typename in_eT, typename T1>
639 inline
642  {
644 
645  arma_ignore(junk);
646 
647  const unwrap<T1> tmp(in.get_ref());
648  const Mat<in_eT>& X = tmp.M;
649 
650  arma_debug_check( (X.is_vec() == false), "conv_to(): given object can't be interpreted as a vector" );
651 
652  Col<out_eT> out(X.n_elem);
653 
654  arrayops::convert( out.memptr(), X.memptr(), out.n_elem );
655 
656  return out;
657  }
658 
659 
660 
661 template<typename out_eT>
662 template<typename in_eT, typename T1>
663 inline
666  {
668 
669  arma_ignore(junk);
670 
671  const unwrap<T1> tmp(in.get_ref());
672  const Mat<in_eT>& X = tmp.M;
673 
674  arma_debug_check( (X.is_vec() == false), "conv_to(): given object can't be interpreted as a vector" );
675 
676  Col<out_eT> out(X.n_rows, X.n_cols);
677 
678  arrayops::convert_cx( out.memptr(), X.memptr(), out.n_elem );
679 
680  return out;
681  }
682 
683 
684 
685 template<typename out_eT>
686 template<typename in_eT>
687 inline
689 conv_to< Col<out_eT> >::from(const std::vector<in_eT>& in, const typename arma_not_cx<in_eT>::result* junk)
690  {
692 
693  arma_ignore(junk);
694 
695  Col<out_eT> out( in.size() );
696 
697  typename std::vector<in_eT>::const_iterator in_begin = in.begin();
698  typename std::vector<in_eT>::const_iterator in_end = in.end();
699 
700  typename Col<out_eT>::iterator out_begin = out.begin();
701  typename Col<out_eT>::iterator out_end = out.end();
702 
703  typename std::vector<in_eT>::const_iterator in_it;
704  typename Col<out_eT>::iterator out_it;
705 
706  for(in_it = in_begin, out_it = out_begin; (in_it != in_end) && (out_it != out_end); ++in_it, ++out_it)
707  {
708  (*out_it) = out_eT(*in_it);
709  }
710 
711  return out;
712  }
713 
714 
715 
716 template<typename out_eT>
717 template<typename in_eT>
718 inline
720 conv_to< Col<out_eT> >::from(const std::vector<in_eT>& in, const typename arma_cx_only<in_eT>::result* junk)
721  {
723 
724  arma_ignore(junk);
725 
726  Col<out_eT> out( in.size() );
727 
728  typename std::vector<in_eT>::const_iterator in_begin = in.begin();
729  typename std::vector<in_eT>::const_iterator in_end = in.end();
730 
731  typename Col<out_eT>::iterator out_begin = out.begin();
732  typename Col<out_eT>::iterator out_end = out.end();
733 
734  typename std::vector<in_eT>::const_iterator in_it;
735  typename Col<out_eT>::iterator out_it;
736 
737  for(in_it = in_begin, out_it = out_begin; (in_it != in_end) && (out_it != out_end); ++in_it, ++out_it)
738  {
739  out_eT& out_elem = (*out_it);
740  const in_eT& in_elem = (*in_it);
741 
742  arrayops::convert_cx_scalar(out_elem, in_elem);
743  }
744 
745  return out;
746  }
747 
748 
749 
750 template<typename out_eT>
751 template<typename in_eT>
752 inline
755  {
757 
758  arma_ignore(junk);
759 
760  const bool is_vec = ( (in.rows() == 1) || (in.cols() == 1) );
761 
762  arma_debug_check( (is_vec == false), "conv_to(): given object can't be interpreted as a vector" );
763 
764  Col<out_eT> out(in.rows() * in.cols());
765 
766  arrayops::convert( out.memptr(), in._data(), out.n_elem );
767 
768  return out;
769  }
770 
771 
772 
773 template<typename out_eT>
774 template<typename in_eT>
775 inline
778  {
780 
781  arma_ignore(junk);
782 
783  //const bool is_vec = ( (in.rows() == 1) || (in.cols() == 1) );
784 
785  Col<out_eT> out(in.rows() * in.cols());
786 
787  arrayops::convert_cx( out.memptr(), in._data(), out.n_elem );
788 
789  return out;
790  }
791 
792 
793 
794 template<typename out_eT>
795 template<typename in_eT>
796 inline
799  {
801 
802  arma_ignore(junk);
803 
804  Col<out_eT> out( in.length() );
805 
806  arrayops::convert( out.memptr(), in._data(), out.n_elem );
807 
808  return out;
809  }
810 
811 
812 
813 template<typename out_eT>
814 template<typename in_eT>
815 inline
818  {
820 
821  arma_ignore(junk);
822 
823  Col<out_eT> out( in.length() );
824 
825  arrayops::convert_cx( out.memptr(), in._data(), out.n_elem );
826 
827  return out;
828  }
829 
830 
831 
833 template<typename out_eT>
834 class conv_to< Cube<out_eT> >
835  {
836  public:
837 
838  template<typename in_eT, typename T1>
839  inline static Cube<out_eT> from(const BaseCube<in_eT, T1>& in, const typename arma_not_cx<in_eT>::result* junk = 0);
840 
841  template<typename in_eT, typename T1>
842  inline static Cube<out_eT> from(const BaseCube<in_eT, T1>& in, const typename arma_cx_only<in_eT>::result* junk = 0);
843  };
844 
845 
846 
847 template<typename out_eT>
848 template<typename in_eT, typename T1>
849 inline
852  {
854 
855  arma_ignore(junk);
856 
857  const unwrap_cube<T1> tmp( in.get_ref() );
858  const Cube<in_eT>& X = tmp.M;
859 
860  Cube<out_eT> out(X.n_rows, X.n_cols, X.n_slices);
861 
862  arrayops::convert( out.memptr(), X.memptr(), out.n_elem );
863 
864  return out;
865  }
866 
867 
868 
869 template<typename out_eT>
870 template<typename in_eT, typename T1>
871 inline
874  {
876 
877  arma_ignore(junk);
878 
879  const unwrap_cube<T1> tmp( in.get_ref() );
880  const Cube<in_eT>& X = tmp.M;
881 
882  Cube<out_eT> out(X.n_rows, X.n_cols, X.n_slices);
883 
884  arrayops::convert_cx( out.memptr(), X.memptr(), out.n_elem );
885 
886  return out;
887  }
888 
889 
890 
892 template<typename out_eT>
893 class conv_to< std::vector<out_eT> >
894  {
895  public:
896 
897  template<typename in_eT, typename T1>
898  inline static std::vector<out_eT> from(const Base<in_eT, T1>& in, const typename arma_not_cx<in_eT>::result* junk = 0);
899 
900  template<typename in_eT, typename T1>
901  inline static std::vector<out_eT> from(const Base<in_eT, T1>& in, const typename arma_cx_only<in_eT>::result* junk = 0);
902  };
903 
904 
905 
906 template<typename out_eT>
907 template<typename in_eT, typename T1>
908 inline
909 std::vector<out_eT>
911  {
913 
914  arma_ignore(junk);
915 
916  const unwrap<T1> tmp(in.get_ref());
917  const Mat<in_eT>& X = tmp.M;
918 
919  arma_debug_check( (X.is_vec() == false), "conv_to(): given object can't be interpreted as a vector" );
920 
921  std::vector<out_eT> out(X.n_elem);
922 
923  typename Mat<in_eT>::const_iterator X_begin = X.begin();
924  typename Mat<in_eT>::const_iterator X_end = X.end();
925 
926  typename std::vector<out_eT>::iterator out_begin = out.begin();
927  typename std::vector<out_eT>::iterator out_end = out.end();
928 
929  typename Mat<in_eT>::const_iterator X_it;
930  typename std::vector<out_eT>::iterator out_it;
931 
932  for(X_it = X_begin, out_it = out_begin; (X_it != X_end) && (out_it != out_end); ++X_it, ++out_it)
933  {
934  (*out_it) = out_eT(*X_it);
935  }
936 
937  return out;
938  }
939 
940 
941 
942 template<typename out_eT>
943 template<typename in_eT, typename T1>
944 inline
945 std::vector<out_eT>
947  {
949 
950  arma_ignore(junk);
951 
952  const unwrap<T1> tmp(in.get_ref());
953  const Mat<in_eT>& X = tmp.M;
954 
955  arma_debug_check( (X.is_vec() == false), "conv_to(): given object can't be interpreted as a vector" );
956 
957  std::vector<out_eT> out(X.n_elem);
958 
959  typename Mat<in_eT>::const_iterator X_begin = X.begin();
960  typename Mat<in_eT>::const_iterator X_end = X.end();
961 
962  typename std::vector<out_eT>::iterator out_begin = out.begin();
963  typename std::vector<out_eT>::iterator out_end = out.end();
964 
965  typename Mat<in_eT>::const_iterator X_it;
966  typename std::vector<out_eT>::iterator out_it;
967 
968  for(X_it = X_begin, out_it = out_begin; (X_it != X_end) && (out_it != out_end); ++X_it, ++out_it)
969  {
970  out_eT& out_elem = (*out_it);
971  const in_eT& X_elem = (*X_it);
972 
973  arrayops::convert_cx_scalar(out_elem, X_elem);
974  }
975 
976  return out;
977  }
978 
979 
980 
982 template<typename out_eT>
983 class conv_to< itpp::Mat<out_eT> >
984  {
985  public:
986 
987  template<typename in_eT, typename T1>
988  inline static itpp::Mat<out_eT> from(const Base<in_eT, T1>& in, const typename arma_not_cx<in_eT>::result* junk = 0);
989 
990  template<typename in_eT, typename T1>
991  inline static itpp::Mat<out_eT> from(const Base<in_eT, T1>& in, const typename arma_cx_only<in_eT>::result* junk = 0);
992  };
993 
994 
995 
996 template<typename out_eT>
997 template<typename in_eT, typename T1>
998 inline
1001  {
1003 
1004  arma_ignore(junk);
1005 
1006  const unwrap<T1> tmp( in.get_ref() );
1007  const Mat<in_eT>& X = tmp.M;
1008 
1009  itpp::Mat<out_eT> out(X.n_rows, X.n_cols);
1010 
1011  arrayops::convert( out._data(), X.memptr(), X.n_elem );
1012 
1013  return out;
1014  }
1015 
1016 
1017 
1018 template<typename out_eT>
1019 template<typename in_eT, typename T1>
1020 inline
1023  {
1025 
1026  arma_ignore(junk);
1027 
1028  const unwrap<T1> tmp( in.get_ref() );
1029  const Mat<in_eT>& X = tmp.M;
1030 
1031  itpp::Mat<out_eT> out(X.n_rows, X.n_cols);
1032 
1033  arrayops::convert_cx( out._data(), X.memptr(), X.n_elem );
1034 
1035  return out;
1036  }
1037 
1038 
1039 
1040 
1042 template<typename out_eT>
1043 class conv_to< itpp::Vec<out_eT> >
1044  {
1045  public:
1046 
1047  template<typename in_eT, typename T1>
1048  inline static itpp::Vec<out_eT> from(const Base<in_eT, T1>& in, const typename arma_not_cx<in_eT>::result* junk = 0);
1049 
1050  template<typename in_eT, typename T1>
1051  inline static itpp::Vec<out_eT> from(const Base<in_eT, T1>& in, const typename arma_cx_only<in_eT>::result* junk = 0);
1052  };
1053 
1054 
1055 
1056 template<typename out_eT>
1057 template<typename in_eT, typename T1>
1058 inline
1061  {
1063 
1064  arma_ignore(junk);
1065 
1066  const unwrap<T1> tmp( in.get_ref() );
1067  const Mat<in_eT>& X = tmp.M;
1068 
1069  arma_debug_check( (X.is_vec() == false), "conv_to(): given object can't be interpreted as a vector" );
1070 
1071  itpp::Vec<out_eT> out(X.n_elem);
1072 
1073  arrayops::convert( out._data(), X.memptr(), X.n_elem );
1074 
1075  return out;
1076  }
1077 
1078 
1079 
1080 template<typename out_eT>
1081 template<typename in_eT, typename T1>
1082 inline
1085  {
1087 
1088  arma_ignore(junk);
1089 
1090  const unwrap<T1> tmp( in.get_ref() );
1091  const Mat<in_eT>& X = tmp.M;
1092 
1093  itpp::Vec<out_eT> out(X.n_elem);
1094 
1095  arrayops::convert_cx( out._data(), X.memptr(), X.n_elem );
1096 
1097  return out;
1098  }
1099 
1100 
1101 
iterator end()
Definition: Mat_meat.hpp:5231
arma_inline arma_warn_unused eT * memptr()
returns a pointer to array of eTs used by the matrix
Definition: Mat_meat.hpp:4024
static out_eT from(const Base< in_eT, T1 > &in, const typename arma_not_cx< in_eT >::result *junk=0)
Definition: fn_conv_to.hpp:45
arma_inline const derived & get_ref() const
Definition: Base_meat.hpp:22
iterator begin()
Definition: Mat_meat.hpp:5207
arma_hot static arma_inline void convert_cx_scalar(out_eT &out, const in_eT &in, const typename arma_not_cx< out_eT >::result *junk1=0, const typename arma_not_cx< in_eT >::result *junk2=0)
const eT * _data() const
Definition: itpp_wrap.hpp:44
dummy itpp::Mat class, to prevent compilation errors
Definition: itpp_wrap.hpp:30
const uword n_elem
number of elements in the matrix (read-only)
Definition: Mat_bones.hpp:31
#define arma_type_check(condition)
Class for column vectors (matrices with only one column)
Definition: Col_bones.hpp:20
arma_inline arma_warn_unused eT * memptr()
returns a pointer to array of eTs used by the cube
Definition: Cube_meat.hpp:2260
#define arma_debug_check
Definition: debug.hpp:1084
static arma_hot void convert_cx(out_eT *dest, const in_eT *src, const uword n_elem)
int rows() const
Definition: itpp_wrap.hpp:41
#define arma_ignore(variable)
Dense cube class.
Definition: Cube_bones.hpp:30
int cols() const
Definition: itpp_wrap.hpp:42
static arma_hot void convert(out_eT *dest, const in_eT *src, const uword n_elem)
Class for row vectors (matrices with only one row)
#define arma_extra_debug_sigprint
Definition: debug.hpp:1116
const eT * const_iterator
Definition: Mat_bones.hpp:373
Analog of the Base class, intended for cubes.
int length() const
Definition: itpp_wrap.hpp:63
const uword n_elem
number of elements in the cube (read-only)
Definition: Cube_bones.hpp:41
Dense matrix class.
dummy itpp::Vec class, to prevent compilation errors
Definition: itpp_wrap.hpp:51
arma_inline const derived & get_ref() const
const eT * _data() const
Definition: itpp_wrap.hpp:64
eT * iterator
Definition: Mat_bones.hpp:372


armadillo_matrix
Author(s):
autogenerated on Fri Apr 16 2021 02:31:57