Documentation>C API
Functions
ikmeans.c File Reference

Integer K-Means clustering - Definition. More...

`#include "ikmeans.h"`
`#include <stdlib.h>`
`#include <stdio.h>`
`#include <string.h>`
`#include "assert.h"`
`#include "ikmeans_init.tc"`
`#include "ikmeans_lloyd.tc"`
`#include "ikmeans_elkan.tc"`

## Functions

VlIKMFilt * | vl_ikm_new (int method)
| Create a new IKM quantizer.
void | vl_ikm_delete (VlIKMFilt *f)
| Delete IKM quantizer.
int | vl_ikm_train (VlIKMFilt *f, vl_uint8 const *data, vl_size N)
| Train clusters.
void | vl_ikm_push (VlIKMFilt *f, vl_uint32 *asgn, vl_uint8 const *data, vl_size N)
| Project data to clusters.
vl_uint32 | vl_ikm_push_one (vl_ikmacc_t const *centers, vl_uint8 const *data, vl_size M, vl_size K)
| Project one datum to clusters.
vl_size | vl_ikm_get_ndims (VlIKMFilt const *f)
| Get data dimensionality.
vl_size | vl_ikm_get_K (VlIKMFilt const *f)
| Get the number of centers K.
int | vl_ikm_get_verbosity (VlIKMFilt const *f)
| Get verbosity level.
vl_size | vl_ikm_get_max_niters (VlIKMFilt const *f)
| Get maximum number of iterations.
vl_ikmacc_t const * | vl_ikm_get_centers (VlIKMFilt const *f)
| Get maximum number of iterations.
void | vl_ikm_set_verbosity (VlIKMFilt *f, int verb)
| Set verbosity level.
void | vl_ikm_set_max_niters (VlIKMFilt *f, vl_size max_niters)
| Set maximum number of iterations.

## Detailed Description

Author
  Brian Fulkerson
  Andrea Vedaldi

## Function Documentation

## ◆ vl_ikm_delete()

void vl_ikm_delete | ( | VlIKMFilt * | f | ) |

Parameters

  f | IKM quantizer.

## ◆ vl_ikm_get_centers()

vl_ikmacc_t const * vl_ikm_get_centers | ( | VlIKMFilt const * | f | ) |

Parameters

  f | IKM filter.

Returns
  maximum number of iterations.

## ◆ vl_ikm_get_K()

vl_size vl_ikm_get_K | ( | VlIKMFilt const * | f | ) |

Parameters

  f | IKM filter.

Returns
  number of centers K.

## ◆ vl_ikm_get_max_niters()

vl_size vl_ikm_get_max_niters | ( | VlIKMFilt const * | f | ) |

Parameters

  f | IKM filter.

Returns
  maximum number of iterations.

## ◆ vl_ikm_get_ndims()

vl_size vl_ikm_get_ndims | ( | VlIKMFilt const * | f | ) |

Parameters

  f | IKM filter.

Returns
  data dimensionality.

## ◆ vl_ikm_get_verbosity()

int vl_ikm_get_verbosity | ( | VlIKMFilt const * | f | ) |

Parameters

  f | IKM filter.

Returns
  verbosity level.

## ◆ vl_ikm_new()

VlIKMFilt * vl_ikm_new | ( | int | method | ) |

Parameters

  method | Clustering algorithm.

Returns
  new IKM quantizer.

The function allocates initializes a new IKM quantizer to operate based algorithm method.

method has values in the enumerations VlIKMAlgorithms.

## ◆ vl_ikm_push()

void vl_ikm_push | ( | VlIKMFilt * | f,
|  | vl_uint32 * | asgn,
|  | vl_uint8 const * | data,
|  | vl_size | N )

Parameters

  f | IKM quantizer.
  asgn | Assignments (out).
  data | data.
  N | number of data (N `>=` 1).

The function projects the data data on the integer K-means clusters specified by the IKM quantizer f. Notice that the quantizer must be initialized.

## ◆ vl_ikm_push_one()

vl_uint32 vl_ikm_push_one | ( | vl_ikmacc_t const * | centers,
|  | vl_uint8 const * | data,
|  | vl_size | M,
|  | vl_size | K )

Parameters

  centers | centers.
  data | datum to project.
  K | number of centers.
  M | dimensionality of the datum.

Returns
  the cluster index.

The function projects the specified datum data on the clusters specified by the centers centers.

## ◆ vl_ikm_set_max_niters()

void vl_ikm_set_max_niters | ( | VlIKMFilt * | f,
|  | vl_size | max_niters )

Parameters

  f | IKM filter.
  max_niters | maximum number of iterations.

## ◆ vl_ikm_set_verbosity()

void vl_ikm_set_verbosity | ( | VlIKMFilt * | f,
|  | int | verb )

Parameters

  f | IKM filter.
  verb | verbosity level.

## ◆ vl_ikm_train()

int vl_ikm_train | ( | VlIKMFilt * | f,
|  | vl_uint8 const * | data,
|  | vl_size | N )

Parameters

  f | IKM quantizer.
  data | data.
  N | number of data (N `>=` 1).

Returns
  -1 if an overflow may have occurred.