Mercurial > hg > segmenter-vamp-plugin
comparison armadillo-3.900.4/include/armadillo_bits/fn_conv_to.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-2012 NICTA (www.nicta.com.au) | |
2 // Copyright (C) 2008-2012 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 fn_conv_to | |
10 //! @{ | |
11 | |
12 | |
13 | |
14 //! conversion from Armadillo Base and BaseCube objects to scalars | |
15 //! (kept only for compatibility with old code; use as_scalar() instead for Base objects like Mat) | |
16 template<typename out_eT> | |
17 class conv_to | |
18 { | |
19 public: | |
20 | |
21 template<typename in_eT, typename T1> | |
22 inline static out_eT from(const Base<in_eT, T1>& in, const typename arma_not_cx<in_eT>::result* junk = 0); | |
23 | |
24 template<typename in_eT, typename T1> | |
25 inline static out_eT from(const Base<in_eT, T1>& in, const typename arma_cx_only<in_eT>::result* junk = 0); | |
26 | |
27 template<typename in_eT, typename T1> | |
28 inline static out_eT from(const BaseCube<in_eT, T1>& in, const typename arma_not_cx<in_eT>::result* junk = 0); | |
29 | |
30 template<typename in_eT, typename T1> | |
31 inline static out_eT from(const BaseCube<in_eT, T1>& in, const typename arma_cx_only<in_eT>::result* junk = 0); | |
32 }; | |
33 | |
34 | |
35 | |
36 template<typename out_eT> | |
37 template<typename in_eT, typename T1> | |
38 inline | |
39 out_eT | |
40 conv_to<out_eT>::from(const Base<in_eT, T1>& in, const typename arma_not_cx<in_eT>::result* junk) | |
41 { | |
42 arma_extra_debug_sigprint(); | |
43 arma_ignore(junk); | |
44 | |
45 arma_type_check(( is_supported_elem_type<out_eT>::value == false )); | |
46 | |
47 const unwrap<T1> tmp(in.get_ref()); | |
48 const Mat<in_eT>& X = tmp.M; | |
49 | |
50 arma_debug_check( (X.n_elem != 1), "conv_to(): given object doesn't have exactly one element" ); | |
51 | |
52 return out_eT(X.mem[0]); | |
53 } | |
54 | |
55 | |
56 | |
57 template<typename out_eT> | |
58 template<typename in_eT, typename T1> | |
59 inline | |
60 out_eT | |
61 conv_to<out_eT>::from(const Base<in_eT, T1>& in, const typename arma_cx_only<in_eT>::result* junk) | |
62 { | |
63 arma_extra_debug_sigprint(); | |
64 arma_ignore(junk); | |
65 | |
66 arma_type_check(( is_supported_elem_type<out_eT>::value == false )); | |
67 | |
68 const unwrap<T1> tmp(in.get_ref()); | |
69 const Mat<in_eT>& X = tmp.M; | |
70 | |
71 arma_debug_check( (X.n_elem != 1), "conv_to(): given object doesn't have exactly one element" ); | |
72 | |
73 out_eT out; | |
74 | |
75 arrayops::convert_cx_scalar(out, X.mem[0]); | |
76 | |
77 return out; | |
78 } | |
79 | |
80 | |
81 | |
82 template<typename out_eT> | |
83 template<typename in_eT, typename T1> | |
84 inline | |
85 out_eT | |
86 conv_to<out_eT>::from(const BaseCube<in_eT, T1>& in, const typename arma_not_cx<in_eT>::result* junk) | |
87 { | |
88 arma_extra_debug_sigprint(); | |
89 arma_ignore(junk); | |
90 | |
91 arma_type_check(( is_supported_elem_type<out_eT>::value == false )); | |
92 | |
93 const unwrap_cube<T1> tmp(in.get_ref()); | |
94 const Cube<in_eT>& X = tmp.M; | |
95 | |
96 arma_debug_check( (X.n_elem != 1), "conv_to(): given object doesn't have exactly one element" ); | |
97 | |
98 return out_eT(X.mem[0]); | |
99 } | |
100 | |
101 | |
102 | |
103 template<typename out_eT> | |
104 template<typename in_eT, typename T1> | |
105 inline | |
106 out_eT | |
107 conv_to<out_eT>::from(const BaseCube<in_eT, T1>& in, const typename arma_cx_only<in_eT>::result* junk) | |
108 { | |
109 arma_extra_debug_sigprint(); | |
110 arma_ignore(junk); | |
111 | |
112 arma_type_check(( is_supported_elem_type<out_eT>::value == false )); | |
113 | |
114 const unwrap_cube<T1> tmp(in.get_ref()); | |
115 const Cube<in_eT>& X = tmp.M; | |
116 | |
117 arma_debug_check( (X.n_elem != 1), "conv_to(): given object doesn't have exactly one element" ); | |
118 | |
119 out_eT out; | |
120 | |
121 arrayops::convert_cx_scalar(out, X.mem[0]); | |
122 | |
123 return out; | |
124 } | |
125 | |
126 | |
127 | |
128 //! conversion to Armadillo matrices from Armadillo Base objects, as well as from std::vector | |
129 template<typename out_eT> | |
130 class conv_to< Mat<out_eT> > | |
131 { | |
132 public: | |
133 | |
134 template<typename in_eT, typename T1> | |
135 inline static Mat<out_eT> from(const Base<in_eT, T1>& in, const typename arma_not_cx<in_eT>::result* junk = 0); | |
136 | |
137 template<typename in_eT, typename T1> | |
138 inline static Mat<out_eT> from(const Base<in_eT, T1>& in, const typename arma_cx_only<in_eT>::result* junk = 0); | |
139 | |
140 | |
141 | |
142 template<typename in_eT> | |
143 inline static Mat<out_eT> from(const std::vector<in_eT>& in, const typename arma_not_cx<in_eT>::result* junk = 0); | |
144 | |
145 template<typename in_eT> | |
146 inline static Mat<out_eT> from(const std::vector<in_eT>& in, const typename arma_cx_only<in_eT>::result* junk = 0); | |
147 }; | |
148 | |
149 | |
150 | |
151 template<typename out_eT> | |
152 template<typename in_eT, typename T1> | |
153 inline | |
154 Mat<out_eT> | |
155 conv_to< Mat<out_eT> >::from(const Base<in_eT, T1>& in, const typename arma_not_cx<in_eT>::result* junk) | |
156 { | |
157 arma_extra_debug_sigprint(); | |
158 arma_ignore(junk); | |
159 | |
160 const unwrap<T1> tmp(in.get_ref()); | |
161 const Mat<in_eT>& X = tmp.M; | |
162 | |
163 Mat<out_eT> out(X.n_rows, X.n_cols); | |
164 | |
165 arrayops::convert( out.memptr(), X.memptr(), out.n_elem ); | |
166 | |
167 return out; | |
168 } | |
169 | |
170 | |
171 | |
172 template<typename out_eT> | |
173 template<typename in_eT, typename T1> | |
174 inline | |
175 Mat<out_eT> | |
176 conv_to< Mat<out_eT> >::from(const Base<in_eT, T1>& in, const typename arma_cx_only<in_eT>::result* junk) | |
177 { | |
178 arma_extra_debug_sigprint(); | |
179 arma_ignore(junk); | |
180 | |
181 const unwrap<T1> tmp(in.get_ref()); | |
182 const Mat<in_eT>& X = tmp.M; | |
183 | |
184 Mat<out_eT> out(X.n_rows, X.n_cols); | |
185 | |
186 arrayops::convert_cx( out.memptr(), X.memptr(), out.n_elem ); | |
187 | |
188 return out; | |
189 } | |
190 | |
191 | |
192 | |
193 template<typename out_eT> | |
194 template<typename in_eT> | |
195 inline | |
196 Mat<out_eT> | |
197 conv_to< Mat<out_eT> >::from(const std::vector<in_eT>& in, const typename arma_not_cx<in_eT>::result* junk) | |
198 { | |
199 arma_extra_debug_sigprint(); | |
200 arma_ignore(junk); | |
201 | |
202 const uword N = uword( in.size() ); | |
203 | |
204 Mat<out_eT> out(N, 1); | |
205 | |
206 if(N > 0) | |
207 { | |
208 out_eT* out_mem = out.memptr(); | |
209 const in_eT* in_mem = &(in[0]); | |
210 | |
211 for(uword i=0; i<N; ++i) | |
212 { | |
213 out_mem[i] = out_eT( in_mem[i] ); | |
214 } | |
215 } | |
216 | |
217 return out; | |
218 } | |
219 | |
220 | |
221 | |
222 template<typename out_eT> | |
223 template<typename in_eT> | |
224 inline | |
225 Mat<out_eT> | |
226 conv_to< Mat<out_eT> >::from(const std::vector<in_eT>& in, const typename arma_cx_only<in_eT>::result* junk) | |
227 { | |
228 arma_extra_debug_sigprint(); | |
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_eT& out_elem = (*out_it); | |
245 const in_eT& in_elem = (*in_it); | |
246 | |
247 arrayops::convert_cx_scalar(out_elem, in_elem); | |
248 } | |
249 | |
250 return out; | |
251 } | |
252 | |
253 | |
254 | |
255 //! conversion to Armadillo row vectors from Armadillo Base objects, as well as from std::vector | |
256 template<typename out_eT> | |
257 class conv_to< Row<out_eT> > | |
258 { | |
259 public: | |
260 | |
261 template<typename in_eT, typename T1> | |
262 inline static Row<out_eT> from(const Base<in_eT, T1>& in, const typename arma_not_cx<in_eT>::result* junk = 0); | |
263 | |
264 template<typename in_eT, typename T1> | |
265 inline static Row<out_eT> from(const Base<in_eT, T1>& in, const typename arma_cx_only<in_eT>::result* junk = 0); | |
266 | |
267 | |
268 | |
269 template<typename in_eT> | |
270 inline static Row<out_eT> from(const std::vector<in_eT>& in, const typename arma_not_cx<in_eT>::result* junk = 0); | |
271 | |
272 template<typename in_eT> | |
273 inline static Row<out_eT> from(const std::vector<in_eT>& in, const typename arma_cx_only<in_eT>::result* junk = 0); | |
274 }; | |
275 | |
276 | |
277 | |
278 template<typename out_eT> | |
279 template<typename in_eT, typename T1> | |
280 inline | |
281 Row<out_eT> | |
282 conv_to< Row<out_eT> >::from(const Base<in_eT, T1>& in, const typename arma_not_cx<in_eT>::result* junk) | |
283 { | |
284 arma_extra_debug_sigprint(); | |
285 arma_ignore(junk); | |
286 | |
287 const unwrap<T1> tmp(in.get_ref()); | |
288 const Mat<in_eT>& X = tmp.M; | |
289 | |
290 arma_debug_check( ( (X.is_vec() == false) && (X.is_empty() == false) ), "conv_to(): given object can't be interpreted as a vector" ); | |
291 | |
292 Row<out_eT> out(X.n_elem); | |
293 | |
294 arrayops::convert( out.memptr(), X.memptr(), out.n_elem ); | |
295 | |
296 return out; | |
297 } | |
298 | |
299 | |
300 | |
301 template<typename out_eT> | |
302 template<typename in_eT, typename T1> | |
303 inline | |
304 Row<out_eT> | |
305 conv_to< Row<out_eT> >::from(const Base<in_eT, T1>& in, const typename arma_cx_only<in_eT>::result* junk) | |
306 { | |
307 arma_extra_debug_sigprint(); | |
308 arma_ignore(junk); | |
309 | |
310 const unwrap<T1> tmp(in.get_ref()); | |
311 const Mat<in_eT>& X = tmp.M; | |
312 | |
313 arma_debug_check( ( (X.is_vec() == false) && (X.is_empty() == false) ), "conv_to(): given object can't be interpreted as a vector" ); | |
314 | |
315 Row<out_eT> out(X.n_rows, X.n_cols); | |
316 | |
317 arrayops::convert_cx( out.memptr(), X.memptr(), out.n_elem ); | |
318 | |
319 return out; | |
320 } | |
321 | |
322 | |
323 | |
324 template<typename out_eT> | |
325 template<typename in_eT> | |
326 inline | |
327 Row<out_eT> | |
328 conv_to< Row<out_eT> >::from(const std::vector<in_eT>& in, const typename arma_not_cx<in_eT>::result* junk) | |
329 { | |
330 arma_extra_debug_sigprint(); | |
331 arma_ignore(junk); | |
332 | |
333 const uword N = uword( in.size() ); | |
334 | |
335 Row<out_eT> out(N); | |
336 | |
337 if(N > 0) | |
338 { | |
339 out_eT* out_mem = out.memptr(); | |
340 const in_eT* in_mem = &(in[0]); | |
341 | |
342 for(uword i=0; i<N; ++i) | |
343 { | |
344 out_mem[i] = out_eT( in_mem[i] ); | |
345 } | |
346 } | |
347 | |
348 return out; | |
349 } | |
350 | |
351 | |
352 | |
353 template<typename out_eT> | |
354 template<typename in_eT> | |
355 inline | |
356 Row<out_eT> | |
357 conv_to< Row<out_eT> >::from(const std::vector<in_eT>& in, const typename arma_cx_only<in_eT>::result* junk) | |
358 { | |
359 arma_extra_debug_sigprint(); | |
360 arma_ignore(junk); | |
361 | |
362 Row<out_eT> out( in.size() ); | |
363 | |
364 typename std::vector<in_eT>::const_iterator in_begin = in.begin(); | |
365 typename std::vector<in_eT>::const_iterator in_end = in.end(); | |
366 | |
367 typename Row<out_eT>::iterator out_begin = out.begin(); | |
368 typename Row<out_eT>::iterator out_end = out.end(); | |
369 | |
370 typename std::vector<in_eT>::const_iterator in_it; | |
371 typename Row<out_eT>::iterator out_it; | |
372 | |
373 for(in_it = in_begin, out_it = out_begin; (in_it != in_end) && (out_it != out_end); ++in_it, ++out_it) | |
374 { | |
375 out_eT& out_elem = (*out_it); | |
376 const in_eT& in_elem = (*in_it); | |
377 | |
378 arrayops::convert_cx_scalar(out_elem, in_elem); | |
379 } | |
380 | |
381 return out; | |
382 } | |
383 | |
384 | |
385 | |
386 //! conversion to Armadillo column vectors from Armadillo Base objects, as well as from std::vector | |
387 template<typename out_eT> | |
388 class conv_to< Col<out_eT> > | |
389 { | |
390 public: | |
391 | |
392 template<typename in_eT, typename T1> | |
393 inline static Col<out_eT> from(const Base<in_eT, T1>& in, const typename arma_not_cx<in_eT>::result* junk = 0); | |
394 | |
395 template<typename in_eT, typename T1> | |
396 inline static Col<out_eT> from(const Base<in_eT, T1>& in, const typename arma_cx_only<in_eT>::result* junk = 0); | |
397 | |
398 | |
399 | |
400 template<typename in_eT> | |
401 inline static Col<out_eT> from(const std::vector<in_eT>& in, const typename arma_not_cx<in_eT>::result* junk = 0); | |
402 | |
403 template<typename in_eT> | |
404 inline static Col<out_eT> from(const std::vector<in_eT>& in, const typename arma_cx_only<in_eT>::result* junk = 0); | |
405 }; | |
406 | |
407 | |
408 | |
409 template<typename out_eT> | |
410 template<typename in_eT, typename T1> | |
411 inline | |
412 Col<out_eT> | |
413 conv_to< Col<out_eT> >::from(const Base<in_eT, T1>& in, const typename arma_not_cx<in_eT>::result* junk) | |
414 { | |
415 arma_extra_debug_sigprint(); | |
416 arma_ignore(junk); | |
417 | |
418 const unwrap<T1> tmp(in.get_ref()); | |
419 const Mat<in_eT>& X = tmp.M; | |
420 | |
421 arma_debug_check( ( (X.is_vec() == false) && (X.is_empty() == false) ), "conv_to(): given object can't be interpreted as a vector" ); | |
422 | |
423 Col<out_eT> out(X.n_elem); | |
424 | |
425 arrayops::convert( out.memptr(), X.memptr(), out.n_elem ); | |
426 | |
427 return out; | |
428 } | |
429 | |
430 | |
431 | |
432 template<typename out_eT> | |
433 template<typename in_eT, typename T1> | |
434 inline | |
435 Col<out_eT> | |
436 conv_to< Col<out_eT> >::from(const Base<in_eT, T1>& in, const typename arma_cx_only<in_eT>::result* junk) | |
437 { | |
438 arma_extra_debug_sigprint(); | |
439 arma_ignore(junk); | |
440 | |
441 const unwrap<T1> tmp(in.get_ref()); | |
442 const Mat<in_eT>& X = tmp.M; | |
443 | |
444 arma_debug_check( ( (X.is_vec() == false) && (X.is_empty() == false) ), "conv_to(): given object can't be interpreted as a vector" ); | |
445 | |
446 Col<out_eT> out(X.n_rows, X.n_cols); | |
447 | |
448 arrayops::convert_cx( out.memptr(), X.memptr(), out.n_elem ); | |
449 | |
450 return out; | |
451 } | |
452 | |
453 | |
454 | |
455 template<typename out_eT> | |
456 template<typename in_eT> | |
457 inline | |
458 Col<out_eT> | |
459 conv_to< Col<out_eT> >::from(const std::vector<in_eT>& in, const typename arma_not_cx<in_eT>::result* junk) | |
460 { | |
461 arma_extra_debug_sigprint(); | |
462 arma_ignore(junk); | |
463 | |
464 const uword N = uword( in.size() ); | |
465 | |
466 Col<out_eT> out(N); | |
467 | |
468 if(N > 0) | |
469 { | |
470 out_eT* out_mem = out.memptr(); | |
471 const in_eT* in_mem = &(in[0]); | |
472 | |
473 for(uword i=0; i<N; ++i) | |
474 { | |
475 out_mem[i] = out_eT( in_mem[i] ); | |
476 } | |
477 } | |
478 | |
479 return out; | |
480 } | |
481 | |
482 | |
483 | |
484 template<typename out_eT> | |
485 template<typename in_eT> | |
486 inline | |
487 Col<out_eT> | |
488 conv_to< Col<out_eT> >::from(const std::vector<in_eT>& in, const typename arma_cx_only<in_eT>::result* junk) | |
489 { | |
490 arma_extra_debug_sigprint(); | |
491 arma_ignore(junk); | |
492 | |
493 Col<out_eT> out( in.size() ); | |
494 | |
495 typename std::vector<in_eT>::const_iterator in_begin = in.begin(); | |
496 typename std::vector<in_eT>::const_iterator in_end = in.end(); | |
497 | |
498 typename Col<out_eT>::iterator out_begin = out.begin(); | |
499 typename Col<out_eT>::iterator out_end = out.end(); | |
500 | |
501 typename std::vector<in_eT>::const_iterator in_it; | |
502 typename Col<out_eT>::iterator out_it; | |
503 | |
504 for(in_it = in_begin, out_it = out_begin; (in_it != in_end) && (out_it != out_end); ++in_it, ++out_it) | |
505 { | |
506 out_eT& out_elem = (*out_it); | |
507 const in_eT& in_elem = (*in_it); | |
508 | |
509 arrayops::convert_cx_scalar(out_elem, in_elem); | |
510 } | |
511 | |
512 return out; | |
513 } | |
514 | |
515 | |
516 | |
517 //! conversion to Armadillo cubes from Armadillo BaseCube objects | |
518 template<typename out_eT> | |
519 class conv_to< Cube<out_eT> > | |
520 { | |
521 public: | |
522 | |
523 template<typename in_eT, typename T1> | |
524 inline static Cube<out_eT> from(const BaseCube<in_eT, T1>& in, const typename arma_not_cx<in_eT>::result* junk = 0); | |
525 | |
526 template<typename in_eT, typename T1> | |
527 inline static Cube<out_eT> from(const BaseCube<in_eT, T1>& in, const typename arma_cx_only<in_eT>::result* junk = 0); | |
528 }; | |
529 | |
530 | |
531 | |
532 template<typename out_eT> | |
533 template<typename in_eT, typename T1> | |
534 inline | |
535 Cube<out_eT> | |
536 conv_to< Cube<out_eT> >::from(const BaseCube<in_eT, T1>& in, const typename arma_not_cx<in_eT>::result* junk) | |
537 { | |
538 arma_extra_debug_sigprint(); | |
539 arma_ignore(junk); | |
540 | |
541 const unwrap_cube<T1> tmp( in.get_ref() ); | |
542 const Cube<in_eT>& X = tmp.M; | |
543 | |
544 Cube<out_eT> out(X.n_rows, X.n_cols, X.n_slices); | |
545 | |
546 arrayops::convert( out.memptr(), X.memptr(), out.n_elem ); | |
547 | |
548 return out; | |
549 } | |
550 | |
551 | |
552 | |
553 template<typename out_eT> | |
554 template<typename in_eT, typename T1> | |
555 inline | |
556 Cube<out_eT> | |
557 conv_to< Cube<out_eT> >::from(const BaseCube<in_eT, T1>& in, const typename arma_cx_only<in_eT>::result* junk) | |
558 { | |
559 arma_extra_debug_sigprint(); | |
560 arma_ignore(junk); | |
561 | |
562 const unwrap_cube<T1> tmp( in.get_ref() ); | |
563 const Cube<in_eT>& X = tmp.M; | |
564 | |
565 Cube<out_eT> out(X.n_rows, X.n_cols, X.n_slices); | |
566 | |
567 arrayops::convert_cx( out.memptr(), X.memptr(), out.n_elem ); | |
568 | |
569 return out; | |
570 } | |
571 | |
572 | |
573 | |
574 //! conversion to std::vector from Armadillo Base objects | |
575 template<typename out_eT> | |
576 class conv_to< std::vector<out_eT> > | |
577 { | |
578 public: | |
579 | |
580 template<typename in_eT, typename T1> | |
581 inline static std::vector<out_eT> from(const Base<in_eT, T1>& in, const typename arma_not_cx<in_eT>::result* junk = 0); | |
582 | |
583 template<typename in_eT, typename T1> | |
584 inline static std::vector<out_eT> from(const Base<in_eT, T1>& in, const typename arma_cx_only<in_eT>::result* junk = 0); | |
585 }; | |
586 | |
587 | |
588 | |
589 template<typename out_eT> | |
590 template<typename in_eT, typename T1> | |
591 inline | |
592 std::vector<out_eT> | |
593 conv_to< std::vector<out_eT> >::from(const Base<in_eT, T1>& in, const typename arma_not_cx<in_eT>::result* junk) | |
594 { | |
595 arma_extra_debug_sigprint(); | |
596 arma_ignore(junk); | |
597 | |
598 const unwrap<T1> tmp(in.get_ref()); | |
599 const Mat<in_eT>& X = tmp.M; | |
600 | |
601 arma_debug_check( ( (X.is_vec() == false) && (X.is_empty() == false) ), "conv_to(): given object can't be interpreted as a vector" ); | |
602 | |
603 const uword N = X.n_elem; | |
604 | |
605 std::vector<out_eT> out(N); | |
606 | |
607 if(N > 0) | |
608 { | |
609 out_eT* out_mem = &(out[0]); | |
610 const in_eT* X_mem = X.memptr(); | |
611 | |
612 for(uword i=0; i<N; ++i) | |
613 { | |
614 out_mem[i] = out_eT( X_mem[i] ); | |
615 } | |
616 } | |
617 | |
618 return out; | |
619 } | |
620 | |
621 | |
622 | |
623 template<typename out_eT> | |
624 template<typename in_eT, typename T1> | |
625 inline | |
626 std::vector<out_eT> | |
627 conv_to< std::vector<out_eT> >::from(const Base<in_eT, T1>& in, const typename arma_cx_only<in_eT>::result* junk) | |
628 { | |
629 arma_extra_debug_sigprint(); | |
630 arma_ignore(junk); | |
631 | |
632 const unwrap<T1> tmp(in.get_ref()); | |
633 const Mat<in_eT>& X = tmp.M; | |
634 | |
635 arma_debug_check( ( (X.is_vec() == false) && (X.is_empty() == false) ), "conv_to(): given object can't be interpreted as a vector" ); | |
636 | |
637 std::vector<out_eT> out(X.n_elem); | |
638 | |
639 typename Mat<in_eT>::const_iterator X_begin = X.begin(); | |
640 typename Mat<in_eT>::const_iterator X_end = X.end(); | |
641 | |
642 typename std::vector<out_eT>::iterator out_begin = out.begin(); | |
643 typename std::vector<out_eT>::iterator out_end = out.end(); | |
644 | |
645 typename Mat<in_eT>::const_iterator X_it; | |
646 typename std::vector<out_eT>::iterator out_it; | |
647 | |
648 for(X_it = X_begin, out_it = out_begin; (X_it != X_end) && (out_it != out_end); ++X_it, ++out_it) | |
649 { | |
650 out_eT& out_elem = (*out_it); | |
651 const in_eT& X_elem = (*X_it); | |
652 | |
653 arrayops::convert_cx_scalar(out_elem, X_elem); | |
654 } | |
655 | |
656 return out; | |
657 } | |
658 | |
659 | |
660 | |
661 //! @} |