Go to the documentation of this file.00001
00002 #ifndef vnl_io_diag_matrix_txx_
00003 #define vnl_io_diag_matrix_txx_
00004
00005
00006
00007 #include "vnl_io_diag_matrix.h"
00008 #include <vsl/vsl_binary_io.h>
00009 #include <vnl/io/vnl_io_vector.h>
00010
00011
00012
00013
00014 template<class T>
00015 void vsl_b_write(vsl_b_ostream & os, const vnl_diag_matrix<T> & p)
00016 {
00017 const short io_version_no = 1;
00018 vsl_b_write(os, io_version_no);
00019 vsl_b_write(os, p.diagonal());
00020 }
00021
00022
00023
00024 template<class T>
00025 void vsl_b_read(vsl_b_istream &is, vnl_diag_matrix<T> & p)
00026 {
00027 if (!is) return;
00028
00029 short ver;
00030 vnl_vector<T> v;
00031 vsl_b_read(is, ver);
00032 switch (ver)
00033 {
00034 case 1:
00035 vsl_b_read(is, v);
00036 p.set(v);
00037 break;
00038
00039 default:
00040 vcl_cerr << "I/O ERROR: vsl_b_read(vsl_b_istream&, vnl_diag_matrix<T>&)\n"
00041 << " Unknown version number "<< v << '\n';
00042 is.is().clear(vcl_ios::badbit);
00043 return;
00044 }
00045 }
00046
00047
00048
00049 template<class T>
00050 void vsl_print_summary(vcl_ostream & os,const vnl_diag_matrix<T> & p)
00051 {
00052 os<<"Diagonal: ";
00053 vsl_print_summary(os, p.diagonal());
00054 }
00055
00056 #define VNL_IO_DIAG_MATRIX_INSTANTIATE(T) \
00057 template void vsl_print_summary(vcl_ostream &, const vnl_diag_matrix<T > &); \
00058 template void vsl_b_read(vsl_b_istream &, vnl_diag_matrix<T > &); \
00059 template void vsl_b_write(vsl_b_ostream &, const vnl_diag_matrix<T > &)
00060
00061 #endif // vnl_io_diag_matrix_txx_