5 instantiations of NIndex
System.Numerics.Tensors (5)
System\Buffers\NIndex.cs (5)
63public static NIndex Start => new NIndex((nint)0); 66public static NIndex End => new NIndex((nint)~0); 78return new NIndex(value); 91return new NIndex(~value); 159public static implicit operator NIndex(Index value) => new NIndex(value);
81 references to NIndex
System.Numerics.Tensors (81)
System\Buffers\NIndex.cs (28)
18public readonly struct NIndex : IEquatable<NIndex> 22/// <summary>Constructs an <see cref="NIndex"/> using an index value and a Boolean that indicates if the <see cref="NIndex"/> is from the start or from the end.</summary> 42/// <summary>Constructs an <see cref="NIndex"/> from an <see cref="Index"/>.</summary> 43/// <param name="index">The <see cref="Index"/> to create the <see cref="NIndex"/> from.</param> 62/// <summary>Creates an <see cref="NIndex"/> that points at the first element.</summary> 63public static NIndex Start => new NIndex((nint)0); 65/// <summary>Creates an <see cref="NIndex"/> that points beyond the last element.</summary> 66public static NIndex End => new NIndex((nint)~0); 68/// <summary>Creates an <see cref="NIndex"/> from the start at the specified position.</summary> 71public static NIndex FromStart(nint value) 84public static NIndex FromEnd(nint value) 95/// Converts the <see cref="NIndex"/> to an <see cref="Index"/>. 101/// Converts the <see cref="NIndex"/> to an <see cref="Index"/> without doing bounds checks. 106/// <summary>Gets the <see cref="NIndex"/> value.</summary> 118/// <summary>Gets a value that indicates whether the <see cref="NIndex"/> is from the start or the end.</summary> 126/// It is expected <see cref="NIndex"/> will be used with collections that always have a non-negative length/count. If the returned offset is negative and 127/// then used to <see cref="NIndex"/> a collection, an <see cref="ArgumentOutOfRangeException" /> is thrown, which has the same effect as the validation. 146public override bool Equals([NotNullWhen(true)] object? value) => value is NIndex other && _value == other._value; 148/// <summary>Compares the current <see cref="NIndex"/> object to another <see cref="NIndex"/> object for equality.</summary> 150public bool Equals(NIndex other) => _value == other._value; 156public static implicit operator NIndex(nint value) => FromStart(value); 159public static implicit operator NIndex(Index value) => new NIndex(value); 161/// <summary>Converts an <see cref="NIndex"/> to an <see cref="Index"/>.</summary> 162public static explicit operator Index(NIndex value) => new Index((int)value.Value, value.IsFromEnd); 164/// <summary>Converts an <see cref="NIndex"/> to an <see cref="Index"/>.</summary> 165public static explicit operator checked Index(NIndex value) => new Index(checked((int)value.Value), value.IsFromEnd);
System\Buffers\NRange.cs (15)
22public NIndex Start { get; } 25public NIndex End { get; } 27/// <summary>Constructs an <see cref="NRange"/> object using the start and end <see cref="NIndex"/>.</summary> 28/// <param name="start">The inclusive start <see cref="NIndex"/> of the <see cref="NRange"/>.</param> 29/// <param name="end">The exclusive end <see cref="NIndex"/> of the <see cref="NRange"/>.</param> 30public NRange(NIndex start, NIndex end) 92/// <summary>Creates an <see cref="NRange"/> object starting from start <see cref="NIndex"/> to the end of the collection.</summary> 93public static NRange StartAt(NIndex start) => new NRange(start, NIndex.End); 95/// <summary>Creates an <see cref="NRange"/> object starting from first element in the collection to the end <see cref="NIndex"/>.</summary> 96public static NRange EndAt(NIndex end) => new NRange(NIndex.Start, end); 99public static NRange All => new NRange(NIndex.Start, NIndex.End);
System\Numerics\Tensors\netcore\IReadOnlyTensor.cs (1)
24object? this[params scoped ReadOnlySpan<NIndex> indexes] { get; }
System\Numerics\Tensors\netcore\IReadOnlyTensor_1.cs (3)
31new ref readonly T this[params scoped ReadOnlySpan<NIndex> indexes] { get; } 46ReadOnlyTensorSpan<T> AsReadOnlyTensorSpan(params scoped ReadOnlySpan<NIndex> startIndexes); 77TSelf Slice(params scoped ReadOnlySpan<NIndex> startIndexes);
System\Numerics\Tensors\netcore\ITensor.cs (1)
24new object? this[params scoped ReadOnlySpan<NIndex> indexes] { get; set; }
System\Numerics\Tensors\netcore\ITensor_1.cs (3)
61/// <inheritdoc cref="IReadOnlyTensor{TSelf, T}.this[ReadOnlySpan{NIndex}]" /> 62new ref T this[params scoped ReadOnlySpan<NIndex> indexes] { get; } 80TensorSpan<T> AsTensorSpan(params scoped ReadOnlySpan<NIndex> startIndexes);
System\Numerics\Tensors\netcore\ReadOnlyTensorSpan_1.cs (6)
287/// <inheritdoc cref="IReadOnlyTensor{TSelf, T}.this[ReadOnlySpan{NIndex}]" /> 288public ref readonly T this[params scoped ReadOnlySpan<NIndex> indexes] 290get => ref Unsafe.Add(ref _reference, _shape.GetLinearOffset<TensorShape.GetOffsetAndLengthForNIndex, NIndex>(indexes)); 417/// <inheritdoc cref="IReadOnlyTensor{TSelf, T}.Slice(ReadOnlySpan{NIndex})" /> 418public ReadOnlyTensorSpan<T> Slice(params scoped ReadOnlySpan<NIndex> startIndexes) 420TensorShape shape = _shape.Slice<TensorShape.GetOffsetAndLengthForNIndex, NIndex>(startIndexes, out nint linearOffset);
System\Numerics\Tensors\netcore\Tensor_1.cs (13)
131/// <inheritdoc cref="TensorSpan{T}.this[ReadOnlySpan{NIndex}]" /> 132public ref T this[params scoped ReadOnlySpan<NIndex> indexes] 134get => ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(_values), _start + _shape.GetLinearOffset<TensorShape.GetOffsetAndLengthForNIndex, NIndex>(indexes)); 187/// <inheritdoc cref="IReadOnlyTensor{TSelf, T}.AsReadOnlyTensorSpan(ReadOnlySpan{NIndex})" /> 188public ReadOnlyTensorSpan<T> AsReadOnlyTensorSpan(params scoped ReadOnlySpan<NIndex> startIndexes) => AsReadOnlyTensorSpan().Slice(startIndexes); 199/// <inheritdoc cref="ITensor{TSelf, T}.AsTensorSpan(ReadOnlySpan{NIndex})" /> 200public TensorSpan<T> AsTensorSpan(params scoped ReadOnlySpan<NIndex> startIndexes) => AsTensorSpan().Slice(startIndexes); 265/// <inheritdoc cref="IReadOnlyTensor{TSelf, T}.Slice(ReadOnlySpan{NIndex})" /> 266public Tensor<T> Slice(params ReadOnlySpan<NIndex> startIndexes) 268TensorShape shape = _shape.Slice<TensorShape.GetOffsetAndLengthForNIndex, NIndex>(startIndexes, out nint linearOffset); 349object? IReadOnlyTensor.this[params scoped ReadOnlySpan<NIndex> indexes] => this[indexes]; 359ref readonly T IReadOnlyTensor<Tensor<T>, T>.this[params ReadOnlySpan<NIndex> indexes] => ref this[indexes]; 370object? ITensor.this[params scoped ReadOnlySpan<NIndex> indexes]
System\Numerics\Tensors\netcore\TensorShape.cs (3)
1330public readonly struct GetOffsetAndLengthForNIndex : IGetOffsetAndLength<NIndex> 1332public static nint GetOffset(ReadOnlySpan<NIndex> indexes, int rankIndex, nint previousLength) 1343public static (nint Offset, nint Length) GetOffsetAndLength(ReadOnlySpan<NIndex> indexes, int rankIndex, nint previousLength)
System\Numerics\Tensors\netcore\TensorSpan.cs (8)
188/// <inheritdoc cref="ITensor{TSelf, T}.this[ReadOnlySpan{NIndex}]" /> 189public ref T this[params scoped ReadOnlySpan<NIndex> indexes] 191get => ref Unsafe.Add(ref _reference, _shape.GetLinearOffset<TensorShape.GetOffsetAndLengthForNIndex, NIndex>(indexes)); 249/// <inheritdoc cref="IReadOnlyTensor{TSelf, T}.AsReadOnlyTensorSpan(ReadOnlySpan{NIndex})" /> 250public ReadOnlyTensorSpan<T> AsReadOnlyTensorSpan(params scoped ReadOnlySpan<NIndex> startIndexes) => AsReadOnlyTensorSpan().Slice(startIndexes); 314/// <inheritdoc cref="IReadOnlyTensor{TSelf, T}.Slice(ReadOnlySpan{NIndex})" /> 315public TensorSpan<T> Slice(params scoped ReadOnlySpan<NIndex> startIndexes) 317TensorShape shape = _shape.Slice<TensorShape.GetOffsetAndLengthForNIndex, NIndex>(startIndexes, out nint linearOffset);