Table of Contents

Namespace NumSharp.Utilities

Classes

ArrayConvert

Presents all possible combinations of array conversion of types supported by numpy.

Arrays
ArraysExtensions
ConcurrentHashset<T>
Converts

Provides various methods related to Convert.

Converts<T>

Provides various methods related to Convert based on give T.

Hashset<T>

Implementation notes: This uses an array-based implementation similar to Dictionary<T>, using a buckets array to map hash values to the Slots array. Items in the Slots array that hash to the same value are chained together through the "next" indices.

This implementation supports long indexing for collections exceeding int.MaxValue elements.

The capacity is always prime; so during resizing, the capacity is chosen as the next prime greater than double the last capacity (or 33% growth for very large sets above 1 billion elements).

The underlying data structures are lazily initialized. Because of the observation that, in practice, hashtables tend to contain only a few elements, the initial capacity is set very small (3 elements) unless the ctor with a collection is used.

The +/- 1 modifications in methods that add, check for containment, etc allow us to distinguish a hash code of 0 from an uninitialized bucket. This saves us from having to reset each bucket to -1 when resizing. See Contains, for example.

Set methods such as UnionWith, IntersectWith, ExceptWith, and SymmetricExceptWith modify this set.

Some operations can perform faster if we can assume "other" contains unique elements according to this equality comparer. The only times this is efficient to check is if other is a hashset. Note that checking that it's a hashset alone doesn't suffice; we also have to check that the hashset is using the same equality comparer. If other has a different equality comparer, it will have unique elements according to its own equality comparer, but not necessarily according to ours. Therefore, to go these optimized routes we check that other is a hashset using the same equality comparer.

A HashSet with no elements has the properties of the empty set. (See IsSubset, etc. for special empty set checks.)

A couple of methods have a special case if other is this (e.g. SymmetricExceptWith). If we didn't have these checks, we could be iterating over the set and modifying at the same time.

InfoOf<T>

Provides a cache for properties of T that requires computation.

NDCoordinatesAxisIncrementor
NDCoordinatesIncrementor
NDCoordinatesIncrementorAutoResetting
NDCoordinatesLeftToAxisIncrementor
NDExtendedCoordinatesIncrementor
NDOffsetIncrementor
NDOffsetIncrementorAutoresetting
NonGenericConvert

Provides a way to convert boxed object from known time to specific type.

NumberInfo
SteppingExtension
TypelessConvert

Provides a way to convert boxed object from known input type to known output type. By making it receive and return object - It is suitable for a common delegate: see TypelessConvertDelegate

UnmanagedBuffer

Provides low-level memory copy operations for unmanaged types.

UnmanagedSpanExtensions

Extension methods for UnmanagedSpan{T} and ReadOnlyUnmanagedSpan{T}. These provide SIMD-accelerated operations where possible. All methods support full 64-bit indexing natively.

py

Implements Python utility functions that are often used in connection with numpy

Structs

Hashset<T>.Enumerator
ReadOnlyUnmanagedSpan<T>

ReadOnlyUnmanagedSpan represents a contiguous region of arbitrary memory. Unlike arrays, it can point to either managed or native memory, or to memory allocated on the stack. It is type-safe and memory-safe.

ReadOnlyUnmanagedSpan<T>.Enumerator

Enumerates the elements of a ReadOnlyUnmanagedSpan<T>.

UnmanagedSpan<T>

UnmanagedSpan represents a contiguous region of arbitrary memory. Unlike arrays, it can point to either managed or native memory, or to memory allocated on the stack. It is type-safe and memory-safe.

UnmanagedSpan<T>.Enumerator

Enumerates the elements of a UnmanagedSpan<T>.

ValueCoordinatesIncrementor
ValueCoordinatesIncrementorAutoResetting
ValueOffsetIncrementor
ValueOffsetIncrementorAutoresetting

Delegates

TypelessConvertDelegate
ValueCoordinatesIncrementor.EndCallbackHandler