Table of Contents

Struct np.Intersect1dResult

Namespace
NumSharp
Assembly
NumSharp.dll
The result of <xref href="NumSharp.np.intersect1d(NumSharp.NDArray%2cNumSharp.NDArray%2cSystem.Boolean%2cSystem.Boolean)" data-throw-if-not-resolved="false"></xref> — NumPy's bare-array-OR-tuple return
expressed as one type (np.unique's <xref href="NumSharp.np.UniqueResult" data-throw-if-not-resolved="false"></xref> pattern): the sorted common
<xref href="NumSharp.np.Intersect1dResult.values" data-throw-if-not-resolved="false"></xref>, plus <xref href="NumSharp.np.Intersect1dResult.comm1" data-throw-if-not-resolved="false"></xref> / <xref href="NumSharp.np.Intersect1dResult.comm2" data-throw-if-not-resolved="false"></xref> when <code>return_indices</code> was set (null
otherwise).

It stands in for both NumPy return shapes: it converts implicitly to NDArray (the bare form, the values: NDArray v = np.intersect1d(a, b);) and implicitly to NDArray[] (the tuple form, the present outputs in NumPy's order), indexes the outputs ([1] is comm1), and deconstructs: var (values, comm1, comm2) = np.intersect1d(a, b, return_indices: true);.

public readonly struct np.Intersect1dResult : INDArrayCarrier, IDisposable
Implements
Inherited Members

Remarks

API-parity batch 11 (2026-11-13): it replaces the two NDArray-returning overloads and the NDArray[]-returning one. Assignment and argument passing are unaffected (the implicit conversions); the common NDArray members forward to values (size, shape, dtype, the typed getters, ToArray<T>, array_equal), and Dispose() releases every output, so using var r = np.intersect1d(...) keeps working.

Footgun: an extension method of NDArray (FluentAssertions' Should(), a LINQ-style helper) does not see through the implicit conversion - call it on values, or assign the result to an NDArray first.

Properties

this[int]

The index-th present output in NumPy's order (values, comm1, comm2).

public NDArray this[int index] { get; }

Parameters

index int

0 for the values, 1 and 2 for the index arrays.

Property Value

NDArray

The output.

Exceptions

IndexOutOfRangeException

index is not below Length.

Length

Number of present outputs: 1, or 3 with return_indices (NumPy's tuple length).

public int Length { get; }

Property Value

int

Shape

The Shape of values.

public Shape Shape { get; }

Property Value

Shape

comm1

The indices of the first occurrences of the common values in ar1 (int64), or null when return_indices was false.

public NDArray comm1 { get; }

Property Value

NDArray

comm2

The indices of the first occurrences of the common values in ar2 (int64), or null when return_indices was false.

public NDArray comm2 { get; }

Property Value

NDArray

dtype

The descriptor of values (the two operands' common dtype).

public DType dtype { get; }

Property Value

DType

ndim

Rank of values (always 1).

public int ndim { get; }

Property Value

int

shape

Shape of values as a long[] (a copy, as shape is).

public long[] shape { get; }

Property Value

long[]

size

Element count of values.

public long size { get; }

Property Value

long

typecode

The storage lane of values.

public NPTypeCode typecode { get; }

Property Value

NPTypeCode

values

The sorted 1-D array of common (unique) values. Always present.

public NDArray values { get; }

Property Value

NDArray

Methods

Deconstruct(out NDArray, out NDArray, out NDArray)

Deconstructs a return_indices=True result: var (values, comm1, comm2) = ....

public void Deconstruct(out NDArray values, out NDArray comm1, out NDArray comm2)

Parameters

values NDArray

The common values.

comm1 NDArray

The first-occurrence indices in ar1.

comm2 NDArray

The first-occurrence indices in ar2.

Exceptions

InvalidOperationException

The result holds only the values (Python's not enough values to unpack (expected 3, got 1)).

Dispose()

Releases every present output (the values and the index arrays): the using form of a result the caller is done with.

public void Dispose()

Remarks

Disposing the struct disposes the arrays it shares with every copy of it and with any variable the implicit conversions filled - dispose once, when none of them is read again.

GetAtIndex(long)

The element of values at a flat index, boxed in its own type.

public object GetAtIndex(long index)

Parameters

index long

The flat index.

Returns

object

The element.

GetDouble(int[])

The double value of values at the given coordinates.

public double GetDouble(int[] indices)

Parameters

indices int[]

The coordinates.

Returns

double

The element read as a double.

GetDouble(params long[])

The double value of values at the given coordinates.

public double GetDouble(params long[] indices)

Parameters

indices long[]

The coordinates.

Returns

double

The element read as a double.

GetInt32(params long[])

The int value of values at the given coordinates.

public int GetInt32(params long[] indices)

Parameters

indices long[]

The coordinates.

Returns

int

The element read as an int.

GetInt64(params long[])

The long value of values at the given coordinates.

public long GetInt64(params long[] indices)

Parameters

indices long[]

The coordinates.

Returns

long

The element read as a long.

ToArray()

The present outputs as an NDArray[] in NumPy's order.

public NDArray[] ToArray()

Returns

NDArray[]

The outputs array (the struct's own; do not mutate it).

ToArray<T>()

The elements of values as a new T[] in C order.

public T[] ToArray<T>() where T : unmanaged

Returns

T[]

A new managed array.

Type Parameters

T

The element type to read (it must be the dtype's own type, as ToArray<T>() requires).

Exceptions

ArgumentException

T is not the values' element type.

array_equal(NDArray)

True if values equals rhs element-wise (same shape).

public bool array_equal(NDArray rhs)

Parameters

rhs NDArray

The array to compare with.

Returns

bool

Whether the shapes and elements are equal.

Operators

implicit operator NDArray(Intersect1dResult)

Bare-return conversion: the values (NumPy's single-array return).

public static implicit operator NDArray(np.Intersect1dResult result)

Parameters

result np.Intersect1dResult

The result.

Returns

NDArray

values.

implicit operator NDArray[](Intersect1dResult)

Tuple-return conversion: the present outputs, NumPy's order.

public static implicit operator NDArray[](np.Intersect1dResult result)

Parameters

result np.Intersect1dResult

The result.

Returns

NDArray[]

The outputs array.