Table of Contents

Class ArraySlicingRoutines

Namespace
NeuralNetworks.Core
Assembly
NeuralNetworks.dll

Provides array slicing and row/column manipulation routines for supported multidimensional array types.

public static class ArraySlicingRoutines
Inheritance
ArraySlicingRoutines
Inherited Members

Remarks

Includes extension methods for selecting rows, columns, and ranges across dimensions, splitting row sets by ratio, and writing row values back into arrays. Most slicing operations return new arrays rather than views.

Methods

GetColumn(float[,], int)

Gets a submatrix containing the specified column from the current source. The shape is [rows, 1].

public static float[,] GetColumn(this float[,] source, int column)

Parameters

source float[,]

The array to slice.

column int

The zero-based column index.

Returns

float[,]

A new [rows, 1] array representing the selected column.

GetColumns(float[,], Range)

Gets a submatrix containing the specified range of columns from the current source. The shape is [rows, range].

public static float[,] GetColumns(this float[,] source, Range range)

Parameters

source float[,]

The array to slice.

range Range

The range specifying the subset of columns.

Returns

float[,]

A new array with [rows, selectedColumns].

GetRow(float[,,,], int)

Gets a three-dimensional slice (row) from a four-dimensional array at the specified first-dimension index.

public static float[,,] GetRow(this float[,,,] source, int row)

Parameters

source float[,,,]

The four-dimensional array to slice.

row int

The zero-based index along dimension 0.

Returns

float[,,]

A new three-dimensional array with shape [dim1, dim2, dim3] containing the selected row.

GetRow(float[,], int)

Gets a row from the source.

public static float[] GetRow(this float[,] source, int row)

Parameters

source float[,]

The two-dimensional array to slice.

row int

The index of the row to retrieve.

Returns

float[]

A new array representing the specified row.

Remarks

The returned row is a new instance and has the same number of columns as the original source.

GetRowAs2D(float[,], int)

Gets the specified row as a two-dimensional array with shape [1, columns].

public static float[,] GetRowAs2D(this float[,] source, int row)

Parameters

source float[,]

The two-dimensional array to slice.

row int

The zero-based row index.

Returns

float[,]

A new [1, columns] array containing the row values.

GetRows(int[,], Range)

public static int[,] GetRows(this int[,] source, Range range)

Parameters

source int[,]
range Range

Returns

int[,]

GetRows(float[,,,], Range)

Gets a contiguous range of rows from a four-dimensional array.

public static float[,,,] GetRows(this float[,,,] source, Range range)

Parameters

source float[,,,]

The four-dimensional array to slice.

range Range

The range applied to rows.

Returns

float[,,,]

A new four-dimensional array containing the selected rows.

GetRows(float[,,], Range)

Gets a contiguous range of rows from a three-dimensional array.

public static float[,,] GetRows(this float[,,] source, Range range)

Parameters

source float[,,]

The three-dimensional array to slice.

range Range

The range applied to rows.

Returns

float[,,]

A new three-dimensional array containing the selected rows.

GetRows(float[,], Range)

Gets a submatrix containing the specified range of rows from the current source.

public static float[,] GetRows(this float[,] source, Range range)

Parameters

source float[,]

The array to slice.

range Range

The range of rows to retrieve.

Returns

float[,]

A new array representing the submatrix.

Remarks

The returned columns are the same as in the original source.

SetRow(float[,,,], int, float[,,])

Sets the three-dimensional row slice at the specified index in a four-dimensional array.

public static void SetRow(this float[,,,] source, int rowIndex, float[,,] row)

Parameters

source float[,,,]

The four-dimensional array to modify.

rowIndex int

The zero-based index along dimension 0 to set.

row float[,,]

A three-dimensional array with shape [dim1, dim2, dim3] providing values.

SetRow(float[,], int, float[])

Sets the values of a specific row in the source.

public static void SetRow(this float[,] source, int rowIndex, float[] row)

Parameters

source float[,]

The two-dimensional array to modify.

rowIndex int

The index of the row to set.

row float[]

The array containing the values to set. Length must equal the number of columns.

SliceDim0<T>(T, int, int)

public static T SliceDim0<T>(T source, int startInclusive, int endExclusive) where T : notnull

Parameters

source T
startInclusive int
endExclusive int

Returns

T

Type Parameters

T

SplitRowsByRatio(float[,], float)

Splits the source into two sets of dim1 based on the specified ratio.

public static (float[,] Set1, float[,] Set2) SplitRowsByRatio(this float[,] source, float ratio)

Parameters

source float[,]

The two-dimensional array to split.

ratio float

The ratio for splitting the dim1.

Returns

(float[,] Set1, float[,] Set2)

A tuple containing the two sets of dim1.