00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 template<typename oT>
00023 inline
00024 field<oT>::~field()
00025 {
00026 arma_extra_debug_sigprint_this(this);
00027
00028 delete_objects();
00029
00030 if(n_elem > sizeof(mem_local)/sizeof(oT*) )
00031 {
00032 delete [] mem;
00033 }
00034
00035 if(arma_config::debug == true)
00036 {
00037
00038 access::rw(n_rows) = 0;
00039 access::rw(n_cols) = 0;
00040 access::rw(n_elem) = 0;
00041 mem = 0;
00042 }
00043 }
00044
00045
00046
00047 template<typename oT>
00048 inline
00049 field<oT>::field()
00050 : n_rows(0)
00051 , n_cols(0)
00052 , n_elem(0)
00053 , mem(0)
00054 {
00055 arma_extra_debug_sigprint_this(this);
00056 }
00057
00058
00059
00060
00061 template<typename oT>
00062 inline
00063 field<oT>::field(const field& x)
00064 : n_rows(0)
00065 , n_cols(0)
00066 , n_elem(0)
00067 , mem(0)
00068 {
00069 arma_extra_debug_sigprint(arma_boost::format("this = %x x = %x") % this % &x);
00070
00071 init(x);
00072 }
00073
00074
00075
00076
00077 template<typename oT>
00078 inline
00079 const field<oT>&
00080 field<oT>::operator=(const field& x)
00081 {
00082 arma_extra_debug_sigprint();
00083
00084 init(x);
00085 return *this;
00086 }
00087
00088
00089
00090
00091 template<typename oT>
00092 inline
00093 field<oT>::field(const subview_field<oT>& X)
00094 : n_rows(0)
00095 , n_cols(0)
00096 , n_elem(0)
00097 , mem(0)
00098 {
00099 arma_extra_debug_sigprint_this(this);
00100
00101 this->operator=(X);
00102 }
00103
00104
00105
00106
00107 template<typename oT>
00108 inline
00109 const field<oT>&
00110 field<oT>::operator=(const subview_field<oT>& X)
00111 {
00112 arma_extra_debug_sigprint();
00113
00114 subview_field<oT>::extract(*this, X);
00115 return *this;
00116 }
00117
00118
00119
00120
00121
00122 template<typename oT>
00123 inline
00124 field<oT>::field(const u32 n_elem_in)
00125 : n_rows(0)
00126 , n_cols(0)
00127 , n_elem(0)
00128 , mem(0)
00129 {
00130 arma_extra_debug_sigprint_this(this);
00131
00132 init(n_elem_in, 1);
00133 }
00134
00135
00136
00137
00138 template<typename oT>
00139 inline
00140 field<oT>::field(const u32 n_rows_in, const u32 n_cols_in)
00141 : n_rows(0)
00142 , n_cols(0)
00143 , n_elem(0)
00144 , mem(0)
00145 {
00146 arma_extra_debug_sigprint_this(this);
00147
00148 init(n_rows_in, n_cols_in);
00149 }
00150
00151
00152
00153
00154
00155 template<typename oT>
00156 inline
00157 void
00158 field<oT>::set_size(const u32 n_elem_in)
00159 {
00160 arma_extra_debug_sigprint(arma_boost::format("n_elem_in = %d") % n_elem_in);
00161
00162 init(n_elem_in, 1);
00163 }
00164
00165
00166
00167
00168 template<typename oT>
00169 inline
00170 void
00171 field<oT>::set_size(const u32 n_rows_in, const u32 n_cols_in)
00172 {
00173 arma_extra_debug_sigprint(arma_boost::format("n_rows_in = %d, n_cols_in = %d") % n_rows_in % n_cols_in);
00174
00175 init(n_rows_in, n_cols_in);
00176 }
00177
00178
00179
00180
00181 template<typename oT>
00182 template<typename oT2>
00183 inline
00184 void
00185 field<oT>::copy_size(const field<oT2>& x)
00186 {
00187 arma_extra_debug_sigprint();
00188
00189 init(x.n_rows, x.n_cols);
00190 }
00191
00192
00193
00194
00195 template<typename oT>
00196 arma_inline
00197 oT&
00198 field<oT>::operator[] (const u32 i)
00199 {
00200 return (*mem[i]);
00201 }
00202
00203
00204
00205
00206 template<typename oT>
00207 arma_inline
00208 const oT&
00209 field<oT>::operator[] (const u32 i) const
00210 {
00211 return (*mem[i]);
00212 }
00213
00214
00215
00216 template<typename oT>
00217 arma_inline
00218 oT&
00219 field<oT>::operator() (const u32 i)
00220 {
00221 arma_debug_check( (i >= n_elem), "field::operator(): index out of bounds");
00222 return (*mem[i]);
00223 }
00224
00225
00226
00227
00228 template<typename oT>
00229 arma_inline
00230 const oT&
00231 field<oT>::operator() (const u32 i) const
00232 {
00233 arma_debug_check( (i >= n_elem), "field::operator(): index out of bounds");
00234 return (*mem[i]);
00235 }
00236
00237
00238
00239
00240 template<typename oT>
00241 arma_inline
00242 oT&
00243 field<oT>::operator() (const u32 in_row, const u32 in_col)
00244 {
00245 arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "field::operator(): index out of bounds");
00246 return (*mem[in_row + in_col*n_rows]);
00247 }
00248
00249
00250
00251
00252 template<typename oT>
00253 arma_inline
00254 const oT&
00255 field<oT>::operator() (const u32 in_row, const u32 in_col) const
00256 {
00257 arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "field::operator(): index out of bounds");
00258 return (*mem[in_row + in_col*n_rows]);
00259 }
00260
00261
00262
00263
00264 template<typename oT>
00265 arma_inline
00266 oT&
00267 field<oT>::at(const u32 in_row, const u32 in_col)
00268 {
00269 return (*mem[in_row + in_col*n_rows]);
00270 }
00271
00272
00273
00274
00275 template<typename oT>
00276 arma_inline
00277 const oT&
00278 field<oT>::at(const u32 in_row, const u32 in_col) const
00279 {
00280 return (*mem[in_row + in_col*n_rows]);
00281 }
00282
00283
00284
00285
00286 template<typename oT>
00287 inline
00288 subview_field<oT>
00289 field<oT>::row(const u32 row_num)
00290 {
00291 arma_extra_debug_sigprint();
00292
00293 arma_debug_check( (row_num >= n_rows), "field::row(): row out of bounds" );
00294 return subview_field<oT>(*this, row_num, 0, row_num, n_cols-1);
00295 }
00296
00297
00298
00299
00300 template<typename oT>
00301 inline
00302 const subview_field<oT>
00303 field<oT>::row(const u32 row_num) const
00304 {
00305 arma_extra_debug_sigprint();
00306
00307 arma_debug_check( (row_num >= n_rows), "field::row(): row out of bounds" );
00308 return subview_field<oT>(*this, row_num, 0, row_num, n_cols-1);
00309 }
00310
00311
00312
00313
00314 template<typename oT>
00315 inline
00316 subview_field<oT>
00317 field<oT>::col(const u32 col_num)
00318 {
00319 arma_extra_debug_sigprint();
00320
00321 arma_debug_check( (col_num >= n_cols), "field::col(): out of bounds");
00322 return subview_field<oT>(*this, 0, col_num, n_rows-1, col_num);
00323 }
00324
00325
00326
00327
00328 template<typename oT>
00329 inline
00330 const subview_field<oT>
00331 field<oT>::col(const u32 col_num) const
00332 {
00333 arma_extra_debug_sigprint();
00334
00335 arma_debug_check( (col_num >= n_cols), "field::col(): out of bounds");
00336 return subview_field<oT>(*this, 0, col_num, n_rows-1, col_num);
00337 }
00338
00339
00340
00341
00342 template<typename oT>
00343 inline
00344 subview_field<oT>
00345 field<oT>::rows(const u32 in_row1, const u32 in_row2)
00346 {
00347 arma_extra_debug_sigprint();
00348
00349 arma_debug_check
00350 (
00351 ( (in_row1 > in_row2) || (in_row2 >= n_rows) ),
00352 "field::rows(): indicies out of bounds or incorrectly used"
00353 );
00354
00355 return subview_field<oT>(*this, in_row1, 0, in_row2, n_cols-1);
00356 }
00357
00358
00359
00360
00361 template<typename oT>
00362 inline
00363 const subview_field<oT>
00364 field<oT>::rows(const u32 in_row1, const u32 in_row2) const
00365 {
00366 arma_extra_debug_sigprint();
00367
00368 arma_debug_check
00369 (
00370 ( (in_row1 > in_row2) || (in_row2 >= n_rows) ),
00371 "field::rows(): indicies out of bounds or incorrectly used"
00372 );
00373
00374 return subview_field<oT>(*this, in_row1, 0, in_row2, n_cols-1);
00375 }
00376
00377
00378
00379
00380 template<typename oT>
00381 inline
00382 subview_field<oT>
00383 field<oT>::cols(const u32 in_col1, const u32 in_col2)
00384 {
00385 arma_extra_debug_sigprint();
00386
00387 arma_debug_check
00388 (
00389 ( (in_col1 > in_col2) || (in_col2 >= n_cols) ),
00390 "field::cols(): indicies out of bounds or incorrectly used"
00391 );
00392
00393 return subview_field<oT>(*this, 0, in_col1, n_rows-1, in_col2);
00394 }
00395
00396
00397
00398
00399 template<typename oT>
00400 inline
00401 const subview_field<oT>
00402 field<oT>::cols(const u32 in_col1, const u32 in_col2) const
00403 {
00404 arma_extra_debug_sigprint();
00405
00406 arma_debug_check
00407 (
00408 ( (in_col1 > in_col2) || (in_col2 >= n_cols) ),
00409 "field::cols(): indicies out of bounds or incorrectly used"
00410 );
00411
00412 return subview_field<oT>(*this, 0, in_col1, n_rows-1, in_col2);
00413 }
00414
00415
00416
00417
00418 template<typename oT>
00419 inline
00420 subview_field<oT>
00421 field<oT>::subfield(const u32 in_row1, const u32 in_col1, const u32 in_row2, const u32 in_col2)
00422 {
00423 arma_extra_debug_sigprint();
00424
00425 arma_debug_check
00426 (
00427 (in_row1 > in_row2) || (in_col1 > in_col2) || (in_row2 >= n_rows) || (in_col2 >= n_cols),
00428 "field::subfield(): indices out of bounds or incorrectly used"
00429 );
00430
00431 return subview_field<oT>(*this, in_row1, in_col1, in_row2, in_col2);
00432 }
00433
00434
00435
00436
00437 template<typename oT>
00438 inline
00439 const subview_field<oT>
00440 field<oT>::subfield(const u32 in_row1, const u32 in_col1, const u32 in_row2, const u32 in_col2) const
00441 {
00442 arma_extra_debug_sigprint();
00443
00444 arma_debug_check
00445 (
00446 (in_row1 > in_row2) || (in_col1 > in_col2) || (in_row2 >= n_rows) || (in_col2 >= n_cols),
00447 "field::subfield(): indices out of bounds or incorrectly used"
00448 );
00449
00450 return subview_field<oT>(*this, in_row1, in_col1, in_row2, in_col2);
00451 }
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464 template<typename oT>
00465 inline
00466 void
00467 field<oT>::print(const std::string extra_text) const
00468 {
00469 arma_extra_debug_sigprint();
00470
00471 if(extra_text.length() != 0)
00472 {
00473 const std::streamsize orig_width = cout.width();
00474
00475 cout << extra_text << '\n';
00476
00477 cout.width(orig_width);
00478 }
00479
00480 arma_ostream::print(cout, *this);
00481 }
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494 template<typename oT>
00495 inline
00496 void
00497 field<oT>::print(std::ostream& user_stream, const std::string extra_text) const
00498 {
00499 arma_extra_debug_sigprint();
00500
00501 if(extra_text.length() != 0)
00502 {
00503 const std::streamsize orig_width = user_stream.width();
00504
00505 user_stream << extra_text << '\n';
00506
00507 user_stream.width(orig_width);
00508 }
00509
00510 arma_ostream::print(user_stream, *this);
00511 }
00512
00513
00514
00515
00516 template<typename oT>
00517 inline
00518 void
00519 field<oT>::fill(const oT& x)
00520 {
00521 arma_extra_debug_sigprint();
00522
00523 field<oT>& t = *this;
00524
00525 for(u32 i=0; i<n_elem; ++i)
00526 {
00527 t[i] = x;
00528 }
00529 }
00530
00531
00532
00533 template<typename oT>
00534 inline
00535 void
00536 field<oT>::reset()
00537 {
00538 arma_extra_debug_sigprint();
00539
00540 init(0,0);
00541 }
00542
00543
00544
00545 template<typename oT>
00546 inline
00547 void
00548 field<oT>::reset_objects()
00549 {
00550 arma_extra_debug_sigprint();
00551
00552 field_aux::reset_objects(*this);
00553 }
00554
00555
00556
00557 template<typename oT>
00558 inline
00559 void
00560 field<oT>::save(const std::string name, const file_type type) const
00561 {
00562 arma_extra_debug_sigprint();
00563
00564 field_aux::save(*this, name, type);
00565 }
00566
00567
00568
00569 template<typename oT>
00570 inline
00571 void
00572 field<oT>::save(std::ostream& os, const file_type type) const
00573 {
00574 arma_extra_debug_sigprint();
00575
00576 field_aux::save(*this, os, type);
00577 }
00578
00579
00580
00581 template<typename oT>
00582 inline
00583 void
00584 field<oT>::load(const std::string name, const file_type type)
00585 {
00586 arma_extra_debug_sigprint();
00587
00588 field_aux::load(*this, name, type);
00589 }
00590
00591
00592
00593 template<typename oT>
00594 inline
00595 void
00596 field<oT>::load(std::istream& is, const file_type type)
00597 {
00598 arma_extra_debug_sigprint();
00599
00600 field_aux::load(*this, is, type);
00601 }
00602
00603
00604
00605
00606 template<typename oT>
00607 inline
00608 void
00609 field<oT>::init(const field<oT>& x)
00610 {
00611 arma_extra_debug_sigprint();
00612
00613 if(this != &x)
00614 {
00615 init(x.n_rows, x.n_cols);
00616
00617 field& t = *this;
00618
00619 for(u32 col=0; col<x.n_cols; ++col)
00620 for(u32 row=0; row<x.n_rows; ++row)
00621 {
00622 t.at(row,col) = x.at(row,col);
00623 }
00624 }
00625
00626 }
00627
00628
00629
00630
00631 template<typename oT>
00632 inline
00633 void
00634 field<oT>::init(const u32 n_rows_in, const u32 n_cols_in)
00635 {
00636 arma_extra_debug_sigprint( arma_boost::format("n_rows_in = %d, n_cols_in = %d") % n_rows_in % n_cols_in );
00637
00638 const u32 n_elem_new = n_rows_in * n_cols_in;
00639
00640 if(n_elem == n_elem_new)
00641 {
00642
00643
00644 access::rw(n_rows) = n_rows_in;
00645 access::rw(n_cols) = n_cols_in;
00646 }
00647 else
00648 {
00649 delete_objects();
00650
00651 if(n_elem > sizeof(mem_local)/sizeof(oT*) )
00652 {
00653 delete [] mem;
00654 }
00655
00656 if(n_elem_new <= sizeof(mem_local)/sizeof(oT*) )
00657 {
00658 mem = mem_local;
00659 }
00660 else
00661 {
00662 mem = new(std::nothrow) oT* [n_elem_new];
00663 arma_check( (mem == 0), "field::init(): out of memory" );
00664 }
00665
00666 access::rw(n_elem) = n_elem_new;
00667
00668 if(n_elem_new == 0)
00669 {
00670 access::rw(n_rows) = 0;
00671 access::rw(n_cols) = 0;
00672 }
00673 else
00674 {
00675 access::rw(n_rows) = n_rows_in;
00676 access::rw(n_cols) = n_cols_in;
00677 }
00678
00679 create_objects();
00680
00681 }
00682
00683 }
00684
00685
00686
00687 template<typename oT>
00688 inline
00689 void
00690 field<oT>::delete_objects()
00691 {
00692 arma_extra_debug_sigprint( arma_boost::format("n_elem = %d") % n_elem );
00693
00694 for(u32 i=0; i<n_elem; ++i)
00695 {
00696 if(mem[i] != 0)
00697 {
00698 delete mem[i];
00699 mem[i] = 0;
00700 }
00701 }
00702
00703 }
00704
00705
00706
00707 template<typename oT>
00708 inline
00709 void
00710 field<oT>::create_objects()
00711 {
00712 arma_extra_debug_sigprint( arma_boost::format("n_elem = %d") % n_elem );
00713
00714 for(u32 i=0; i<n_elem; ++i)
00715 {
00716 mem[i] = new oT;
00717 }
00718
00719 }
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729 template<typename oT>
00730 inline
00731 void
00732 field_aux::reset_objects(field<oT>& x)
00733 {
00734 arma_extra_debug_sigprint();
00735
00736 x.delete_objects();
00737 x.create_objects();
00738 }
00739
00740
00741
00742 template<typename eT>
00743 inline
00744 void
00745 field_aux::reset_objects(field< Mat<eT> >& x)
00746 {
00747 arma_extra_debug_sigprint();
00748
00749 for(u32 i=0; i<x.n_elem; ++i)
00750 {
00751 (*(x.mem[i])).reset();
00752 }
00753 }
00754
00755
00756
00757 template<typename eT>
00758 inline
00759 void
00760 field_aux::reset_objects(field< Col<eT> >& x)
00761 {
00762 arma_extra_debug_sigprint();
00763
00764 for(u32 i=0; i<x.n_elem; ++i)
00765 {
00766 (*(x.mem[i])).reset();
00767 }
00768 }
00769
00770
00771
00772 template<typename eT>
00773 inline
00774 void
00775 field_aux::reset_objects(field< Row<eT> >& x)
00776 {
00777 arma_extra_debug_sigprint();
00778
00779 for(u32 i=0; i<x.n_elem; ++i)
00780 {
00781 (*(x.mem[i])).reset();
00782 }
00783 }
00784
00785
00786
00787 template<typename eT>
00788 inline
00789 void
00790 field_aux::reset_objects(field< Cube<eT> >& x)
00791 {
00792 arma_extra_debug_sigprint();
00793
00794 for(u32 i=0; i<x.n_elem; ++i)
00795 {
00796 (*(x.mem[i])).reset();
00797 }
00798 }
00799
00800
00801
00802 inline
00803 void
00804 field_aux::reset_objects(field< std::string >& x)
00805 {
00806 arma_extra_debug_sigprint();
00807
00808 for(u32 i=0; i<x.n_elem; ++i)
00809 {
00810 (*(x.mem[i])).clear();
00811 }
00812 }
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822 template<typename oT>
00823 inline
00824 void
00825 field_aux::save(const field<oT>& x, const std::string& name, const file_type type)
00826 {
00827 arma_extra_debug_sigprint();
00828
00829 arma_print("field_aux::save(): sorry, saving this type of field is currently not supported");
00830 }
00831
00832
00833
00834 template<typename oT>
00835 inline
00836 void
00837 field_aux::save(const field<oT>& x, std::ostream& os, const file_type type)
00838 {
00839 arma_extra_debug_sigprint();
00840
00841 arma_print("field_aux::save(): sorry, saving this type of field is currently not supported");
00842 }
00843
00844
00845
00846 template<typename oT>
00847 inline
00848 void
00849 field_aux::load(field<oT>& x, const std::string& name, const file_type type)
00850 {
00851 arma_extra_debug_sigprint();
00852
00853 arma_print("field_aux::load(): sorry, loading this type of field is currently not supported");
00854 x.reset();
00855 }
00856
00857
00858
00859 template<typename oT>
00860 inline
00861 void
00862 field_aux::load(field<oT>& x, std::istream& is, const file_type type)
00863 {
00864 arma_extra_debug_sigprint();
00865
00866 arma_print("field_aux::load(): sorry, loading this type of field is currently not supported");
00867 x.reset();
00868 }
00869
00870
00871
00872 template<typename eT>
00873 inline
00874 void
00875 field_aux::save(const field< Mat<eT> >& x, const std::string& name, const file_type type)
00876 {
00877 arma_extra_debug_sigprint();
00878
00879 switch(type)
00880 {
00881 case arma_binary:
00882 diskio::save_arma_binary(x, name);
00883 break;
00884
00885 case ppm_binary:
00886 diskio::save_ppm_binary(x, name);
00887 break;
00888
00889 default:
00890 arma_stop("field_aux::save(): unsupported type");
00891 }
00892 }
00893
00894
00895
00896 template<typename eT>
00897 inline
00898 void
00899 field_aux::save(const field< Mat<eT> >& x, std::ostream& os, const file_type type)
00900 {
00901 arma_extra_debug_sigprint();
00902
00903 switch(type)
00904 {
00905 case arma_binary:
00906 diskio::save_arma_binary(x, "[ostream]", os);
00907 break;
00908
00909 case ppm_binary:
00910 diskio::save_ppm_binary(x, "[ostream]", os);
00911 break;
00912
00913 default:
00914 arma_stop("field_aux::save(): unsupported type");
00915 }
00916 }
00917
00918
00919
00920 template<typename eT>
00921 inline
00922 void
00923 field_aux::load(field< Mat<eT> >& x, const std::string& name, const file_type type)
00924 {
00925 arma_extra_debug_sigprint();
00926
00927 switch(type)
00928 {
00929 case auto_detect:
00930 diskio::load_auto_detect(x, name);
00931 break;
00932
00933 case arma_binary:
00934 diskio::load_arma_binary(x, name);
00935 break;
00936
00937 case ppm_binary:
00938 diskio::load_ppm_binary(x, name);
00939 break;
00940
00941 default:
00942 arma_stop("field_aux::load(): unsupported type");
00943 }
00944 }
00945
00946
00947
00948 template<typename eT>
00949 inline
00950 void
00951 field_aux::load(field< Mat<eT> >& x, std::istream& is, const file_type type)
00952 {
00953 arma_extra_debug_sigprint();
00954
00955 switch(type)
00956 {
00957 case auto_detect:
00958 diskio::load_auto_detect(x, "[istream]", is);
00959 break;
00960
00961 case arma_binary:
00962 diskio::load_arma_binary(x, "[istream]", is);
00963 break;
00964
00965 case ppm_binary:
00966 diskio::load_ppm_binary(x, "[istream]", is);
00967 break;
00968
00969 default:
00970 arma_stop("field_aux::load(): unsupported type");
00971 }
00972 }
00973
00974
00975
00976 template<typename eT>
00977 inline
00978 void
00979 field_aux::save(const field< Col<eT> >& x, const std::string& name, const file_type type)
00980 {
00981 arma_extra_debug_sigprint();
00982
00983 switch(type)
00984 {
00985 case arma_binary:
00986 diskio::save_arma_binary(x, name);
00987 break;
00988
00989 case ppm_binary:
00990 diskio::save_ppm_binary(x, name);
00991 break;
00992
00993 default:
00994 arma_stop("field_aux::save(): unsupported type");
00995 }
00996 }
00997
00998
00999
01000 template<typename eT>
01001 inline
01002 void
01003 field_aux::save(const field< Col<eT> >& x, std::ostream& os, const file_type type)
01004 {
01005 arma_extra_debug_sigprint();
01006
01007 switch(type)
01008 {
01009 case arma_binary:
01010 diskio::save_arma_binary(x, "[ostream]", os);
01011 break;
01012
01013 case ppm_binary:
01014 diskio::save_ppm_binary(x, "[ostream]", os);
01015 break;
01016
01017 default:
01018 arma_stop("field_aux::save(): unsupported type");
01019 }
01020 }
01021
01022
01023
01024 template<typename eT>
01025 inline
01026 void
01027 field_aux::load(field< Col<eT> >& x, const std::string& name, const file_type type)
01028 {
01029 arma_extra_debug_sigprint();
01030
01031 switch(type)
01032 {
01033 case auto_detect:
01034 diskio::load_auto_detect(x, name);
01035 break;
01036
01037 case arma_binary:
01038 diskio::load_arma_binary(x, name);
01039 break;
01040
01041 case ppm_binary:
01042 diskio::load_ppm_binary(x, name);
01043 break;
01044
01045 default:
01046 arma_stop("field_aux::load(): unsupported type");
01047 }
01048 }
01049
01050
01051
01052 template<typename eT>
01053 inline
01054 void
01055 field_aux::load(field< Col<eT> >& x, std::istream& is, const file_type type)
01056 {
01057 arma_extra_debug_sigprint();
01058
01059 switch(type)
01060 {
01061 case auto_detect:
01062 diskio::load_auto_detect(x, "[istream]", is);
01063 break;
01064
01065 case arma_binary:
01066 diskio::load_arma_binary(x, "[istream]", is);
01067 break;
01068
01069 case ppm_binary:
01070 diskio::load_ppm_binary(x, "[istream]", is);
01071 break;
01072
01073 default:
01074 arma_stop("field_aux::load(): unsupported type");
01075 }
01076 }
01077
01078
01079
01080 template<typename eT>
01081 inline
01082 void
01083 field_aux::save(const field< Row<eT> >& x, const std::string& name, const file_type type)
01084 {
01085 arma_extra_debug_sigprint();
01086
01087 switch(type)
01088 {
01089 case arma_binary:
01090 diskio::save_arma_binary(x, name);
01091 break;
01092
01093 case ppm_binary:
01094 diskio::save_ppm_binary(x, name);
01095 break;
01096
01097 default:
01098 arma_stop("field_aux::save(): unsupported type");
01099 }
01100 }
01101
01102
01103
01104 template<typename eT>
01105 inline
01106 void
01107 field_aux::save(const field< Row<eT> >& x, std::ostream& os, const file_type type)
01108 {
01109 arma_extra_debug_sigprint();
01110
01111 switch(type)
01112 {
01113 case arma_binary:
01114 diskio::save_arma_binary(x, "[ostream]", os);
01115 break;
01116
01117 case ppm_binary:
01118 diskio::save_ppm_binary(x, "[ostream]", os);
01119 break;
01120
01121 default:
01122 arma_stop("field_aux::save(): unsupported type");
01123 }
01124 }
01125
01126
01127
01128 template<typename eT>
01129 inline
01130 void
01131 field_aux::load(field< Row<eT> >& x, const std::string& name, const file_type type)
01132 {
01133 arma_extra_debug_sigprint();
01134
01135 switch(type)
01136 {
01137 case auto_detect:
01138 diskio::load_auto_detect(x, name);
01139 break;
01140
01141 case arma_binary:
01142 diskio::load_arma_binary(x, name);
01143 break;
01144
01145 case ppm_binary:
01146 diskio::load_ppm_binary(x, name);
01147 break;
01148
01149 default:
01150 arma_stop("field_aux::load(): unsupported type");
01151 }
01152 }
01153
01154
01155
01156 template<typename eT>
01157 inline
01158 void
01159 field_aux::load(field< Row<eT> >& x, std::istream& is, const file_type type)
01160 {
01161 arma_extra_debug_sigprint();
01162
01163 switch(type)
01164 {
01165 case auto_detect:
01166 diskio::load_auto_detect(x, "[istream]", is);
01167 break;
01168
01169 case arma_binary:
01170 diskio::load_arma_binary(x, "[istream]", is);
01171 break;
01172
01173 case ppm_binary:
01174 diskio::load_ppm_binary(x, "[istream]", is);
01175 break;
01176
01177 default:
01178 arma_stop("field_aux::load(): unsupported type");
01179 }
01180 }
01181
01182
01183
01184 template<typename eT>
01185 inline
01186 void
01187 field_aux::save(const field< Cube<eT> >& x, const std::string& name, const file_type type)
01188 {
01189 arma_extra_debug_sigprint();
01190
01191 switch(type)
01192 {
01193 case arma_binary:
01194 diskio::save_arma_binary(x, name);
01195 break;
01196
01197 case ppm_binary:
01198 diskio::save_ppm_binary(x, name);
01199 break;
01200
01201 default:
01202 arma_stop("field_aux::save(): unsupported type");
01203 }
01204 }
01205
01206
01207
01208 template<typename eT>
01209 inline
01210 void
01211 field_aux::save(const field< Cube<eT> >& x, std::ostream& os, const file_type type)
01212 {
01213 arma_extra_debug_sigprint();
01214
01215 switch(type)
01216 {
01217 case arma_binary:
01218 diskio::save_arma_binary(x, "[ostream]", os);
01219 break;
01220
01221 case ppm_binary:
01222 diskio::save_ppm_binary(x, "[ostream]", os);
01223 break;
01224
01225 default:
01226 arma_stop("field_aux::save(): unsupported type");
01227 }
01228 }
01229
01230
01231
01232 template<typename eT>
01233 inline
01234 void
01235 field_aux::load(field< Cube<eT> >& x, const std::string& name, const file_type type)
01236 {
01237 arma_extra_debug_sigprint();
01238
01239 switch(type)
01240 {
01241 case auto_detect:
01242 diskio::load_auto_detect(x, name);
01243 break;
01244
01245 case arma_binary:
01246 diskio::load_arma_binary(x, name);
01247 break;
01248
01249 case ppm_binary:
01250 diskio::load_ppm_binary(x, name);
01251 break;
01252
01253 default:
01254 arma_stop("field_aux::load(): unsupported type");
01255 }
01256 }
01257
01258
01259
01260 template<typename eT>
01261 inline
01262 void
01263 field_aux::load(field< Cube<eT> >& x, std::istream& is, const file_type type)
01264 {
01265 arma_extra_debug_sigprint();
01266
01267 switch(type)
01268 {
01269 case auto_detect:
01270 diskio::load_auto_detect(x, "[istream]", is);
01271 break;
01272
01273 case arma_binary:
01274 diskio::load_arma_binary(x, "[istream]", is);
01275 break;
01276
01277 case ppm_binary:
01278 diskio::load_ppm_binary(x, "[istream]", is);
01279 break;
01280
01281 default:
01282 arma_stop("field_aux::load(): unsupported type");
01283 }
01284 }
01285
01286
01287
01288 inline
01289 void
01290 field_aux::save(const field< std::string >& x, const std::string& name, const file_type type)
01291 {
01292 arma_extra_debug_sigprint();
01293
01294 diskio::save_std_string(x, name);
01295 }
01296
01297
01298
01299 inline
01300 void
01301 field_aux::save(const field< std::string >& x, std::ostream& os, const file_type type)
01302 {
01303 arma_extra_debug_sigprint();
01304
01305 diskio::save_std_string(x, "[ostream]", os);
01306 }
01307
01308
01309
01310 inline
01311 void
01312 field_aux::load(field< std::string >& x, const std::string& name, const file_type type)
01313 {
01314 arma_extra_debug_sigprint();
01315
01316 diskio::load_std_string(x, name);
01317 }
01318
01319
01320
01321 inline
01322 void
01323 field_aux::load(field< std::string >& x, std::istream& is, const file_type type)
01324 {
01325 arma_extra_debug_sigprint();
01326
01327 diskio::load_std_string(x, "[istream]", is);
01328 }
01329
01330
01331
01332