5 instantiations of NIndex
System.Numerics.Tensors (5)
System\Buffers\NIndex.cs (5)
62
public static NIndex Start => new
NIndex
((nint)0);
65
public static NIndex End => new
NIndex
((nint)~0);
77
return new
NIndex
(value);
90
return new
NIndex
(~value);
158
public static implicit operator NIndex(Index value) => new
NIndex
(value);
113 references to NIndex
System.Numerics.Tensors (113)
System\Buffers\NIndex.cs (28)
17
public 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>
62
public static
NIndex
Start => new NIndex((nint)0);
64
/// <summary>Creates an <see cref="
NIndex
"/> that points beyond the last element.</summary>
65
public static
NIndex
End => new NIndex((nint)~0);
67
/// <summary>Creates an <see cref="
NIndex
"/> from the start at the specified position.</summary>
70
public static
NIndex
FromStart(nint value)
83
public 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.
145
public 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>
149
public bool Equals(
NIndex
other) => _value == other._value;
155
public static implicit operator
NIndex
(nint value) => FromStart(value);
158
public static implicit operator
NIndex
(Index value) => new NIndex(value);
160
/// <summary>Converts an <see cref="
NIndex
"/> to an <see cref="Index"/>.</summary>
161
public 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>
164
public static explicit operator checked Index(
NIndex
value) => new Index(checked((int)value.Value), value.IsFromEnd);
System\Buffers\NRange.cs (15)
21
public
NIndex
Start { get; }
24
public
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>
29
public 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>
92
public 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>
95
public static NRange EndAt(
NIndex
end) => new NRange(
NIndex
.Start, end);
98
public static NRange All => new NRange(
NIndex
.Start,
NIndex
.End);
System\Numerics\Tensors\netcore\IReadOnlyTensor_1.cs (5)
28
new ref readonly T this[params scoped ReadOnlySpan<
NIndex
> indexes] { get; }
43
ReadOnlyTensorSpan<T> AsReadOnlyTensorSpan(params scoped ReadOnlySpan<
NIndex
> startIndexes);
85
ReadOnlySpan<T> GetSpan(scoped ReadOnlySpan<
NIndex
> startIndexes, int length);
94
TSelf Slice(params scoped ReadOnlySpan<
NIndex
> startIndexes);
140
bool TryGetSpan(scoped ReadOnlySpan<
NIndex
> startIndexes, int length, out ReadOnlySpan<T> span);
System\Numerics\Tensors\netcore\IReadOnlyTensor.cs (1)
23
object? this[params scoped ReadOnlySpan<
NIndex
> indexes] { get; }
System\Numerics\Tensors\netcore\ITensor_1.cs (7)
59
/// <inheritdoc cref="IReadOnlyTensor{TSelf, T}.this[ReadOnlySpan{
NIndex
}]" />
60
new ref T this[params scoped ReadOnlySpan<
NIndex
> indexes] { get; }
78
TensorSpan<T> AsTensorSpan(params scoped ReadOnlySpan<
NIndex
> startIndexes);
97
/// <inheritdoc cref="IReadOnlyTensor{TSelf, T}.GetSpan(ReadOnlySpan{
NIndex
}, int)" />
98
new Span<T> GetSpan(scoped ReadOnlySpan<
NIndex
> startIndexes, int length);
103
/// <inheritdoc cref="IReadOnlyTensor{TSelf, T}.TryGetSpan(ReadOnlySpan{
NIndex
}, int, out ReadOnlySpan{T})" />
104
bool TryGetSpan(scoped ReadOnlySpan<
NIndex
> startIndexes, int length, out Span<T> span);
System\Numerics\Tensors\netcore\ITensor.cs (1)
22
new object? this[params scoped ReadOnlySpan<
NIndex
> indexes] { get; set; }
System\Numerics\Tensors\netcore\ReadOnlyTensorSpan_1.cs (13)
262
/// <inheritdoc cref="IReadOnlyTensor{TSelf, T}.this[ReadOnlySpan{
NIndex
}]" />
263
public ref readonly T this[params scoped ReadOnlySpan<
NIndex
> indexes]
265
get => ref Unsafe.Add(ref _reference, _shape.GetLinearOffset<TensorShape.GetOffsetAndLengthForNIndex,
NIndex
>(indexes));
398
/// <inheritdoc cref="IReadOnlyTensor{TSelf, T}.GetSpan(ReadOnlySpan{
NIndex
}, int)" />
399
public ReadOnlySpan<T> GetSpan(scoped ReadOnlySpan<
NIndex
> startIndexes, int length)
418
/// <inheritdoc cref="IReadOnlyTensor{TSelf, T}.Slice(ReadOnlySpan{
NIndex
})" />
419
public ReadOnlyTensorSpan<T> Slice(params scoped ReadOnlySpan<
NIndex
> startIndexes)
421
TensorShape shape = _shape.Slice<TensorShape.GetOffsetAndLengthForNIndex,
NIndex
>(startIndexes, out nint linearOffset);
492
/// <inheritdoc cref="IReadOnlyTensor{TSelf, T}.TryGetSpan(ReadOnlySpan{
NIndex
}, int, out ReadOnlySpan{T})" />
493
public bool TryGetSpan(scoped ReadOnlySpan<
NIndex
> startIndexes, int length, out ReadOnlySpan<T> span)
496
nint longestContiguousLength = _shape.GetLongestContiguousLength<TensorShape.GetOffsetAndLengthForNIndex,
NIndex
>(startIndexes, out nint linearOffset);
512
object? IReadOnlyTensor.this[params scoped ReadOnlySpan<
NIndex
> indexes] => this[indexes];
524
ReadOnlyTensorSpan<T> IReadOnlyTensor<ReadOnlyTensorSpan<T>, T>.AsReadOnlyTensorSpan(params scoped ReadOnlySpan<
NIndex
> startIndexes) => Slice(startIndexes);
System\Numerics\Tensors\netcore\Tensor_1.cs (20)
89
/// <inheritdoc cref="TensorSpan{T}.this[ReadOnlySpan{
NIndex
}]" />
90
public ref T this[params scoped ReadOnlySpan<
NIndex
> indexes]
92
get => ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(_values), _start + _shape.GetLinearOffset<TensorShape.GetOffsetAndLengthForNIndex,
NIndex
>(indexes));
145
/// <inheritdoc cref="IReadOnlyTensor{TSelf, T}.AsReadOnlyTensorSpan(ReadOnlySpan{
NIndex
})" />
146
public ReadOnlyTensorSpan<T> AsReadOnlyTensorSpan(params scoped ReadOnlySpan<
NIndex
> startIndexes) => AsReadOnlyTensorSpan().Slice(startIndexes);
157
/// <inheritdoc cref="ITensor{TSelf, T}.AsTensorSpan(ReadOnlySpan{
NIndex
})" />
158
public TensorSpan<T> AsTensorSpan(params scoped ReadOnlySpan<
NIndex
> startIndexes) => AsTensorSpan().Slice(startIndexes);
209
/// <inheritdoc cref="ITensor{TSelf, T}.GetSpan(ReadOnlySpan{
NIndex
}, int)" />
210
public Span<T> GetSpan(scoped ReadOnlySpan<
NIndex
> startIndexes, int length) => AsTensorSpan().GetSpan(startIndexes, length);
235
/// <inheritdoc cref="IReadOnlyTensor{TSelf, T}.Slice(ReadOnlySpan{
NIndex
})" />
236
public Tensor<T> Slice(params ReadOnlySpan<
NIndex
> startIndexes)
238
TensorShape shape = _shape.Slice<TensorShape.GetOffsetAndLengthForNIndex,
NIndex
>(startIndexes, out nint linearOffset);
288
/// <inheritdoc cref="ITensor{TSelf, T}.TryGetSpan(ReadOnlySpan{
NIndex
}, int, out Span{T})" />
289
public bool TryGetSpan(scoped ReadOnlySpan<
NIndex
> startIndexes, int length, out Span<T> span) => AsTensorSpan().TryGetSpan(startIndexes, length, out span);
294
/// <inheritdoc cref="IReadOnlyTensor{TSelf, T}.TryGetSpan(ReadOnlySpan{
NIndex
}, int, out ReadOnlySpan{T})" />
295
public bool TryGetSpan(scoped ReadOnlySpan<
NIndex
> startIndexes, int length, out ReadOnlySpan<T> span) => AsReadOnlyTensorSpan().TryGetSpan(startIndexes, length, out span);
319
object? IReadOnlyTensor.this[params scoped ReadOnlySpan<
NIndex
> indexes] => this[indexes];
329
ref readonly T IReadOnlyTensor<Tensor<T>, T>.this[params ReadOnlySpan<
NIndex
> indexes] => ref this[indexes];
337
ReadOnlySpan<T> IReadOnlyTensor<Tensor<T>, T>.GetSpan(scoped ReadOnlySpan<
NIndex
> startIndexes, int length) => AsReadOnlyTensorSpan().GetSpan(startIndexes, length);
345
object? ITensor.this[params scoped ReadOnlySpan<
NIndex
> indexes]
System\Numerics\Tensors\netcore\TensorShape.cs (3)
1581
public readonly struct GetOffsetAndLengthForNIndex : IGetOffsetAndLength<
NIndex
>
1583
public static nint GetOffset(
NIndex
index, nint length)
1594
public static (nint Offset, nint Length) GetOffsetAndLength(
NIndex
index, nint length)
System\Numerics\Tensors\netcore\TensorSpan_1.cs (20)
156
/// <inheritdoc cref="ITensor{TSelf, T}.this[ReadOnlySpan{
NIndex
}]" />
157
public ref T this[params scoped ReadOnlySpan<
NIndex
> indexes]
159
get => ref Unsafe.Add(ref _reference, _shape.GetLinearOffset<TensorShape.GetOffsetAndLengthForNIndex,
NIndex
>(indexes));
220
/// <inheritdoc cref="IReadOnlyTensor{TSelf, T}.AsReadOnlyTensorSpan(ReadOnlySpan{
NIndex
})" />
221
public ReadOnlyTensorSpan<T> AsReadOnlyTensorSpan(params scoped ReadOnlySpan<
NIndex
> startIndexes) => AsReadOnlyTensorSpan().Slice(startIndexes);
288
/// <inheritdoc cref="ITensor{TSelf, T}.GetSpan(ReadOnlySpan{
NIndex
}, int)" />
289
public Span<T> GetSpan(scoped ReadOnlySpan<
NIndex
> startIndexes, int length)
308
/// <inheritdoc cref="IReadOnlyTensor{TSelf, T}.Slice(ReadOnlySpan{
NIndex
})" />
309
public TensorSpan<T> Slice(params scoped ReadOnlySpan<
NIndex
> startIndexes)
311
TensorShape shape = _shape.Slice<TensorShape.GetOffsetAndLengthForNIndex,
NIndex
>(startIndexes, out nint linearOffset);
356
/// <inheritdoc cref="ITensor{TSelf, T}.TryGetSpan(ReadOnlySpan{
NIndex
}, int, out Span{T})" />
357
public bool TryGetSpan(scoped ReadOnlySpan<
NIndex
> startIndexes, int length, out Span<T> span)
360
nint longestContiguousLength = _shape.GetLongestContiguousLength<TensorShape.GetOffsetAndLengthForNIndex,
NIndex
>(startIndexes, out nint linearOffset);
375
/// <inheritdoc cref="IReadOnlyTensor{TSelf, T}.TryGetSpan(ReadOnlySpan{
NIndex
}, int, out ReadOnlySpan{T})" />
376
public bool TryGetSpan(scoped ReadOnlySpan<
NIndex
> startIndexes, int length, out ReadOnlySpan<T> span) => AsReadOnlyTensorSpan().TryGetSpan(startIndexes, length, out span);
382
object? IReadOnlyTensor.this[params scoped ReadOnlySpan<
NIndex
> indexes] => this[indexes];
390
ref readonly T IReadOnlyTensor<TensorSpan<T>, T>.this[params scoped ReadOnlySpan<
NIndex
> indexes] => ref this[indexes];
400
ReadOnlySpan<T> IReadOnlyTensor<TensorSpan<T>, T>.GetSpan(scoped ReadOnlySpan<
NIndex
> startIndexes, int length) => AsReadOnlyTensorSpan().GetSpan(startIndexes, length);
421
object? ITensor.this[params scoped ReadOnlySpan<
NIndex
> indexes]
459
TensorSpan<T> ITensor<TensorSpan<T>, T>.AsTensorSpan(params scoped ReadOnlySpan<
NIndex
> startIndexes) => Slice(startIndexes);