Table of Contents

Class np.RClass

Namespace
NumSharp
Assembly
NumSharp.dll

Translates slice expressions to concatenation along the FIRST axis. Two use cases: comma-separated arrays are stacked along axis 0, and slice notation or scalars build a 1-D array.

public sealed class np.RClass : np.AxisConcatenator
Inheritance
np.RClass
Inherited Members

Examples

np.r_[np.array(new[] {1, 2, 3}), 0, 0, np.array(new[] {4, 5, 6})];  // [1 2 3 0 0 4 5 6]
np.r_["-1:1:6j", new[] {0, 0, 0}, 5, 6];   // [-1 -0.6 -0.2 0.2 0.6 1 0 0 0 5 6]
np.r_["0,2", new[] {1, 2, 3}, new[] {4, 5, 6}];  // [[1 2 3] [4 5 6]]
np.r_["-1", a, a];                          // concatenate along the last axis

Remarks

Port of NumPy 2.x numpy.r_. Slice notation "start:stop:step" is np.arange(start, stop, step); an imaginary step ("start:stop:Nj") is np.linspace(start, stop, N) with the stop INCLUSIVE. After expansion everything is concatenated.

An optional leading directive string changes the output. "r" / "c" coerce to a 2-D matrix (a 1-D result becomes 1×N for "r" and N×1 for "c"; a 2-D result is unchanged). An integer string selects the axis to stack along. Two comma-separated integers also set the minimum dimensionality each entry is forced to; a third says which axis the upgraded entries' original axes should start at (default -1, i.e. the 1s are prepended).

See np.AxisConcatenator for how slices are spelled in C# and how weak scalars are mapped. https://numpy.org/doc/stable/reference/generated/numpy.r_.html