Class np.Broadcast
- Namespace
- NumSharp
- Assembly
- NumSharp.dll
NumPy's numpy.broadcast — the broadcast result of N operands, usable as an
iterator. Like NumPy, the object is its OWN iterator (iter(b) is b): it keeps a
single live cursor exposed as index, iterating it yields one tuple of
per-operand values per step (advancing the cursor), and reset() rewinds it.
public class np.Broadcast : IEnumerable<object[]>, IEnumerable, IEnumerator<object[]>, IEnumerator, IDisposable
- Inheritance
-
np.Broadcast
- Implements
- Inherited Members
- Extension Methods
Constructors
Broadcast()
Parameterless constructor retained for source/binary compatibility (the public surface previously exposed an implicit one). An instance built this way has no operands, so iters stays null unless explicitly assigned.
public Broadcast()
Properties
Current
The tuple of per-operand values produced by the most recent step (one per numiter).
public object[] Current { get; }
Property Value
- object[]
index
The live flat position of the iterator (NumPy's broadcast.index): the number
of elements already consumed — 0 before iterating, incrementing by one per step, and
equal to size once exhausted. Use reset() to rewind.
public int index { get; }
Property Value
iters
Per-operand flat iterators (NumPy's broadcast.iters): one entry per input,
each iterating that operand broadcast to the result shape in C-order
(e.g. np.broadcast([1,2,3], [[10],[20]]).iters[0] yields 1,2,3,1,2,3). Built lazily
on first access — np.broadcast() only resolves the shape eagerly — and backed by
broadcast_to(NDArray, Shape) + NDFlatIterator, the
NDIter-aligned replacement for the removed NDIterator. There are numiter
entries (0 when constructed without operands). Unlike NumPy's flatiters these are
independent and re-enumerable; they do not share the index cursor.
public NDFlatIterator[] iters { get; }
Property Value
nd
public int nd { get; }
Property Value
ndim
public int ndim { get; }
Property Value
numiter
Number of operands being broadcast together (NumPy's broadcast.numiter,
equal to len(iters)). Equals the operand count passed to
broadcast(params NDArray[]) (0 for the parameterless constructor).
public int numiter { get; }
Property Value
shape
public Shape shape { get; }
Property Value
size
public long size { get; }
Property Value
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
GetEnumerator()
Returns the broadcast itself as its iterator — matching NumPy's iter(b) is b,
so iteration shares the single index cursor (call reset()
to iterate again).
public IEnumerator<object[]> GetEnumerator()
Returns
MoveNext()
Advances the cursor one element and reads each operand's value at that flat (C-order) position into Current. Returns false once index reaches size (or when constructed without operands).
public bool MoveNext()
Returns
reset()
NumPy's broadcast.reset(): rewind the live index cursor to 0
so the object can be iterated again.
public void reset()