Documentation>C API
Functions
hikmeans.c File Reference

Hierarchical Integer K-Means Clustering - Declaration. More...

`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <math.h>`
`#include "hikmeans.h"`

## Functions

vl_uint8 * | vl_hikm_copy_subset (vl_uint8 const *data, vl_uint32 *ids, vl_size N, vl_size M, vl_uint32 id, vl_size *N2)
| Copy a subset of the data to a buffer.
static VlHIKMNode * | xmeans (VlHIKMTree *tree, vl_uint8 const *data, vl_size N, vl_size K, vl_size height)
| Compute HIKM clustering.
static void | xdelete (VlHIKMNode *node)
| Delete node.
VlHIKMTree * | vl_hikm_new (int method)
| New HIKM tree.
void | vl_hikm_delete (VlHIKMTree *f)
| Delete HIKM tree.
void | vl_hikm_init (VlHIKMTree *f, vl_size M, vl_size K, vl_size depth)
| Initialize HIKM tree.
void | vl_hikm_train (VlHIKMTree *f, vl_uint8 const *data, vl_size N)
| Train HIKM tree.
void | vl_hikm_push (VlHIKMTree *f, vl_uint32 *asgn, vl_uint8 const *data, vl_size N)
| Project data down HIKM tree.
vl_size | vl_hikm_get_ndims (VlHIKMTree const *f)
| Get data dimensionality.
vl_size | vl_hikm_get_K (VlHIKMTree const *f)
| Get K.
vl_size | vl_hikm_get_depth (VlHIKMTree const *f)
| Get depth.
int | vl_hikm_get_verbosity (VlHIKMTree const *f)
| Get verbosity level.
vl_size | vl_hikm_get_max_niters (VlHIKMTree const *f)
| Get maximum number of iterations.
VlHIKMNode const * | vl_hikm_get_root (VlHIKMTree const *f)
| Get maximum number of iterations.
void | vl_hikm_set_verbosity (VlHIKMTree *f, int verb)
| Set verbosity level.
void | vl_hikm_set_max_niters (VlHIKMTree *f, int max_niters)
| Set maximum number of iterations.

## Detailed Description

Author
  Brian Fulkerson
  Andrea Vedaldi

## Function Documentation

## ◆ vl_hikm_copy_subset()

vl_uint8 * vl_hikm_copy_subset | ( | vl_uint8 const * | data,
|  | vl_uint32 * | ids,
|  | vl_size | N,
|  | vl_size | M,
|  | vl_uint32 | id,
|  | vl_size * | N2 )

Parameters

  data | Data
  ids | Data labels
  N | Number of indices
  M | Data dimensionality
  id | Label of data to copy
  N2 | Number of data copied (out)

Returns
  a new buffer with a copy of the selected data.

## ◆ vl_hikm_delete()

void vl_hikm_delete | ( | VlHIKMTree * | f | ) |

Parameters

  f | HIKM tree.

## ◆ vl_hikm_get_depth()

vl_size vl_hikm_get_depth | ( | VlHIKMTree const * | f | ) |

Parameters

  f | HIKM tree.

Returns
  depth.

## ◆ vl_hikm_get_K()

vl_size vl_hikm_get_K | ( | VlHIKMTree const * | f | ) |

Parameters

  f | HIKM tree.

Returns
  K.

## ◆ vl_hikm_get_max_niters()

vl_size vl_hikm_get_max_niters | ( | VlHIKMTree const * | f | ) |

Parameters

  f | HIKM tree.

Returns
  maximum number of iterations.

## ◆ vl_hikm_get_ndims()

vl_size vl_hikm_get_ndims | ( | VlHIKMTree const * | f | ) |

Parameters

  f | HIKM tree.

Returns
  data dimensionality.

## ◆ vl_hikm_get_root()

VlHIKMNode const * vl_hikm_get_root | ( | VlHIKMTree const * | f | ) |

Parameters

  f | HIKM tree.

Returns
  maximum number of iterations.

## ◆ vl_hikm_get_verbosity()

int vl_hikm_get_verbosity | ( | VlHIKMTree const * | f | ) |

Parameters

  f | HIKM tree.

Returns
  verbosity level.

## ◆ vl_hikm_init()

void vl_hikm_init | ( | VlHIKMTree * | f,
|  | vl_size | M,
|  | vl_size | K,
|  | vl_size | depth )

Parameters

  f | HIKM tree.
  M | Data dimensionality.
  K | Number of clusters per node.
  depth | Tree depth.

Returns
  a new HIKM tree representing the clustering.

Remarks
  depth cannot be smaller than 1.

## ◆ vl_hikm_new()

VlHIKMTree * vl_hikm_new | ( | int | method | ) |

Parameters

  method | clustering method.

Returns
  new HIKM tree.

## ◆ vl_hikm_push()

void vl_hikm_push | ( | VlHIKMTree * | f,
|  | vl_uint32 * | asgn,
|  | vl_uint8 const * | data,
|  | vl_size | N )

Parameters

  f | HIKM tree.
  asgn | Path down the tree (out).
  data | Data to project.
  N | Number of data.

The function writes to asgn the path of the data data down the HIKM tree f. The parameter asgn must point to an array of `M` by `N` elements, where `M` is the depth of the HIKM tree and `N` is the number of data point to process.

## ◆ vl_hikm_set_max_niters()

void vl_hikm_set_max_niters | ( | VlHIKMTree * | f,
|  | int | max_niters )

Parameters

  f | HIKM tree.
  max_niters | maximum number of iterations.

## ◆ vl_hikm_set_verbosity()

void vl_hikm_set_verbosity | ( | VlHIKMTree * | f,
|  | int | verb )

Parameters

  f | HIKM tree.
  verb | verbosity level.

## ◆ vl_hikm_train()

void vl_hikm_train | ( | VlHIKMTree * | f,
|  | vl_uint8 const * | data,
|  | vl_size | N )

Parameters

  f | HIKM tree.
  data | Data to cluster.
  N | Number of data.

## ◆ xdelete()

void xdelete | ( | VlHIKMNode * | node | ) |

static

Parameters

  node | to delete.

The function deletes recursively node and all its descendent.

## ◆ xmeans()

VlHIKMNode * xmeans | ( | VlHIKMTree * | tree,
|  | vl_uint8 const * | data,
|  | vl_size | N,
|  | vl_size | K,
|  | vl_size | height )

static

Parameters

  tree | HIKM tree to initialize.
  data | Data to cluster.
  N | Number of data points.
  K | Number of clusters for this node.
  height | Tree height.

Remarks
  height cannot be smaller than 1.

Returns
  a new HIKM node representing a sub-clustering.