Table of Contents

Class NDIter

Namespace
NumSharp.Backends.Iteration
Assembly
NumSharp.dll

Static iterator helper methods (backward compatible API).

NUMSHARP DIVERGENCE: These methods support unlimited dimensions via dynamic allocation. Dimension arrays are allocated on demand and freed after use.

public static class NDIter
Inheritance
NDIter
Inherited Members

Methods

Advance(long*, long*, long*, int, ref long)

public static void Advance(long* shape, long* strides, long* coords, int ndim, ref long offset)

Parameters

shape long*
strides long*
coords long*
ndim int
offset long

CoalesceAxes(ref NDIterState, long*, long*, long*)

public static void CoalesceAxes(ref NDIterState state, long* shape, long* srcStrides, long* dstStrides)

Parameters

state NDIterState
shape long*
srcStrides long*
dstStrides long*

Copy(UnmanagedStorage, UnmanagedStorage)

Copy src into dst with full support for broadcast, stride, and cross-dtype conversion.

Drop-in replacement for the legacy MultiIterator.Assign(dst, src): matches its broadcast-src-to-dst-shape semantics and its cast-on-write behavior (read src as src.TypeCode, convert, write dst.TypeCode).

public static void Copy(UnmanagedStorage dst, UnmanagedStorage src)

Parameters

dst UnmanagedStorage
src UnmanagedStorage

Exceptions

NumSharpException

If dst is not writeable (e.g., broadcast view).

Copy(NDArray, NDArray)

Copy src into dst with full support for broadcast, stride, and cross-dtype conversion.

Drop-in replacement for the legacy MultiIterator.Assign(dst, src): matches its broadcast-src-to-dst-shape semantics and its cast-on-write behavior (read src as src.TypeCode, convert, write dst.TypeCode).

public static void Copy(NDArray dst, NDArray src)

Parameters

dst NDArray
src NDArray

Exceptions

NumSharpException

If dst is not writeable (e.g., broadcast view).

CopyAs(NPTypeCode, NDArray, char, TensorEngine)

The unified allocate-and-fill core for copying, retyping, and casting. Allocates a fresh array of dstType whose physical layout follows order (NumPy C/F/A/K resolved via NumSharp.OrderResolver), then fills it from src through the in-place Copy(NDArray, NDArray) primitive. Every elementwise concern — broadcast, arbitrary strides, transpose, and cross-dtype conversion — is absorbed by the NDIter copy core, so a single call covers ndarray.copy(), astype(), and Clone() alike.

public static NDArray CopyAs(NPTypeCode dstType, NDArray src, char order = 'K', TensorEngine engine = null)

Parameters

dstType NPTypeCode

dtype of the result (equal to src's dtype for a plain copy/retype).

src NDArray

source array of any layout (contiguous, sliced, strided, broadcast, transposed, scalar, empty).

order char

'C' (row-major), 'F' (column-major), 'A' ('F' iff src is F-contiguous and not C), or 'K' (default; KEEPORDER — mirror src contiguity, matching NumPy astype order='K').

engine TensorEngine

tensor engine assigned to the result; defaults to src's engine.

Returns

NDArray

A freshly allocated, owning array of dstType holding src's values.

Exceptions

ArgumentNullException

src is null.

CreateCopyState(UnmanagedStorage, UnmanagedStorage)

Create state for copy operation. IMPORTANT: Caller must call state.FreeDimArrays() when done!

public static NDIterState CreateCopyState(UnmanagedStorage src, UnmanagedStorage dst)

Parameters

src UnmanagedStorage
dst UnmanagedStorage

Returns

NDIterState

CreateReductionState(UnmanagedStorage)

Create state for reduction operation. IMPORTANT: Caller must call state.FreeDimArrays() when done!

public static NDIterState CreateReductionState(UnmanagedStorage src)

Parameters

src UnmanagedStorage

Returns

NDIterState

IsContiguous(long*, long*, int)

public static bool IsContiguous(long* shape, long* strides, int ndim)

Parameters

shape long*
strides long*
ndim int

Returns

bool

ReduceBool<T, TKernel>(UnmanagedStorage)

public static bool ReduceBool<T, TKernel>(UnmanagedStorage src) where T : unmanaged where TKernel : struct, INDBooleanReductionKernel<T>

Parameters

src UnmanagedStorage

Returns

bool

Type Parameters

T
TKernel

ReduceBool<T, TKernel>(NDArray)

public static bool ReduceBool<T, TKernel>(NDArray src) where T : unmanaged where TKernel : struct, INDBooleanReductionKernel<T>

Parameters

src NDArray

Returns

bool

Type Parameters

T
TKernel

TryCopySameType(UnmanagedStorage, UnmanagedStorage)

public static bool TryCopySameType(UnmanagedStorage dst, UnmanagedStorage src)

Parameters

dst UnmanagedStorage
src UnmanagedStorage

Returns

bool

TryCopySameType(NDArray, NDArray)

public static bool TryCopySameType(NDArray dst, NDArray src)

Parameters

dst NDArray
src NDArray

Returns

bool

UpdateLayoutFlags(ref NDIterState, long*, long*, long*)

public static void UpdateLayoutFlags(ref NDIterState state, long* shape, long* srcStrides, long* dstStrides)

Parameters

state NDIterState
shape long*
srcStrides long*
dstStrides long*