Returns the `neighborCount` nearest indices and distances for the sample at the specified index.
The function returns `neighborCount` indices and distances.
- Parameter index: The index of the sample that the function returns the nearest neighbors.
Pass `nil` to specify that the function returns the `neighborCount` nearest indices and distances
for each sample.
- Parameter outputIndices: The output indices descriptor. This must have a data type of
`Int32` with a `vector` shape with size `neighborCount`. If `index` is `nil`, it must have
the size size `neighborCount * sampleCount`.
- Parameter outputDistances: The output distances descriptor. This must have a data type of
`Float` with a `vector` shape with size `neighborCount`. If `index` is `nil`, it must have
the size size `neighborCount * sampleCount`.
- Precondition: `index` must be greater than or equal to zero and less than `sampleCount`.
method · iOS 17.0+
append
TypeScript
append(samples: BNNSNDArrayDescriptor): void
Swift declaration
func append(samples: BNNSNDArrayDescriptor)
Appends the samples.
- Parameter samples: A `BNNSNDArrayDescriptor` that contains the sample data. Pass
a matrix with the first dimension set to the number of samples and the second dimension set to the
number of features (dimensions). For example, eight two dimensional samples requires a descriptor
with the shape `matrixRowMajor(8, 2)`.
- Precondition: The total number of samples must not exceed `capacity`.
- Precondition: The `samples` descriptor must have a rank of two.
Initializes a new `NearestNeighbors` structure with the specifies sample capacity.
- Parameter capacity: The memory to allocate counted in samples.
- Parameter dimensionCount: The number of features or dimensions of each sample.
- Parameter neighborCount: The number of neighbors that the `nearestNeighbors`
function returns.
- Parameter dataType: The data type of the data. This must me either `float` or `float16`.