Go to the documentation of this file.00001
00002 #ifndef bsta_io_mixture_fixed_h_
00003 #define bsta_io_mixture_fixed_h_
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <bsta/bsta_mixture_fixed.h>
00016 #include <vsl/vsl_binary_io.h>
00017 #include <vcl_iostream.h>
00018
00019
00020 template <class comp_, unsigned s>
00021 void
00022 vsl_b_write(vsl_b_ostream &os, const bsta_mixture_fixed<comp_,s>& m)
00023 {
00024 unsigned size = m.num_components();
00025 vsl_b_write(os,size);
00026 for (unsigned i=0; i<size; ++i){
00027 vsl_b_write(os,m.weight(i));
00028 vsl_b_write(os,m.distribution(i));
00029 }
00030 }
00031
00032
00033 template <class comp_, unsigned s>
00034 void
00035 vsl_b_read(vsl_b_istream &is, bsta_mixture_fixed<comp_,s>& m)
00036 {
00037 while (m.num_components()>0)
00038 m.remove_last();
00039
00040 unsigned size;
00041 vsl_b_read(is,size);
00042 typename comp_::math_type weight;
00043 comp_ dstrb;
00044 for (unsigned i=0; i<size; ++i){
00045 vsl_b_read(is,weight);
00046 vsl_b_read(is,dstrb);
00047 m.insert(dstrb,weight);
00048 }
00049 }
00050
00051
00052 template <class comp_, unsigned s>
00053 void
00054 vsl_print_summary(vcl_ostream &os, const bsta_mixture_fixed<comp_,s>& m)
00055 {
00056 unsigned size = m.num_components();
00057 os << "mixture with "<<size<<" components\n";
00058 for (unsigned i=0; i<size; ++i){
00059 os<<" weight:"<<m.weight(i)<<' ';
00060 vsl_print_summary(os,m.distribution(i));
00061 os <<"\n";
00062 }
00063 }
00064
00065
00066 #endif // bsta_io_mixture_fixed_h_