Go to the documentation of this file.00001
00002 #ifndef bsta_attributes_h_
00003 #define bsta_attributes_h_
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "bsta_distribution.h"
00019 #include <vcl_iostream.h>
00020 #include <vpdl/vpdt/vpdt_dist_traits.h>
00021
00022
00023 template <class dist_>
00024 class bsta_num_obs : public dist_
00025 {
00026 typedef typename dist_::math_type T;
00027
00028 public:
00029
00030 typedef dist_ contained_type;
00031
00032
00033 bsta_num_obs<dist_>() : dist_(), num_observations(T(0)) {}
00034
00035
00036 bsta_num_obs<dist_>(const dist_& d, const T& n_obs = T(0))
00037 : dist_(d), num_observations(n_obs) {}
00038
00039
00040 T num_observations;
00041 };
00042
00043 template <class dist_>
00044 inline vcl_ostream& operator<< (vcl_ostream& os,
00045 bsta_num_obs<dist_> const& no)
00046 {
00047 dist_ const& dist = static_cast<dist_ const&>(no);
00048 os << "n_obs:" << no.num_observations << '\n'
00049 << dist ;
00050 return os;
00051 }
00052
00053
00054 template <class dist>
00055 struct vpdt_is_mixture<bsta_num_obs<dist> >
00056 {
00057 static const bool value = vpdt_is_mixture<dist>::value;
00058 };
00059
00060
00061
00062 template <class dist_>
00063 class bsta_vsum_num_obs : public dist_
00064 {
00065 typedef typename dist_::math_type T;
00066 typedef typename dist_::vector_type vect_t;
00067
00068 public:
00069
00070 typedef dist_ contained_type;
00071
00072
00073 bsta_vsum_num_obs<dist_>() : dist_(), num_observations(T(0)), vector_sum(vect_t(T(0))) {}
00074
00075
00076 bsta_vsum_num_obs<dist_>(const dist_& d, const vect_t & vsum = vect_t(T(0)), const T& n_obs = T(0))
00077 : dist_(d), num_observations(n_obs), vector_sum(vsum) {}
00078
00079
00080 T num_observations;
00081 vect_t vector_sum;
00082 };
00083
00084 template <class dist_>
00085 inline vcl_ostream& operator<< (vcl_ostream& os,
00086 bsta_vsum_num_obs<dist_> const& vno)
00087 {
00088 dist_ const& dist = static_cast<dist_ const&>(vno);
00089 os << "n_obs:" << vno.num_observations << '\n'
00090 << "vector_sum:" << vno.vector_sum << '\n'
00091 << dist ;
00092 return os;
00093 }
00094
00095
00096 template <class dist>
00097 struct vpdt_is_mixture<bsta_vsum_num_obs<dist> >
00098 {
00099 static const bool value = vpdt_is_mixture<dist>::value;
00100 };
00101
00102
00103 #endif // bsta_attributes_h_