Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

131 lines
3.1 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1997
  6. //
  7. // File: bndist.h
  8. //
  9. //--------------------------------------------------------------------------
  10. //
  11. // bndist.h: Belief Network Distributions
  12. //
  13. #ifndef _BNDIST_H_
  14. #define _BNDIST_H_
  15. #include "mddist.h"
  16. ////////////////////////////////////////////////////////////////////
  17. // class BNDIST:
  18. //
  19. // Base class for probability distributions used in belief networks.
  20. //
  21. // This is a reference counted object which usually lives in the
  22. // distribution map of an MBNET.
  23. //
  24. // However, BNDISTs are also created for various other purposes
  25. // such as CI network expansion. In these cases, the BNDIST
  26. // is automatically deleted when the reference count goes to zero.
  27. // See BNDIST::NoRef().
  28. //
  29. ////////////////////////////////////////////////////////////////////
  30. class BNDIST : public REFCNT
  31. {
  32. friend class DSCPARSER;
  33. public:
  34. BNDIST ();
  35. ~ BNDIST ();
  36. BNDIST ( const BNDIST & bnd );
  37. enum EDIST
  38. {
  39. ED_NONE, // illegal value
  40. ED_DENSE, // lowest enum value for a dense distribution
  41. ED_SPARSE, // lowest enum value for a sparse distribution
  42. ED_CI_MAX, // therefore, CI "max" is sparse
  43. ED_CI_PLUS, // as is CI "plus"
  44. ED_MAX // first unused value
  45. };
  46. EDIST Edist () const
  47. { return _edist; }
  48. BNDIST & operator = ( const BNDIST & bnd );
  49. // Set distribution to "dense"
  50. void SetDense ( const VIMD & vimd );
  51. // Set distribution to sparse
  52. void SetSparse ( const VIMD & vimd );
  53. static bool BDenseType ( EDIST edist )
  54. { return edist >= ED_DENSE && edist < ED_SPARSE ; }
  55. static bool BSparseType ( EDIST edist )
  56. { return edist >= ED_SPARSE && edist < ED_MAX ; }
  57. bool BDense () const
  58. { return BDenseType( Edist() ); }
  59. bool BSparse () const
  60. { return BSparseType( Edist() ); }
  61. bool BChangeSubtype ( EDIST edist );
  62. // Convert a dense representation to a sparse one
  63. void ConvertToDense ( const VIMD & vimd );
  64. void Clear ()
  65. {
  66. delete _pmdvcpd;
  67. _pmdvcpd = NULL;
  68. delete _mpcpdd;
  69. _mpcpdd = NULL;
  70. }
  71. MDVCPD & Mdvcpd ()
  72. {
  73. assert( _pmdvcpd );
  74. return *_pmdvcpd ;
  75. }
  76. const MDVCPD & Mdvcpd () const
  77. {
  78. assert( _pmdvcpd );
  79. return *_pmdvcpd ;
  80. }
  81. MPCPDD & Mpcpdd ()
  82. {
  83. assert( _mpcpdd );
  84. return *_mpcpdd;
  85. }
  86. const MPCPDD & Mpcpdd () const
  87. {
  88. assert( _mpcpdd );
  89. return *_mpcpdd;
  90. }
  91. const VIMD & VimdDim () const
  92. { return _vimdDim; }
  93. // Return the "leak" or "default" vector for a sparse distribution
  94. const VLREAL * PVlrLeak () const;
  95. void Dump();
  96. void Clone ( const BNDIST & bndist );
  97. LEAK_VAR_ACCESSOR
  98. protected:
  99. EDIST _edist; // Type of distribution
  100. MDVCPD * _pmdvcpd; // Ptr to dense m-d array
  101. MPCPDD * _mpcpdd; // Ptr to sparse array
  102. VIMD _vimdDim; // Dense dimensionality
  103. // Called when object's reference count goes to zero
  104. void NoRef ();
  105. // Dumper functions
  106. void DumpSparse();
  107. void DumpDense();
  108. LEAK_VAR_DECL
  109. };
  110. #endif