nuget server logo nuget api documents
↑

API Docs / Microsoft.VisualBasic.DataMining.UMAP / Heaps

Heaps

Full name Microsoft.VisualBasic.DataMining.UMAP.Heaps Assembly Microsoft.VisualBasic.DataMining.UMAP Members 11

01 Syntax

Microsoft.VisualBasic.DataMining.UMAP.Heaps

02 Methods

NameOverloadsSummary
MakeHeap 1 Constructor for the heap objects.
MakeArrays 1 allocate a nPoints-by-size matrix and then fill it with the given fillValue
HeapPush 1 Push a new element onto the heap.
UncheckedHeapPush 1 Push a new element onto the heap.
HeapPushPair 1 Push the symmetric neighbours pair (rowA -> rowB) and (rowB -> rowA) onto the heap in a thread safe manner.
BuildCandidates 1 Build a heap of candidate neighbors for nearest neighbor descent.
DeHeapSort 1 Given an array of heaps (of indices and weights), unpack the heap out to give and array of sorted lists of indices and weights by increasing weight.
SortHeapRow 1 unpack one heap row out to a sorted list of indices by increasing weight (the second half of the heap sort)
ToIntMatrix 1 convert the indices matrix of the heap from double to integer
SiftDown 1 Restore the heap property for a heap with an out of place element at position elt.
SmallestFlagged 1 Search the heap for the smallest element that is still flagged

03 Members

method MakeHeap #
MakeHeap(Int32, Int32)

Constructor for the heap objects. The heaps are used for approximate nearest neighbor search, maintaining a list of potential neighbors sorted by their distance.We also flag if potential neighbors are newly added to the list or not.Internally this is stored as a single array; the first axis determines whether we are looking at the array of candidate indices, the array of distances, or the flag array for whether elements are new or not.Each of these arrays are of shape (nPoints, size)

method MakeArrays #
MakeArrays(Double, Int32, Int32)

allocate a nPoints-by-size matrix and then fill it with the given fillValue

method HeapPush #
HeapPush(Heap, Int32, Double, Int32, Int32)

Push a new element onto the heap. The heap stores potential neighbors for each data point.The row parameter determines which data point we are addressing, the weight determines the distance (for heap sorting), the index is the element to add, and the flag determines whether this is to be considered a new addition.

method UncheckedHeapPush #
UncheckedHeapPush(Heap, Int32, Double, Int32, Int32)

Push a new element onto the heap. The heap stores potential neighbors for each data point. The row parameter determines which data point we are addressing, the weight determines the distance (for heap sorting), the index is the element to add, and the flag determines whether this is to be considered a new addition.

method HeapPushPair #
HeapPushPair(Heap, Object(), Int32, Int32, Double, Int32)

Push the symmetric neighbours pair (rowA -> rowB) and (rowB -> rowA) onto the heap in a thread safe manner.

Remarks

the two lock objects are always acquired in the ascending order of the stripe index, so that the dead lock is impossible.

Parameters
NameTypeDescription
heapHeap

-

locksObject()

a striped lock array which is created via the Utils.NewStripedLocks() function.

rowAInt32

-

rowBInt32

-

weightDouble

-

flagInt32

-

Returns

the number of the elements that have been pushed onto the heap: 0, 1 or 2.

method BuildCandidates #
BuildCandidates(Heap, Int32, Int32, Int32, IProvideRandomValues, ParallelConfig)

Build a heap of candidate neighbors for nearest neighbor descent. For each vertex the candidate neighbors are any current neighbors, and any vertices that have the vertex as one of their nearest neighbors.

Parameters
NameTypeDescription
parallelismHeap

the parallelism configuration, the candidate heap will be built in parallel when the size of the graph is large enough.

method DeHeapSort #
DeHeapSort(Heap, ParallelConfig)

Given an array of heaps (of indices and weights), unpack the heap out to give and array of sorted lists of indices and weights by increasing weight. This is effectively just the second half of heap sort (the first half not being required since we already have the data in a heap).

Parameters
NameTypeDescription
parallelismHeap

the parallelism configuration. Each row of the heap is sorted independently, so this procedure could be done in parallel without any lock.

method SortHeapRow #
SortHeapRow(Double(), Double())

unpack one heap row out to a sorted list of indices by increasing weight (the second half of the heap sort)

Remarks

this procedure only touches the two given rows, so that it is safe for run it in parallel for each row of the heap.

Parameters
NameTypeDescription
indHeapDouble()

the row of the neighbour indices, this row will be modified in place.

distHeapDouble()

the row of the neighbour distances, this row will be modified in place.

method ToIntMatrix #
ToIntMatrix(Double()(), ParallelConfig)

convert the indices matrix of the heap from double to integer

method SiftDown #
SiftDown(Double(), Double(), Int32, Int32)

Restore the heap property for a heap with an out of place element at position elt. This works with a heap pair where heap1 carries the weights and heap2 holds the corresponding elements.

method SmallestFlagged #
SmallestFlagged(Heap, Int32)

Search the heap for the smallest element that is still flagged