Table of Contents

Class Arrays

Namespace
NumSharp.Utilities
Assembly
NumSharp.dll
public static class Arrays
Inheritance
Arrays
Inherited Members

Methods

AppendAt<T>(T[], int, T)

Inserts item into a specific index.

public static T[] AppendAt<T>(T[] source, int index, T value)

Parameters

source T[]

The array to insert copy and insert value to.

index int

The index to insert to.

value T

Returns

T[]

a copy of source with the appended value.

Type Parameters

T

Concat<T>(T[], T[])

Performs fast concatenation of multiple arrays

public static T[] Concat<T>(T[] left, T[] right)

Parameters

left T[]
right T[]

Returns

T[]

Type Parameters

T

Concat<T>(params T[][])

Performs fast concatenation of multiple arrays

public static T[] Concat<T>(params T[][] arrays)

Parameters

arrays T[][]

Returns

T[]

Type Parameters

T

CopyToExceptAt<T>(T[], int, int, T[], int)

Copies an array contents except for a specific index.

public static void CopyToExceptAt<T>(this T[] source, int sourceOffset, int index, T[] destinition, int destOffset = 0)

Parameters

source T[]

The array to copy from.

sourceOffset int
index int

The index to ignore.

destinition T[]

The copying destinition

destOffset int

The destinition's offset

Type Parameters

T

CopyToExceptAt<T>(T[], int, T[], int)

Copies an array contents except for a specific index.

public static void CopyToExceptAt<T>(this T[] source, int index, T[] destinition, int destOffset = 0)

Parameters

source T[]

The array to copy from.

index int

The index to ignore.

destinition T[]

The copying destinition

destOffset int

The destinition's offset

Type Parameters

T

Create(NPTypeCode, int)

Creates an array of 1D of type typeCode.

public static Array Create(NPTypeCode typeCode, int length)

Parameters

typeCode NPTypeCode

The type to create this array.

length int

The length of the array

Returns

Array

Remarks

Do not use this if you are trying to create jagged or multidimensional array.

Create(Type, IEnumerable)

Creates an array of 1D of type type.

public static Array Create(Type type, IEnumerable enumerable)

Parameters

type Type

The type to create this array.

enumerable IEnumerable

Returns

Array

Remarks

Do not use this if you are trying to create jagged or multidimensional array.

Create(Type, int)

Creates an array of 1D of type type.

public static Array Create(Type type, int length)

Parameters

type Type

The type to create this array.

length int

The length of the array

Returns

Array

Remarks

Do not use this if you are trying to create jagged or multidimensional array.

Create(Type, int[])

Creates an array of specific length of type type.

public static Array Create(Type type, int[] length)

Parameters

type Type

The type to create this array.

length int[]

The length of the array

Returns

Array

Create<T>(int)

Creates an array 1D of type T.

public static T[] Create<T>(int length)

Parameters

length int

The length of the array

Returns

T[]

Type Parameters

T

The type of the array

ExtractStructure(Array)

Extracts shape and type from given array.

public static (Shape Shape, Type DType) ExtractStructure(Array array)

Parameters

array Array

The array to extract DType and Shape from.

Returns

(Shape Shape, Type Type)

ExtractStructure<T>(T[])

Extracts shape and type from given array.

public static (Shape Shape, Type DType) ExtractStructure<T>(T[] array)

Parameters

array T[]

The array to extract DType and Shape from.

Returns

(Shape Shape, Type Type)

Type Parameters

T

Flatten(Array)

Flattens any type of Array.

public static Array Flatten(Array array)

Parameters

array Array

Returns

Array

Remarks

Supports both jagged array and multi-dim arrays.

Insert<T>(T[], int, T)

Inserts item into a specific index.

public static T[] Insert<T>(T[] source, int index, T value) where T : unmanaged

Parameters

source T[]

The array to insert the value to.

index int

The index to insert to.

value T

Returns

T[]

Type Parameters

T

Insert<T>(ref T[], int, T)

Inserts item into a specific index.

public static void Insert<T>(ref T[] source, int index, T value)

Parameters

source T[]

The array to insert the value to.

index int

The index to insert to.

value T

Type Parameters

T

RemoveAt<T>(T[], int)

Removes a specific index from given array.

public static T[] RemoveAt<T>(this T[] source, int index)

Parameters

source T[]

The array to remove index from.

index int

The index to remove.

Returns

T[]

A copy of source without given index

Type Parameters

T

ResolveElementType(Array)

Resolves Array element type recusivly.

public static Type ResolveElementType(this Array arr)

Parameters

arr Array

Returns

Type

ResolveRank(Array)

Resolves Array's rank, supports both jagged array and multidim array.

public static int ResolveRank(this Array arr)

Parameters

arr Array

Returns

int

The number of ranks arr has

ResolveShape(Array)

Resolves the shape of this given array.

public static Shape ResolveShape(this Array array)

Parameters

array Array

Returns

Shape

Remarks

Supports multi-dim and jagged arrays.

ResolveShapeAndType(Array)

Resolves the shape of this given array.

public static (Shape Shape, Type Type) ResolveShapeAndType(this Array array)

Parameters

array Array

Returns

(Shape Shape, Type Type)

Remarks

Supports multi-dim and jagged arrays.

Slice<T>(T[], int, int)

Slice an array.

public static T[] Slice<T>(this T[] source, int start, int end)

Parameters

source T[]
start int
end int

Returns

T[]

Type Parameters

T

Remarks

Supports negative end index

Slice<T>(T[], long, long)

Slice an array.

public static T[] Slice<T>(this T[] source, long start, long end)

Parameters

source T[]
start long
end long

Returns

T[]

Type Parameters

T

Remarks

Supports negative end index

Wrap(NPTypeCode, object)

Creates an array of 1D of type typeCode with length of 1 and a single value inside.

public static Array Wrap(NPTypeCode typeCode, object value)

Parameters

typeCode NPTypeCode

The type to create this array.

value object

The value to insert

Returns

Array

Remarks

Do not use this if you are trying to create jagged or multidimensional array.