Clustering
C++20 header-only: DBSCAN, HDBSCAN, k-means.
Loading...
Searching...
No Matches
clustering Namespace Reference

Namespaces

namespace  hdbscan
namespace  index
namespace  kmeans
namespace  math
namespace  detail

Classes

class  DBSCAN
 Density-based clustering over the eps-neighborhood graph produced by a clustering::index::RangeIndex backend. More...
class  HDBSCAN
 Hierarchical density-based clustering over mutual-reachability distances. More...
class  BruteForcePairwise
 Range-index backend that builds the full eps-neighborhood adjacency in one fused pairwise sweep. More...
struct  KDTreeNode
 Node in a KDTree, sharing the same struct shape between internals and leaves. More...
class  KDTree
 Implements a KDTree data structure. More...
class  KMeans
 Lloyd-family k-means. More...
class  UnionFind
 Disjoint-set-union with iterative path compression and union-by-rank. More...
class  BinaryHeap
 Binary min-heap of (key, val) pairs ordered on key. More...
class  IndexedHeap
 Binary min-heap keyed on Key with O(1) handle-to-position lookup. More...
class  LinearAllocator
class  NewAllocator
 Thin wrapper over new T / delete that satisfies the library's allocator concept. More...
class  NDArray
 Represents a multidimensional array (NDArray) of a fixed number of dimensions N and element type T. More...
struct  Range
 Half-open index range with optional positive step for slicing an NDArray axis. More...

Enumerations

enum class  KDTreeDistanceType : std::uint8_t { kEucledian }
 Distance metric a KDTree builds pruning bounds under. More...
enum class  NDArrayStorage : std::uint8_t { Owned , Borrowed }
 Tag indicating whether an NDArray owns its buffer or borrows memory from elsewhere. More...
enum class  Layout : std::uint8_t { Contig , MaybeStrided }
 Compile-time layout tag for NDArray. More...

Functions

void alwaysAssertFail (const char *cond, const char *file, int line) noexcept
 Emits a diagnostic to stderr and terminates via std::abort.
template<class T, std::size_t NA, Layout LA, std::size_t NB, Layout LB>
bool sameStorage (const NDArray< T, NA, LA > &a, const NDArray< T, NB, LB > &b) noexcept
 Returns true when a and b share the same underlying allocation.
constexpr Range all ()
 Sentinel value meaning "take every element of this axis".

Enumeration Type Documentation

◆ KDTreeDistanceType

enum class clustering::KDTreeDistanceType : std::uint8_t
strong

Distance metric a KDTree builds pruning bounds under.

Additional flavours (Manhattan, Cosine, etc.) would extend this enum and dispatch new overloads of the pivot-to-child inequality used during pruning.

Enumerator
kEucledian 

Squared Euclidean; radii and comparisons run on squared distances.

Definition at line 61 of file kdtree.h.

◆ Layout

enum class clustering::Layout : std::uint8_t
strong

Compile-time layout tag for NDArray.

Contig guarantees row-major contiguous storage with zero offset. Instances of this layout expose the chain-of-accessors operator[] and use the baseline flat-index formula in the hot path. MaybeStrided makes no contiguity guarantee; only the variadic operator() is available for element access, and it consults m_strides and m_offset.

The split is a type-level precondition: calling a[i] on a MaybeStrided array is a compile error, not a runtime check.

Enumerator
Contig 
MaybeStrided 

Definition at line 122 of file ndarray.h.

◆ NDArrayStorage

enum class clustering::NDArrayStorage : std::uint8_t
strong

Tag indicating whether an NDArray owns its buffer or borrows memory from elsewhere.

Enumerator
Owned 
Borrowed 

Definition at line 109 of file ndarray.h.

Function Documentation

◆ all()

Range clustering::all ( )
constexpr

Sentinel value meaning "take every element of this axis".

Definition at line 26 of file ndarray_range.h.

◆ alwaysAssertFail()

void clustering::alwaysAssertFail ( const char * cond,
const char * file,
int line )
inlinenoexcept

Emits a diagnostic to stderr and terminates via std::abort.

The format is fixed ("clustering: always-assert failed: <cond> at <file>:<line>\n") so death tests can match the output with a stable regex. std::abort is chosen over std::terminate so GoogleTest's EXPECT_DEATH catches the signal without routing through the terminate handler.

Definition at line 16 of file always_assert.h.

◆ sameStorage()

template<class T, std::size_t NA, Layout LA, std::size_t NB, Layout LB>
bool clustering::sameStorage ( const NDArray< T, NA, LA > & a,
const NDArray< T, NB, LB > & b )
noexcept

Returns true when a and b share the same underlying allocation.

Every view verb propagates the parent's base pointer; fresh Owned allocations (including clone and the non-contiguous reshape / contiguous fallbacks) install a new base. Two siblings produced from the same source therefore both test true against each other and against their source, regardless of which pointer-advancing verb produced them.

Definition at line 1106 of file ndarray.h.