5 instantiations of NIndex
System.Numerics.Tensors (5)
System\Buffers\NIndex.cs (5)
62public static NIndex Start => new NIndex((nint)0); 65public static NIndex End => new NIndex((nint)~0); 77return new NIndex(value); 90return new NIndex(~value); 158public static implicit operator NIndex(Index value) => new NIndex(value);
87 references to NIndex
System.Numerics.Tensors (87)
System\Buffers\NIndex.cs (28)
17public readonly struct NIndex : IEquatable<NIndex> 21/// <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> 41/// <summary>Constructs an <see cref="NIndex"/> from an <see cref="Index"/>.</summary> 42/// <param name="index">The <see cref="Index"/> to create the <see cref="NIndex"/> from.</param> 61/// <summary>Creates an <see cref="NIndex"/> that points at the first element.</summary> 62public static NIndex Start => new NIndex((nint)0); 64/// <summary>Creates an <see cref="NIndex"/> that points beyond the last element.</summary> 65public static NIndex End => new NIndex((nint)~0); 67/// <summary>Creates an <see cref="NIndex"/> from the start at the specified position.</summary> 70public static NIndex FromStart(nint value) 83public static NIndex FromEnd(nint value) 94/// Converts the <see cref="NIndex"/> to an <see cref="Index"/>. 100/// Converts the <see cref="NIndex"/> to an <see cref="Index"/> without doing bounds checks. 105/// <summary>Gets the <see cref="NIndex"/> value.</summary> 117/// <summary>Gets a value that indicates whether the <see cref="NIndex"/> is from the start or the end.</summary> 125/// 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 126/// then used to <see cref="NIndex"/> a collection, an <see cref="ArgumentOutOfRangeException" /> is thrown, which has the same effect as the validation. 145public override bool Equals([NotNullWhen(true)] object? value) => value is NIndex other && _value == other._value; 147/// <summary>Compares the current <see cref="NIndex"/> object to another <see cref="NIndex"/> object for equality.</summary> 149public bool Equals(NIndex other) => _value == other._value; 155public static implicit operator NIndex(nint value) => FromStart(value); 158public static implicit operator NIndex(Index value) => new NIndex(value); 160/// <summary>Converts an <see cref="NIndex"/> to an <see cref="Index"/>.</summary> 161public static explicit operator Index(NIndex value) => new Index((int)value.Value, value.IsFromEnd); 163/// <summary>Converts an <see cref="NIndex"/> to an <see cref="Index"/>.</summary> 164public static explicit operator checked Index(NIndex value) => new Index(checked((int)value.Value), value.IsFromEnd);
System\Buffers\NRange.cs (15)
21public NIndex Start { get; } 24public NIndex End { get; } 26/// <summary>Constructs an <see cref="NRange"/> object using the start and end <see cref="NIndex"/>.</summary> 27/// <param name="start">The inclusive start <see cref="NIndex"/> of the <see cref="NRange"/>.</param> 28/// <param name="end">The exclusive end <see cref="NIndex"/> of the <see cref="NRange"/>.</param> 29public NRange(NIndex start, NIndex end) 91/// <summary>Creates an <see cref="NRange"/> object starting from start <see cref="NIndex"/> to the end of the collection.</summary> 92public static NRange StartAt(NIndex start) => new NRange(start, NIndex.End); 94/// <summary>Creates an <see cref="NRange"/> object starting from first element in the collection to the end <see cref="NIndex"/>.</summary> 95public static NRange EndAt(NIndex end) => new NRange(NIndex.Start, end); 98public static NRange All => new NRange(NIndex.Start, NIndex.End);
System\Numerics\Tensors\netcore\IReadOnlyTensor.cs (1)
23object? 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); 82TSelf Slice(params scoped ReadOnlySpan<NIndex> startIndexes);
System\Numerics\Tensors\netcore\ITensor.cs (1)
23new object? this[params scoped ReadOnlySpan<NIndex> indexes] { get; set; }
System\Numerics\Tensors\netcore\ITensor_1.cs (3)
62/// <inheritdoc cref="IReadOnlyTensor{TSelf, T}.this[ReadOnlySpan{NIndex}]" /> 63new ref T this[params scoped ReadOnlySpan<NIndex> indexes] { get; } 81TensorSpan<T> AsTensorSpan(params scoped ReadOnlySpan<NIndex> startIndexes);
System\Numerics\Tensors\netcore\ReadOnlyTensorSpan_1.cs (8)
259/// <inheritdoc cref="IReadOnlyTensor{TSelf, T}.this[ReadOnlySpan{NIndex}]" /> 260public ref readonly T this[params scoped ReadOnlySpan<NIndex> indexes] 262get => ref Unsafe.Add(ref _reference, _shape.GetLinearOffset<TensorShape.GetOffsetAndLengthForNIndex, NIndex>(indexes)); 395/// <inheritdoc cref="IReadOnlyTensor{TSelf, T}.Slice(ReadOnlySpan{NIndex})" /> 396public ReadOnlyTensorSpan<T> Slice(params scoped ReadOnlySpan<NIndex> startIndexes) 398TensorShape shape = _shape.Slice<TensorShape.GetOffsetAndLengthForNIndex, NIndex>(startIndexes, out nint linearOffset); 446object? IReadOnlyTensor.this[params scoped ReadOnlySpan<NIndex> indexes] => this[indexes]; 458ReadOnlyTensorSpan<T> IReadOnlyTensor<ReadOnlyTensorSpan<T>, T>.AsReadOnlyTensorSpan(params scoped ReadOnlySpan<NIndex> startIndexes) => Slice(startIndexes);
System\Numerics\Tensors\netcore\Tensor_1.cs (13)
86/// <inheritdoc cref="TensorSpan{T}.this[ReadOnlySpan{NIndex}]" /> 87public ref T this[params scoped ReadOnlySpan<NIndex> indexes] 89get => ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(_values), _start + _shape.GetLinearOffset<TensorShape.GetOffsetAndLengthForNIndex, NIndex>(indexes)); 142/// <inheritdoc cref="IReadOnlyTensor{TSelf, T}.AsReadOnlyTensorSpan(ReadOnlySpan{NIndex})" /> 143public ReadOnlyTensorSpan<T> AsReadOnlyTensorSpan(params scoped ReadOnlySpan<NIndex> startIndexes) => AsReadOnlyTensorSpan().Slice(startIndexes); 154/// <inheritdoc cref="ITensor{TSelf, T}.AsTensorSpan(ReadOnlySpan{NIndex})" /> 155public TensorSpan<T> AsTensorSpan(params scoped ReadOnlySpan<NIndex> startIndexes) => AsTensorSpan().Slice(startIndexes); 223/// <inheritdoc cref="IReadOnlyTensor{TSelf, T}.Slice(ReadOnlySpan{NIndex})" /> 224public Tensor<T> Slice(params ReadOnlySpan<NIndex> startIndexes) 226TensorShape shape = _shape.Slice<TensorShape.GetOffsetAndLengthForNIndex, NIndex>(startIndexes, out nint linearOffset); 305object? IReadOnlyTensor.this[params scoped ReadOnlySpan<NIndex> indexes] => this[indexes]; 315ref readonly T IReadOnlyTensor<Tensor<T>, T>.this[params ReadOnlySpan<NIndex> indexes] => ref this[indexes]; 327object? ITensor.this[params scoped ReadOnlySpan<NIndex> indexes]
System\Numerics\Tensors\netcore\TensorShape.cs (3)
1236public readonly struct GetOffsetAndLengthForNIndex : IGetOffsetAndLength<NIndex> 1238public static nint GetOffset(NIndex index, nint length) 1249public static (nint Offset, nint Length) GetOffsetAndLength(NIndex index, nint length)
System\Numerics\Tensors\netcore\TensorSpan_1.cs (12)
159/// <inheritdoc cref="ITensor{TSelf, T}.this[ReadOnlySpan{NIndex}]" /> 160public ref T this[params scoped ReadOnlySpan<NIndex> indexes] 162get => ref Unsafe.Add(ref _reference, _shape.GetLinearOffset<TensorShape.GetOffsetAndLengthForNIndex, NIndex>(indexes)); 223/// <inheritdoc cref="IReadOnlyTensor{TSelf, T}.AsReadOnlyTensorSpan(ReadOnlySpan{NIndex})" /> 224public ReadOnlyTensorSpan<T> AsReadOnlyTensorSpan(params scoped ReadOnlySpan<NIndex> startIndexes) => AsReadOnlyTensorSpan().Slice(startIndexes); 291/// <inheritdoc cref="IReadOnlyTensor{TSelf, T}.Slice(ReadOnlySpan{NIndex})" /> 292public TensorSpan<T> Slice(params scoped ReadOnlySpan<NIndex> startIndexes) 294TensorShape shape = _shape.Slice<TensorShape.GetOffsetAndLengthForNIndex, NIndex>(startIndexes, out nint linearOffset); 325object? IReadOnlyTensor.this[params scoped ReadOnlySpan<NIndex> indexes] => this[indexes]; 333ref readonly T IReadOnlyTensor<TensorSpan<T>, T>.this[params scoped ReadOnlySpan<NIndex> indexes] => ref this[indexes]; 360object? ITensor.this[params scoped ReadOnlySpan<NIndex> indexes] 398TensorSpan<T> ITensor<TensorSpan<T>, T>.AsTensorSpan(params scoped ReadOnlySpan<NIndex> startIndexes) => Slice(startIndexes);