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.

134 lines
3.5 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /** @file aib.h
  2. ** @brief AIB (@ref aib)
  3. ** @author Brian Fulkerson
  4. ** @author Andrea Vedaldi
  5. **/
  6. /*
  7. Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson.
  8. All rights reserved.
  9. This file is part of the VLFeat library and is made available under
  10. the terms of the BSD license (see the COPYING file).
  11. */
  12. #ifndef VL_AIB_H
  13. #define VL_AIB_H
  14. #include "generic.h"
  15. #include "mathop.h"
  16. /** ------------------------------------------------------------------
  17. ** @internal
  18. ** @brief AIB algorithm data
  19. **
  20. ** The implementation is quite straightforward, but the way feature
  21. ** values are handled in order to support efficient joins,
  22. ** deletions and re-arrangement needs to be explained. This is
  23. ** achieved by adding a layer of indirection:
  24. ** - Call each feature value (either original or obtained by a join
  25. ** operation) a <em>node</em>. Nodes are identified by numbers.
  26. ** - Call each element of the various arrays (such as VlAIB::Px)
  27. ** an <em>entry</em>.
  28. ** - Entries are dynamically associated to nodes as specified by
  29. ** VlAIB::nodes. For example, @c Px[i] refers to the node @c
  30. ** nodes[i].
  31. **/
  32. typedef struct _VlAIB
  33. {
  34. vl_uint *nodes ; /**< Entires to nodes */
  35. vl_uint nentries ; /**< Total number of entries (= # active nodes) */
  36. double *beta ; /**< Minimum distance to an entry */
  37. vl_uint *bidx ; /**< Closest entry */
  38. vl_uint *which ; /**< List of entries to update */
  39. vl_uint nwhich ; /**< Number of entries to update */
  40. double *Pcx; /**< Joint probability table */
  41. double *Px; /**< Marginal. */
  42. double *Pc; /**< Marginal. */
  43. vl_uint nvalues; /**< Number of feature values */
  44. vl_uint nlabels; /**< Number of labels */
  45. vl_uint *parents; /**< Array of parents */
  46. double *costs; /**< Cost of each merge */
  47. vl_uint verbosity ; /** Verbosity level */
  48. } VlAIB;
  49. /** @name Create and destroy
  50. ** @{
  51. **/
  52. VL_EXPORT
  53. VlAIB * vl_aib_new(double * Pcx, vl_uint nvalues, vl_uint nlabels);
  54. VL_EXPORT
  55. void vl_aib_delete (VlAIB * aib);
  56. /** @} */
  57. /** @name Process data
  58. ** @{
  59. **/
  60. VL_EXPORT
  61. void vl_aib_process(VlAIB * aib);
  62. /** @} */
  63. /** @name Retrieve results
  64. ** @{
  65. **/
  66. VL_INLINE vl_uint * vl_aib_get_parents(VlAIB const * aib);
  67. VL_INLINE double * vl_aib_get_costs(VlAIB const * aib);
  68. /** @} */
  69. /* -------------------------------------------------------------------
  70. * Inline functions implementation
  71. * ---------------------------------------------------------------- */
  72. /** ------------------------------------------------------------------
  73. ** @brief Get resulting list of parents
  74. ** @param aib AIB filter.
  75. ** @return An array of parents
  76. **/
  77. VL_INLINE
  78. vl_uint * vl_aib_get_parents(VlAIB const * aib)
  79. {
  80. return aib->parents;
  81. }
  82. /** ------------------------------------------------------------------
  83. ** @brief Get a list of merge costs
  84. ** @param aib AIB filter.
  85. ** @return An array of costs
  86. **/
  87. VL_INLINE
  88. double * vl_aib_get_costs(VlAIB const * aib)
  89. {
  90. return aib->costs;
  91. }
  92. /* ----------------------------------------------------------------- */
  93. /** @brief Set the verbosity
  94. ** @param self AIB object.
  95. ** @param verbosity a non-negative integer.
  96. **/
  97. VL_INLINE void
  98. vl_aib_set_verbosity (VlAIB * self, int verbosity)
  99. {
  100. self->verbosity = verbosity ;
  101. }
  102. /** @brief Get the verbosity
  103. ** @param self AIB object.
  104. ** @return the verbosity level.
  105. **/
  106. VL_INLINE int
  107. vl_aib_get_verbosity (VlAIB const * self)
  108. {
  109. return self->verbosity ;
  110. }
  111. /* VL_AIB_H */
  112. #endif