This commit is contained in:
Tanner Gooding 2025-07-30 13:06:15 +02:00 committed by GitHub
commit e6e44a62a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
24 changed files with 2016 additions and 549 deletions

View File

@ -315,6 +315,8 @@ namespace System.Numerics.Tensors
public static System.Numerics.Tensors.Tensor<T> CreateFromShape<T>(scoped System.ReadOnlySpan<nint> lengths, scoped System.ReadOnlySpan<nint> strides, bool pinned = false) { throw null; }
public static System.Numerics.Tensors.Tensor<T> CreateFromShapeUninitialized<T>(scoped System.ReadOnlySpan<nint> lengths, bool pinned = false) { throw null; }
public static System.Numerics.Tensors.Tensor<T> CreateFromShapeUninitialized<T>(scoped System.ReadOnlySpan<nint> lengths, scoped System.ReadOnlySpan<nint> strides, bool pinned = false) { throw null; }
public static System.Numerics.Tensors.Tensor<T> Decrement<T>(in System.Numerics.Tensors.ReadOnlyTensorSpan<T> x) where T : System.Numerics.IDecrementOperators<T> { throw null; }
public static ref readonly System.Numerics.Tensors.TensorSpan<T> Decrement<T>(scoped in System.Numerics.Tensors.ReadOnlyTensorSpan<T> x, in System.Numerics.Tensors.TensorSpan<T> destination) where T : System.Numerics.IDecrementOperators<T> { throw null; }
public static System.Numerics.Tensors.Tensor<T> DegreesToRadians<T>(in System.Numerics.Tensors.ReadOnlyTensorSpan<T> x) where T : System.Numerics.ITrigonometricFunctions<T> { throw null; }
public static ref readonly System.Numerics.Tensors.TensorSpan<T> DegreesToRadians<T>(scoped in System.Numerics.Tensors.ReadOnlyTensorSpan<T> x, in System.Numerics.Tensors.TensorSpan<T> destination) where T : System.Numerics.ITrigonometricFunctions<T> { throw null; }
public static T Distance<T>(scoped in System.Numerics.Tensors.ReadOnlyTensorSpan<T> x, scoped in System.Numerics.Tensors.ReadOnlyTensorSpan<T> y) where T : System.Numerics.IRootFunctions<T> { throw null; }
@ -385,6 +387,8 @@ namespace System.Numerics.Tensors
public static ref readonly System.Numerics.Tensors.TensorSpan<T> Ieee754Remainder<T>(T x, scoped in System.Numerics.Tensors.ReadOnlyTensorSpan<T> y, in System.Numerics.Tensors.TensorSpan<T> destination) where T : System.Numerics.IFloatingPointIeee754<T> { throw null; }
public static System.Numerics.Tensors.Tensor<int> ILogB<T>(in System.Numerics.Tensors.ReadOnlyTensorSpan<T> x) where T : System.Numerics.IFloatingPointIeee754<T> { throw null; }
public static ref readonly System.Numerics.Tensors.TensorSpan<int> ILogB<T>(scoped in System.Numerics.Tensors.ReadOnlyTensorSpan<T> x, in System.Numerics.Tensors.TensorSpan<int> destination) where T : System.Numerics.IFloatingPointIeee754<T> { throw null; }
public static System.Numerics.Tensors.Tensor<T> Increment<T>(in System.Numerics.Tensors.ReadOnlyTensorSpan<T> x) where T : System.Numerics.IIncrementOperators<T> { throw null; }
public static ref readonly System.Numerics.Tensors.TensorSpan<T> Increment<T>(scoped in System.Numerics.Tensors.ReadOnlyTensorSpan<T> x, in System.Numerics.Tensors.TensorSpan<T> destination) where T : System.Numerics.IIncrementOperators<T> { throw null; }
public static nint IndexOfMaxMagnitude<T>(scoped in System.Numerics.Tensors.ReadOnlyTensorSpan<T> x) where T : System.Numerics.INumber<T> { throw null; }
public static nint IndexOfMax<T>(scoped in System.Numerics.Tensors.ReadOnlyTensorSpan<T> x) where T : System.Numerics.INumber<T> { throw null; }
public static nint IndexOfMinMagnitude<T>(scoped in System.Numerics.Tensors.ReadOnlyTensorSpan<T> x) where T : System.Numerics.INumber<T> { throw null; }
@ -523,6 +527,12 @@ namespace System.Numerics.Tensors
public static bool SequenceEqual<T>(this scoped in System.Numerics.Tensors.TensorSpan<T> tensor, scoped in System.Numerics.Tensors.ReadOnlyTensorSpan<T> other) where T : System.IEquatable<T>? { throw null; }
public static ref readonly System.Numerics.Tensors.TensorSpan<T> SetSlice<T>(this in System.Numerics.Tensors.TensorSpan<T> tensor, scoped in System.Numerics.Tensors.ReadOnlyTensorSpan<T> values, params scoped System.ReadOnlySpan<System.Buffers.NRange> ranges) { throw null; }
public static System.Numerics.Tensors.Tensor<T> SetSlice<T>(this System.Numerics.Tensors.Tensor<T> tensor, in System.Numerics.Tensors.ReadOnlyTensorSpan<T> values, params scoped System.ReadOnlySpan<System.Buffers.NRange> ranges) { throw null; }
public static Tensor<T> ShiftLeft<T>(in ReadOnlyTensorSpan<T> x, int shiftAmount) where T : IShiftOperators<T, int, T> { throw null; }
public static ref readonly TensorSpan<T> ShiftLeft<T>(scoped in ReadOnlyTensorSpan<T> x, int shiftAmount, in TensorSpan<T> destination) where T : IShiftOperators<T, int, T> { throw null; }
public static Tensor<T> ShiftRightArithmetic<T>(in ReadOnlyTensorSpan<T> x, int shiftAmount) where T : IShiftOperators<T, int, T> { throw null; }
public static ref readonly TensorSpan<T> ShiftRightArithmetic<T>(scoped in ReadOnlyTensorSpan<T> x, int shiftAmount, in TensorSpan<T> destination) where T : IShiftOperators<T, int, T> { throw null; }
public static Tensor<T> ShiftRightLogical<T>(in ReadOnlyTensorSpan<T> x, int shiftAmount) where T : IShiftOperators<T, int, T> { throw null; }
public static ref readonly TensorSpan<T> ShiftRightLogical<T>(scoped in ReadOnlyTensorSpan<T> x, int shiftAmount, in TensorSpan<T> destination) where T : IShiftOperators<T, int, T> { throw null; }
public static System.Numerics.Tensors.Tensor<T> Sigmoid<T>(in System.Numerics.Tensors.ReadOnlyTensorSpan<T> x) where T : System.Numerics.IExponentialFunctions<T> { throw null; }
public static ref readonly System.Numerics.Tensors.TensorSpan<T> Sigmoid<T>(scoped in System.Numerics.Tensors.ReadOnlyTensorSpan<T> x, in System.Numerics.Tensors.TensorSpan<T> destination) where T : System.Numerics.IExponentialFunctions<T> { throw null; }
public static System.Numerics.Tensors.Tensor<T> Sinh<T>(in System.Numerics.Tensors.ReadOnlyTensorSpan<T> x) where T : System.Numerics.IHyperbolicFunctions<T> { throw null; }
@ -578,6 +588,318 @@ namespace System.Numerics.Tensors
public static ref readonly System.Numerics.Tensors.TensorSpan<T> Xor<T>(scoped in System.Numerics.Tensors.ReadOnlyTensorSpan<T> x, scoped in System.Numerics.Tensors.ReadOnlyTensorSpan<T> y, in System.Numerics.Tensors.TensorSpan<T> destination) where T : System.Numerics.IBitwiseOperators<T, T, T> { throw null; }
public static System.Numerics.Tensors.Tensor<T> Xor<T>(in System.Numerics.Tensors.ReadOnlyTensorSpan<T> x, T y) where T : System.Numerics.IBitwiseOperators<T, T, T> { throw null; }
public static ref readonly System.Numerics.Tensors.TensorSpan<T> Xor<T>(scoped in System.Numerics.Tensors.ReadOnlyTensorSpan<T> x, T y, in System.Numerics.Tensors.TensorSpan<T> destination) where T : System.Numerics.IBitwiseOperators<T, T, T> { throw null; }
extension<TScalar>(System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar>)
where TScalar : System.Numerics.IAdditionOperators<TScalar, TScalar, TScalar>, System.Numerics.IAdditiveIdentity<TScalar, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator +(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> left, in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator +(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> left, TScalar right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator +(TScalar left, in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> right) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.Tensor<TScalar> tensor)
where TScalar : System.Numerics.IAdditionOperators<TScalar, TScalar, TScalar>, System.Numerics.IAdditiveIdentity<TScalar, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator +(System.Numerics.Tensors.Tensor<TScalar> left, System.Numerics.Tensors.Tensor<TScalar> right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator +(System.Numerics.Tensors.Tensor<TScalar> left, TScalar right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator +(TScalar left, System.Numerics.Tensors.Tensor<TScalar> right) { throw null; }
public void operator +=(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> other) { throw null; }
public void operator +=(TScalar other) { throw null; }
}
extension<TScalar>(ref System.Numerics.Tensors.TensorSpan<TScalar> tensor)
where TScalar : System.Numerics.IAdditionOperators<TScalar, TScalar, TScalar>, System.Numerics.IAdditiveIdentity<TScalar, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator +(in System.Numerics.Tensors.TensorSpan<TScalar> left, in System.Numerics.Tensors.TensorSpan<TScalar> right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator +(in System.Numerics.Tensors.TensorSpan<TScalar> left, TScalar right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator +(TScalar left, in System.Numerics.Tensors.TensorSpan<TScalar> right) { throw null; }
public void operator +=(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> other) { throw null; }
public void operator +=(TScalar other) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar>)
where TScalar : System.Numerics.IBitwiseOperators<TScalar, TScalar, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator &(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> left, in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator &(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> left, TScalar right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator &(TScalar left, in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> right) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.Tensor<TScalar> tensor)
where TScalar : System.Numerics.IBitwiseOperators<TScalar, TScalar, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator &(System.Numerics.Tensors.Tensor<TScalar> left, System.Numerics.Tensors.Tensor<TScalar> right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator &(System.Numerics.Tensors.Tensor<TScalar> left, TScalar right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator &(TScalar left, System.Numerics.Tensors.Tensor<TScalar> right) { throw null; }
public void operator &=(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> other) { throw null; }
public void operator &=(TScalar other) { throw null; }
}
extension<TScalar>(ref System.Numerics.Tensors.TensorSpan<TScalar> tensor)
where TScalar : System.Numerics.IBitwiseOperators<TScalar, TScalar, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator &(in System.Numerics.Tensors.TensorSpan<TScalar> left, in System.Numerics.Tensors.TensorSpan<TScalar> right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator &(in System.Numerics.Tensors.TensorSpan<TScalar> left, TScalar right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator &(TScalar left, in System.Numerics.Tensors.TensorSpan<TScalar> right) { throw null; }
public void operator &=(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> other) { throw null; }
public void operator &=(TScalar other) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar>)
where TScalar : System.Numerics.IBitwiseOperators<TScalar, TScalar, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator |(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> left, in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator |(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> left, TScalar right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator |(TScalar left, in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> right) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.Tensor<TScalar> tensor)
where TScalar : System.Numerics.IBitwiseOperators<TScalar, TScalar, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator |(System.Numerics.Tensors.Tensor<TScalar> left, System.Numerics.Tensors.Tensor<TScalar> right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator |(System.Numerics.Tensors.Tensor<TScalar> left, TScalar right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator |(TScalar left, System.Numerics.Tensors.Tensor<TScalar> right) { throw null; }
public void operator |=(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> other) { throw null; }
public void operator |=(TScalar other) { throw null; }
}
extension<TScalar>(ref System.Numerics.Tensors.TensorSpan<TScalar> tensor)
where TScalar : System.Numerics.IBitwiseOperators<TScalar, TScalar, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator |(in System.Numerics.Tensors.TensorSpan<TScalar> left, in System.Numerics.Tensors.TensorSpan<TScalar> right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator |(in System.Numerics.Tensors.TensorSpan<TScalar> left, TScalar right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator |(TScalar left, in System.Numerics.Tensors.TensorSpan<TScalar> right) { throw null; }
public void operator |=(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> other) { throw null; }
public void operator |=(TScalar other) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.Tensor<TScalar> tensor) where TScalar : System.Numerics.IDecrementOperators<TScalar>
{
public void operator --() { throw null; }
}
extension<TScalar>(ref System.Numerics.Tensors.TensorSpan<TScalar> tensor) where TScalar : System.Numerics.IDecrementOperators<TScalar>
{
public void operator --() { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar>)
where TScalar : System.Numerics.IDivisionOperators<TScalar, TScalar, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator /(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> left, in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator /(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> left, TScalar right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator /(TScalar left, in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> right) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.Tensor<TScalar> tensor)
where TScalar : System.Numerics.IDivisionOperators<TScalar, TScalar, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator /(System.Numerics.Tensors.Tensor<TScalar> left, System.Numerics.Tensors.Tensor<TScalar> right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator /(System.Numerics.Tensors.Tensor<TScalar> left, TScalar right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator /(TScalar left, System.Numerics.Tensors.Tensor<TScalar> right) { throw null; }
public void operator /=(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> other) { throw null; }
public void operator /=(TScalar other) { throw null; }
}
extension<TScalar>(ref System.Numerics.Tensors.TensorSpan<TScalar> tensor)
where TScalar : System.Numerics.IDivisionOperators<TScalar, TScalar, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator /(in System.Numerics.Tensors.TensorSpan<TScalar> left, in System.Numerics.Tensors.TensorSpan<TScalar> right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator /(in System.Numerics.Tensors.TensorSpan<TScalar> left, TScalar right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator /(TScalar left, in System.Numerics.Tensors.TensorSpan<TScalar> right) { throw null; }
public void operator /=(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> other) { throw null; }
public void operator /=(TScalar other) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar>)
where TScalar : System.Numerics.IBitwiseOperators<TScalar, TScalar, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator ^(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> left, in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator ^(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> left, TScalar right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator ^(TScalar left, in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> right) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.Tensor<TScalar> tensor)
where TScalar : System.Numerics.IBitwiseOperators<TScalar, TScalar, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator ^(System.Numerics.Tensors.Tensor<TScalar> left, System.Numerics.Tensors.Tensor<TScalar> right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator ^(System.Numerics.Tensors.Tensor<TScalar> left, TScalar right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator ^(TScalar left, System.Numerics.Tensors.Tensor<TScalar> right) { throw null; }
public void operator ^=(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> other) { throw null; }
public void operator ^=(TScalar other) { throw null; }
}
extension<TScalar>(ref System.Numerics.Tensors.TensorSpan<TScalar> tensor)
where TScalar : System.Numerics.IBitwiseOperators<TScalar, TScalar, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator ^(in System.Numerics.Tensors.TensorSpan<TScalar> left, in System.Numerics.Tensors.TensorSpan<TScalar> right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator ^(in System.Numerics.Tensors.TensorSpan<TScalar> left, TScalar right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator ^(TScalar left, in System.Numerics.Tensors.TensorSpan<TScalar> right) { throw null; }
public void operator ^=(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> other) { throw null; }
public void operator ^=(TScalar other) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.Tensor<TScalar> tensor) where TScalar : System.Numerics.IIncrementOperators<TScalar>
{
public void operator ++() { throw null; }
}
extension<TScalar>(ref System.Numerics.Tensors.TensorSpan<TScalar> tensor) where TScalar : System.Numerics.IIncrementOperators<TScalar>
{
public void operator ++() { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar>)
where TScalar : System.Numerics.IShiftOperators<TScalar, int, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator <<(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> tensor, int shiftAmount) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.Tensor<TScalar>)
where TScalar : System.Numerics.IShiftOperators<TScalar, int, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator <<(System.Numerics.Tensors.Tensor<TScalar> tensor, int shiftAmount) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.Tensor<TScalar> tensor)
where TScalar : System.Numerics.IShiftOperators<TScalar, int, TScalar>
{
public void operator <<=(int shiftAmount) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.TensorSpan<TScalar>)
where TScalar : System.Numerics.IShiftOperators<TScalar, int, TScalar>
{
public static Tensor<TScalar> operator <<(in TensorSpan<TScalar> tensor, int shiftAmount) { throw null; }
}
extension<TScalar>(ref System.Numerics.Tensors.TensorSpan<TScalar> tensor)
where TScalar : System.Numerics.IShiftOperators<TScalar, int, TScalar>
{
public void operator <<=(int shiftAmount) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar>)
where TScalar : System.Numerics.IMultiplyOperators<TScalar, TScalar, TScalar>, System.Numerics.IMultiplicativeIdentity<TScalar, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator *(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> left, in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator *(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> left, TScalar right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator *(TScalar left, in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> right) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.Tensor<TScalar> tensor)
where TScalar : System.Numerics.IMultiplyOperators<TScalar, TScalar, TScalar>, System.Numerics.IMultiplicativeIdentity<TScalar, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator *(System.Numerics.Tensors.Tensor<TScalar> left, System.Numerics.Tensors.Tensor<TScalar> right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator *(System.Numerics.Tensors.Tensor<TScalar> left, TScalar right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator *(TScalar left, System.Numerics.Tensors.Tensor<TScalar> right) { throw null; }
public void operator *=(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> other) { throw null; }
public void operator *=(TScalar other) { throw null; }
}
extension<TScalar>(ref System.Numerics.Tensors.TensorSpan<TScalar> tensor)
where TScalar : System.Numerics.IMultiplyOperators<TScalar, TScalar, TScalar>, System.Numerics.IMultiplicativeIdentity<TScalar, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator *(in System.Numerics.Tensors.TensorSpan<TScalar> left, in System.Numerics.Tensors.TensorSpan<TScalar> right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator *(in System.Numerics.Tensors.TensorSpan<TScalar> left, TScalar right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator *(TScalar left, in System.Numerics.Tensors.TensorSpan<TScalar> right) { throw null; }
public void operator *=(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> other) { throw null; }
public void operator *=(TScalar other) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar>)
where TScalar : System.Numerics.IBitwiseOperators<TScalar, TScalar, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator ~(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> tensor) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.Tensor<TScalar>)
where TScalar : System.Numerics.IBitwiseOperators<TScalar, TScalar, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator ~(in System.Numerics.Tensors.Tensor<TScalar> tensor) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.TensorSpan<TScalar>)
where TScalar : System.Numerics.IBitwiseOperators<TScalar, TScalar, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator ~(in System.Numerics.Tensors.TensorSpan<TScalar> tensor) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar>)
where TScalar : System.Numerics.IShiftOperators<TScalar, int, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator >>(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> tensor, int shiftAmount) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.Tensor<TScalar>)
where TScalar : System.Numerics.IShiftOperators<TScalar, int, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator >>(System.Numerics.Tensors.Tensor<TScalar> tensor, int shiftAmount) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.Tensor<TScalar> tensor)
where TScalar : System.Numerics.IShiftOperators<TScalar, int, TScalar>
{
public void operator >>=(int shiftAmount) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.TensorSpan<TScalar>)
where TScalar : System.Numerics.IShiftOperators<TScalar, int, TScalar>
{
public static Tensor<TScalar> operator >>(in TensorSpan<TScalar> tensor, int shiftAmount) { throw null; }
}
extension<TScalar>(ref System.Numerics.Tensors.TensorSpan<TScalar> tensor)
where TScalar : System.Numerics.IShiftOperators<TScalar, int, TScalar>
{
public void operator >>=(int shiftAmount) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar>)
where TScalar : System.Numerics.ISubtractionOperators<TScalar, TScalar, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator -(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> left, in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator -(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> left, TScalar right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator -(TScalar left, in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> right) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.Tensor<TScalar> tensor)
where TScalar : System.Numerics.ISubtractionOperators<TScalar, TScalar, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator -(System.Numerics.Tensors.Tensor<TScalar> left, System.Numerics.Tensors.Tensor<TScalar> right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator -(System.Numerics.Tensors.Tensor<TScalar> left, TScalar right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator -(TScalar left, System.Numerics.Tensors.Tensor<TScalar> right) { throw null; }
public void operator -=(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> other) { throw null; }
public void operator -=(TScalar other) { throw null; }
}
extension<TScalar>(ref System.Numerics.Tensors.TensorSpan<TScalar> tensor)
where TScalar : System.Numerics.ISubtractionOperators<TScalar, TScalar, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator -(in System.Numerics.Tensors.TensorSpan<TScalar> left, in System.Numerics.Tensors.TensorSpan<TScalar> right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator -(in System.Numerics.Tensors.TensorSpan<TScalar> left, TScalar right) { throw null; }
public static System.Numerics.Tensors.Tensor<TScalar> operator -(TScalar left, in System.Numerics.Tensors.TensorSpan<TScalar> right) { throw null; }
public void operator -=(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> other) { throw null; }
public void operator -=(TScalar other) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar>)
where TScalar : System.Numerics.IUnaryNegationOperators<TScalar, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator -(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> tensor) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.Tensor<TScalar>)
where TScalar : System.Numerics.IUnaryNegationOperators<TScalar, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator -(in System.Numerics.Tensors.Tensor<TScalar> tensor) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.TensorSpan<TScalar>)
where TScalar : System.Numerics.IUnaryNegationOperators<TScalar, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator -(in System.Numerics.Tensors.TensorSpan<TScalar> tensor) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar>)
where TScalar : System.Numerics.IUnaryPlusOperators<TScalar, TScalar>
{
public static System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> operator +(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> tensor) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.Tensor<TScalar>)
where TScalar : System.Numerics.IUnaryPlusOperators<TScalar, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator +(System.Numerics.Tensors.Tensor<TScalar> tensor) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.TensorSpan<TScalar>)
where TScalar : System.Numerics.IUnaryPlusOperators<TScalar, TScalar>
{
public static System.Numerics.Tensors.TensorSpan<TScalar> operator +(in System.Numerics.Tensors.TensorSpan<TScalar> tensor) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar>)
where TScalar : System.Numerics.IShiftOperators<TScalar, int, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator >>>(in System.Numerics.Tensors.ReadOnlyTensorSpan<TScalar> tensor, int shiftAmount) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.Tensor<TScalar>)
where TScalar : System.Numerics.IShiftOperators<TScalar, int, TScalar>
{
public static System.Numerics.Tensors.Tensor<TScalar> operator >>>(System.Numerics.Tensors.Tensor<TScalar> tensor, int shiftAmount) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.Tensor<TScalar> tensor)
where TScalar : System.Numerics.IShiftOperators<TScalar, int, TScalar>
{
public void operator >>>=(int shiftAmount) { throw null; }
}
extension<TScalar>(System.Numerics.Tensors.TensorSpan<TScalar>)
where TScalar : System.Numerics.IShiftOperators<TScalar, int, TScalar>
{
public static Tensor<TScalar> operator >>>(in TensorSpan<TScalar> tensor, int shiftAmount) { throw null; }
}
extension<TScalar>(ref System.Numerics.Tensors.TensorSpan<TScalar> tensor)
where TScalar : System.Numerics.IShiftOperators<TScalar, int, TScalar>
{
public void operator >>>=(int shiftAmount) { throw null; }
}
}
public readonly ref partial struct TensorDimensionSpan<T>
{

View File

@ -841,6 +841,13 @@
<Right>lib/net8.0/System.Numerics.Tensors.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0017</DiagnosticId>
<Target>M:System.Numerics.Tensors.Tensor.OnesComplement``1(System.Numerics.Tensors.ReadOnlyTensorSpan{``0}@,System.Numerics.Tensors.TensorSpan{``0}@)$0</Target>
<Left>lib/net8.0/System.Numerics.Tensors.dll</Left>
<Right>lib/net8.0/System.Numerics.Tensors.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0017</DiagnosticId>
<Target>M:System.Numerics.Tensors.Tensor`1.AsReadOnlyTensorSpan(System.ReadOnlySpan{System.Buffers.NIndex})$0</Target>
@ -1016,6 +1023,13 @@
<Right>lib/net9.0/System.Numerics.Tensors.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0017</DiagnosticId>
<Target>M:System.Numerics.Tensors.Tensor.OnesComplement``1(System.Numerics.Tensors.ReadOnlyTensorSpan{``0}@,System.Numerics.Tensors.TensorSpan{``0}@)$0</Target>
<Left>lib/net9.0/System.Numerics.Tensors.dll</Left>
<Right>lib/net9.0/System.Numerics.Tensors.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0017</DiagnosticId>
<Target>M:System.Numerics.Tensors.Tensor`1.AsReadOnlyTensorSpan(System.ReadOnlySpan{System.Buffers.NIndex})$0</Target>
@ -1107,6 +1121,24 @@
<Right>lib/net9.0/System.Numerics.Tensors.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0017</DiagnosticId>
<Target>M:System.Numerics.Tensors.Tensor.OnesComplement``1(System.Numerics.Tensors.ReadOnlyTensorSpan{``0}@,System.Numerics.Tensors.TensorSpan{``0}@)$0</Target>
<Left>ref/net10.0/System.Numerics.Tensors.dll</Left>
<Right>lib/net10.0/System.Numerics.Tensors.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0017</DiagnosticId>
<Target>M:System.Numerics.Tensors.Tensor.OnesComplement``1(System.Numerics.Tensors.ReadOnlyTensorSpan{``0}@,System.Numerics.Tensors.TensorSpan{``0}@)$0</Target>
<Left>ref/net8.0/System.Numerics.Tensors.dll</Left>
<Right>lib/net8.0/System.Numerics.Tensors.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0017</DiagnosticId>
<Target>M:System.Numerics.Tensors.Tensor.OnesComplement``1(System.Numerics.Tensors.ReadOnlyTensorSpan{``0}@,System.Numerics.Tensors.TensorSpan{``0}@)$0</Target>
<Left>ref/net9.0/System.Numerics.Tensors.dll</Left>
<Right>lib/net9.0/System.Numerics.Tensors.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0021</DiagnosticId>
<Target>M:System.Numerics.Tensors.Tensor.Average``1(System.Numerics.Tensors.ReadOnlyTensorSpan{``0}@)``0:T:System.Numerics.INumberBase{``0}</Target>

View File

@ -39,6 +39,21 @@
<Compile Include="System\Numerics\Tensors\netcore\ReadOnlyTensorDimensionSpan_1.cs" />
<Compile Include="System\Numerics\Tensors\netcore\ReadOnlyTensorSpan_1.cs" />
<Compile Include="System\Numerics\Tensors\netcore\Tensor.cs" />
<Compile Include="System\Numerics\Tensors\netcore\Tensor.op_Addition.cs" />
<Compile Include="System\Numerics\Tensors\netcore\Tensor.op_BitwiseAnd.cs" />
<Compile Include="System\Numerics\Tensors\netcore\Tensor.op_BitwiseOr.cs" />
<Compile Include="System\Numerics\Tensors\netcore\Tensor.op_Decrement.cs" />
<Compile Include="System\Numerics\Tensors\netcore\Tensor.op_Division.cs" />
<Compile Include="System\Numerics\Tensors\netcore\Tensor.op_ExclusiveOr.cs" />
<Compile Include="System\Numerics\Tensors\netcore\Tensor.op_Increment.cs" />
<Compile Include="System\Numerics\Tensors\netcore\Tensor.op_LeftShift.cs" />
<Compile Include="System\Numerics\Tensors\netcore\Tensor.op_Multiply.cs" />
<Compile Include="System\Numerics\Tensors\netcore\Tensor.op_OnesComplement.cs" />
<Compile Include="System\Numerics\Tensors\netcore\Tensor.op_RightShift.cs" />
<Compile Include="System\Numerics\Tensors\netcore\Tensor.op_Subtraction.cs" />
<Compile Include="System\Numerics\Tensors\netcore\Tensor.op_UnaryNegation.cs" />
<Compile Include="System\Numerics\Tensors\netcore\Tensor.op_UnaryPlus.cs" />
<Compile Include="System\Numerics\Tensors\netcore\Tensor.op_UnsignedRightShift.cs" />
<Compile Include="System\Numerics\Tensors\netcore\Tensor_1.cs" />
<Compile Include="System\Numerics\Tensors\netcore\TensorDimensionSpan_1.cs" />
<Compile Include="System\Numerics\Tensors\netcore\TensorOperation.cs" />
@ -149,6 +164,8 @@
<Compile Include="System\Numerics\Tensors\netcore\TensorPrimitives.Round.cs" />
<Compile Include="System\Numerics\Tensors\netcore\TensorPrimitives.ScaleB.cs" />
<Compile Include="System\Numerics\Tensors\netcore\TensorPrimitives.ShiftLeft.cs" />
<Compile Include="System\Numerics\Tensors\netcore\TensorPrimitives.ShiftRightArithmetic.cs" />
<Compile Include="System\Numerics\Tensors\netcore\TensorPrimitives.ShiftRightLogical.cs" />
<Compile Include="System\Numerics\Tensors\netcore\TensorPrimitives.Sigmoid.cs" />
<Compile Include="System\Numerics\Tensors\netcore\TensorPrimitives.Sign.cs" />
<Compile Include="System\Numerics\Tensors\netcore\TensorPrimitives.Sin.cs" />

View File

@ -2453,62 +2453,6 @@ namespace System.Numerics.Tensors
}
#endregion
#region Add
/// <summary>
/// Adds each element of <paramref name="x"/> to each element of <paramref name="y"/> and returns a new <see cref="Tensor{T}"/> with the result.
/// </summary>
/// <param name="x">The <see cref="ReadOnlyTensorSpan{T}"/> of values to add.</param>
/// <param name="y">The second <see cref="ReadOnlyTensorSpan{T}"/> of values to add.</param>
public static Tensor<T> Add<T>(in ReadOnlyTensorSpan<T> x, in ReadOnlyTensorSpan<T> y)
where T : IAdditionOperators<T, T, T>, IAdditiveIdentity<T, T>
{
TensorOperation.ValidateCompatibility(x, y, out Tensor<T> destination);
TensorOperation.Invoke<TensorOperation.Add<T>, T, T>(x, y, destination);
return destination;
}
/// <summary>
/// Adds <paramref name="y"/> to each element of <paramref name="x"/> and returns a new <see cref="Tensor{T}"/> with the result.
/// </summary>
/// <param name="x">The <see cref="ReadOnlyTensorSpan{T}"/> of values to add.</param>
/// <param name="y">The <typeparamref name="T"/> to add to each element of <paramref name="x"/>.</param>
public static Tensor<T> Add<T>(in ReadOnlyTensorSpan<T> x, T y)
where T : IAdditionOperators<T, T, T>, IAdditiveIdentity<T, T>
{
Tensor<T> destination = CreateFromShapeUninitialized<T>(x.Lengths);
TensorOperation.Invoke<TensorOperation.Add<T>, T, T>(x, y, destination);
return destination;
}
/// <summary>
/// Adds each element of <paramref name="x"/> to each element of <paramref name="y"/> and returns a new <see cref="ReadOnlyTensorSpan{T}"/> with the result.
/// </summary>
/// <param name="x">The <see cref="ReadOnlyTensorSpan{T}"/> of values to add.</param>
/// <param name="y">The second <see cref="ReadOnlyTensorSpan{T}"/> of values to add.</param>
/// <param name="destination"></param>
public static ref readonly TensorSpan<T> Add<T>(scoped in ReadOnlyTensorSpan<T> x, scoped in ReadOnlyTensorSpan<T> y, in TensorSpan<T> destination)
where T : IAdditionOperators<T, T, T>, IAdditiveIdentity<T, T>
{
TensorOperation.ValidateCompatibility(x, y, destination);
TensorOperation.Invoke<TensorOperation.Add<T>, T, T>(x, y, destination);
return ref destination;
}
/// <summary>
/// Adds <paramref name="y"/> to each element of <paramref name="x"/> and returns a new <see cref="TensorSpan{T}"/> with the result.
/// </summary>
/// <param name="x">The <see cref="ReadOnlyTensorSpan{T}"/> of values to add.</param>
/// <param name="y">The <typeparamref name="T"/> to add to each element of <paramref name="x"/>.</param>
/// <param name="destination"></param>
public static ref readonly TensorSpan<T> Add<T>(scoped in ReadOnlyTensorSpan<T> x, T y, in TensorSpan<T> destination)
where T : IAdditionOperators<T, T, T>, IAdditiveIdentity<T, T>
{
TensorOperation.ValidateCompatibility(x, destination);
TensorOperation.Invoke<TensorOperation.Add<T>, T, T>(x, y, destination);
return ref destination;
}
#endregion
#region Asin
/// <summary>
/// Takes the inverse sin of each element of the <see cref="ReadOnlyTensorSpan{T}"/> and returns a new <see cref="Tensor{T}"/> with the result.
@ -2854,118 +2798,6 @@ namespace System.Numerics.Tensors
}
#endregion
#region BitwiseAnd
/// <summary>
/// Computes the element-wise bitwise and of the two input <see cref="ReadOnlyTensorSpan{T}"/> and returns a new <see cref="Tensor{T}"/> with the result.
/// </summary>
/// <param name="x">The left <see cref="ReadOnlyTensorSpan{T}"/>.</param>
/// <param name="y">The right <see cref="ReadOnlyTensorSpan{T}"/>.</param>
public static Tensor<T> BitwiseAnd<T>(in ReadOnlyTensorSpan<T> x, in ReadOnlyTensorSpan<T> y)
where T : IBitwiseOperators<T, T, T>
{
Tensor<T> destination = CreateFromShapeUninitialized<T>(x.Lengths);
TensorOperation.Invoke<TensorOperation.BitwiseAnd<T>, T, T>(x, y, destination);
return destination;
}
/// <summary>
/// Computes the element-wise bitwise and of the two input <see cref="ReadOnlyTensorSpan{T}"/> and returns a new <see cref="TensorSpan{T}"/> with the result.
/// </summary>
/// <param name="x">The left <see cref="ReadOnlyTensorSpan{T}"/>.</param>
/// <param name="y">The right <see cref="ReadOnlyTensorSpan{T}"/>.</param>
/// <param name="destination"></param>
public static ref readonly TensorSpan<T> BitwiseAnd<T>(scoped in ReadOnlyTensorSpan<T> x, scoped in ReadOnlyTensorSpan<T> y, in TensorSpan<T> destination)
where T : IBitwiseOperators<T, T, T>
{
TensorOperation.ValidateCompatibility(x, y, destination);
TensorOperation.Invoke<TensorOperation.BitwiseAnd<T>, T, T>(x, y, destination);
return ref destination;
}
/// <summary>
/// Computes the element-wise bitwise and of the two input <see cref="ReadOnlyTensorSpan{T}"/> and returns a new <see cref="Tensor{T}"/> with the result.
/// </summary>
/// <param name="x">The left <see cref="ReadOnlyTensorSpan{T}"/>.</param>
/// <param name="y">The second value.</param>
public static Tensor<T> BitwiseAnd<T>(in ReadOnlyTensorSpan<T> x, T y)
where T : IBitwiseOperators<T, T, T>
{
Tensor<T> destination = CreateFromShapeUninitialized<T>(x.Lengths);
TensorOperation.Invoke<TensorOperation.BitwiseAnd<T>, T, T>(x, y, destination);
return destination;
}
/// <summary>
/// Computes the element-wise bitwise and of the two input <see cref="ReadOnlyTensorSpan{T}"/> and returns a new <see cref="TensorSpan{T}"/> with the result.
/// </summary>
/// <param name="x">The left <see cref="ReadOnlyTensorSpan{T}"/>.</param>
/// <param name="y">The second value.</param>
/// <param name="destination"></param>
public static ref readonly TensorSpan<T> BitwiseAnd<T>(scoped in ReadOnlyTensorSpan<T> x, T y, in TensorSpan<T> destination)
where T : IBitwiseOperators<T, T, T>
{
TensorOperation.ValidateCompatibility(x, destination);
TensorOperation.Invoke<TensorOperation.BitwiseAnd<T>, T, T>(x, y, destination);
return ref destination;
}
#endregion
#region BitwiseOr
/// <summary>
/// Computes the element-wise bitwise of of the two input <see cref="ReadOnlyTensorSpan{T}"/> and returns a new <see cref="Tensor{T}"/> with the result.
/// </summary>
/// <param name="x">The left <see cref="ReadOnlyTensorSpan{T}"/>.</param>
/// <param name="y">The right <see cref="ReadOnlyTensorSpan{T}"/>.</param>
public static Tensor<T> BitwiseOr<T>(in ReadOnlyTensorSpan<T> x, in ReadOnlyTensorSpan<T> y)
where T : IBitwiseOperators<T, T, T>
{
Tensor<T> destination = CreateFromShapeUninitialized<T>(x.Lengths);
TensorOperation.Invoke<TensorOperation.BitwiseOr<T>, T, T>(x, y, destination);
return destination;
}
/// <summary>
/// Computes the element-wise bitwise of of the two input <see cref="ReadOnlyTensorSpan{T}"/> and returns a new <see cref="TensorSpan{T}"/> with the result.
/// </summary>
/// <param name="x">The left <see cref="ReadOnlyTensorSpan{T}"/>.</param>
/// <param name="y">The right <see cref="ReadOnlyTensorSpan{T}"/>.</param>
/// <param name="destination"></param>
public static ref readonly TensorSpan<T> BitwiseOr<T>(scoped in ReadOnlyTensorSpan<T> x, scoped in ReadOnlyTensorSpan<T> y, in TensorSpan<T> destination)
where T : IBitwiseOperators<T, T, T>
{
TensorOperation.ValidateCompatibility(x, destination);
TensorOperation.Invoke<TensorOperation.BitwiseOr<T>, T, T>(x, y, destination);
return ref destination;
}
/// <summary>
/// Computes the element-wise bitwise or of the two input <see cref="ReadOnlyTensorSpan{T}"/> and returns a new <see cref="Tensor{T}"/> with the result.
/// </summary>
/// <param name="x">The left <see cref="ReadOnlyTensorSpan{T}"/>.</param>
/// <param name="y">The second value.</param>
public static Tensor<T> BitwiseOr<T>(in ReadOnlyTensorSpan<T> x, T y)
where T : IBitwiseOperators<T, T, T>
{
Tensor<T> destination = CreateFromShapeUninitialized<T>(x.Lengths);
TensorOperation.Invoke<TensorOperation.BitwiseOr<T>, T, T>(x, y, destination);
return destination;
}
/// <summary>
/// Computes the element-wise bitwise or of the two input <see cref="ReadOnlyTensorSpan{T}"/> and returns a new <see cref="TensorSpan{T}"/> with the result.
/// </summary>
/// <param name="x">The left <see cref="ReadOnlyTensorSpan{T}"/>.</param>
/// <param name="y">The second value.</param>
/// <param name="destination"></param>
public static ref readonly TensorSpan<T> BitwiseOr<T>(scoped in ReadOnlyTensorSpan<T> x, T y, in TensorSpan<T> destination)
where T : IBitwiseOperators<T, T, T>
{
TensorOperation.ValidateCompatibility(x, destination);
TensorOperation.Invoke<TensorOperation.BitwiseOr<T>, T, T>(x, y, destination);
return ref destination;
}
#endregion
#region CubeRoot
/// <summary>
/// Computes the element-wise cube root of the input <see cref="ReadOnlyTensorSpan{T}"/> and returns a new <see cref="Tensor{T}"/> with the result.
@ -3329,91 +3161,6 @@ namespace System.Numerics.Tensors
}
#endregion
#region Divide
/// <summary>
/// Divides each element of <paramref name="x"/> by <paramref name="y"/> and returns a new <see cref="Tensor{T}"/> with the result.
/// </summary>
/// <param name="x">Input <see cref="ReadOnlyTensorSpan{T}"/>.</param>
/// <param name="y">The divisor</param>
public static Tensor<T> Divide<T>(in ReadOnlyTensorSpan<T> x, T y)
where T : IDivisionOperators<T, T, T>
{
Tensor<T> destination = CreateFromShapeUninitialized<T>(x.Lengths);
TensorOperation.Invoke<TensorOperation.Divide<T>, T, T>(x, y, destination);
return destination;
}
/// <summary>
/// Divides <paramref name="x"/> by each element of <paramref name="y"/> and returns a new <see cref="Tensor{T}"/> with the result."/>
/// </summary>
/// <param name="x">The value to be divided.</param>
/// <param name="y">The <see cref="ReadOnlyTensorSpan{T}"/> divisor.</param>
public static Tensor<T> Divide<T>(T x, in ReadOnlyTensorSpan<T> y)
where T : IDivisionOperators<T, T, T>
{
Tensor<T> destination = CreateFromShapeUninitialized<T>(y.Lengths);
TensorOperation.Invoke<TensorOperation.Divide<T>, T, T>(x, y, destination);
return destination;
}
/// <summary>
/// Divides each element of <paramref name="x"/> by its corresponding element in <paramref name="y"/> and returns
/// a new <see cref="ReadOnlyTensorSpan{T}"/> with the result.
/// </summary>
/// <param name="x">The <see cref="ReadOnlyTensorSpan{T}"/> to be divided.</param>
/// <param name="y">The <see cref="ReadOnlyTensorSpan{T}"/> divisor.</param>
public static Tensor<T> Divide<T>(in ReadOnlyTensorSpan<T> x, in ReadOnlyTensorSpan<T> y)
where T : IDivisionOperators<T, T, T>
{
TensorOperation.ValidateCompatibility(x, y, out Tensor<T> destination);
TensorOperation.Invoke<TensorOperation.Divide<T>, T, T>(x, y, destination);
return destination;
}
/// <summary>
/// Divides each element of <paramref name="x"/> by <paramref name="y"/> and returns a new <see cref="TensorSpan{T}"/> with the result.
/// </summary>
/// <param name="x">Input <see cref="ReadOnlyTensorSpan{T}"/>.</param>
/// <param name="y">The divisor</param>
/// <param name="destination"></param>
public static ref readonly TensorSpan<T> Divide<T>(scoped in ReadOnlyTensorSpan<T> x, T y, in TensorSpan<T> destination)
where T : IDivisionOperators<T, T, T>
{
TensorOperation.ValidateCompatibility(x, destination);
TensorOperation.Invoke<TensorOperation.Divide<T>, T, T>(x, y, destination);
return ref destination;
}
/// <summary>
/// Divides <paramref name="x"/> by each element of <paramref name="y"/> and returns a new <see cref="TensorSpan{T}"/> with the result."/>
/// </summary>
/// <param name="x">The value to be divided.</param>
/// <param name="y">The <see cref="ReadOnlyTensorSpan{T}"/> divisor.</param>
/// <param name="destination"></param>
public static ref readonly TensorSpan<T> Divide<T>(T x, scoped in ReadOnlyTensorSpan<T> y, in TensorSpan<T> destination)
where T : IDivisionOperators<T, T, T>
{
TensorOperation.ValidateCompatibility(y, destination);
TensorOperation.Invoke<TensorOperation.Divide<T>, T, T>(x, y, destination);
return ref destination;
}
/// <summary>
/// Divides each element of <paramref name="x"/> by its corresponding element in <paramref name="y"/> and returns
/// a new <see cref="TensorSpan{T}"/> with the result.
/// </summary>
/// <param name="x">The <see cref="ReadOnlyTensorSpan{T}"/> to be divided.</param>
/// <param name="y">The <see cref="ReadOnlyTensorSpan{T}"/> divisor.</param>
/// <param name="destination"></param>
public static ref readonly TensorSpan<T> Divide<T>(scoped in ReadOnlyTensorSpan<T> x, scoped in ReadOnlyTensorSpan<T> y, in TensorSpan<T> destination)
where T : IDivisionOperators<T, T, T>
{
TensorOperation.ValidateCompatibility(x, y, destination);
TensorOperation.Invoke<TensorOperation.Divide<T>, T, T>(x, y, destination);
return ref destination;
}
#endregion
#region Dot
/// <summary>
/// Computes the dot product of two tensors containing numbers.
@ -4512,87 +4259,6 @@ namespace System.Numerics.Tensors
}
#endregion
#region Multiply
/// <summary>
/// Multiplies each element of <paramref name="x"/> with <paramref name="y"/> and returns a new <see cref="Tensor{T}"/> with the result.
/// </summary>
/// <param name="x">Input <see cref="ReadOnlyTensorSpan{T}"/></param>
/// <param name="y"><typeparamref name="T"/> value to multiply by.</param>
public static Tensor<T> Multiply<T>(in ReadOnlyTensorSpan<T> x, T y)
where T : IMultiplyOperators<T, T, T>, IMultiplicativeIdentity<T, T>
{
Tensor<T> destination = CreateFromShape<T>(x.Lengths);
TensorOperation.Invoke<TensorOperation.Multiply<T>, T, T>(x, y, destination);
return destination;
}
/// <summary>
/// Multiplies each element of <paramref name="x"/> with <paramref name="y"/> and returns a new <see cref="Tensor{T}"/> with the result.
/// If the shapes are not the same they are broadcast to the smallest compatible shape.
/// </summary>
/// <param name="x">Left <see cref="ReadOnlyTensorSpan{T}"/> for multiplication.</param>
/// <param name="y">Right <see cref="ReadOnlyTensorSpan{T}"/> for multiplication.</param>
public static Tensor<T> Multiply<T>(in ReadOnlyTensorSpan<T> x, in ReadOnlyTensorSpan<T> y)
where T : IMultiplyOperators<T, T, T>, IMultiplicativeIdentity<T, T>
{
TensorOperation.ValidateCompatibility(x, y, out Tensor<T> destination);
TensorOperation.Invoke<TensorOperation.Multiply<T>, T, T>(x, y, destination);
return destination;
}
/// <summary>
/// Multiplies each element of <paramref name="x"/> with <paramref name="y"/> and returns a new <see cref="TensorSpan{T}"/> with the result.
/// </summary>
/// <param name="x">Input <see cref="ReadOnlyTensorSpan{T}"/></param>
/// <param name="y"><typeparamref name="T"/> value to multiply by.</param>
/// <param name="destination"></param>
public static ref readonly TensorSpan<T> Multiply<T>(scoped in ReadOnlyTensorSpan<T> x, T y, in TensorSpan<T> destination)
where T : IMultiplyOperators<T, T, T>, IMultiplicativeIdentity<T, T>
{
TensorOperation.ValidateCompatibility(x, destination);
TensorOperation.Invoke<TensorOperation.Multiply<T>, T, T>(x, y, destination);
return ref destination;
}
/// <summary>
/// Multiplies each element of <paramref name="x"/> with <paramref name="y"/> and returns a new <see cref="TensorSpan{T}"/> with the result.
/// If the shapes are not the same they are broadcast to the smallest compatible shape.
/// </summary>
/// <param name="x">Left <see cref="ReadOnlyTensorSpan{T}"/> for multiplication.</param>
/// <param name="y">Right <see cref="ReadOnlyTensorSpan{T}"/> for multiplication.</param>
/// <param name="destination"></param>
public static ref readonly TensorSpan<T> Multiply<T>(scoped in ReadOnlyTensorSpan<T> x, scoped in ReadOnlyTensorSpan<T> y, in TensorSpan<T> destination)
where T : IMultiplyOperators<T, T, T>, IMultiplicativeIdentity<T, T>
{
TensorOperation.ValidateCompatibility(x, y, destination);
TensorOperation.Invoke<TensorOperation.Multiply<T>, T, T>(x, y, destination);
return ref destination;
}
#endregion
#region Negate
/// <summary>Computes the element-wise negation of each number in the specified tensor.</summary>
/// <param name="x">The <see cref="ReadOnlyTensorSpan{T}"/></param>
public static Tensor<T> Negate<T>(in ReadOnlyTensorSpan<T> x)
where T : IUnaryNegationOperators<T, T>
{
Tensor<T> destination = CreateFromShapeUninitialized<T>(x.Lengths);
TensorOperation.Invoke<TensorOperation.Negate<T>, T, T>(x, destination);
return destination;
}
/// <summary>Computes the element-wise negation of each number in the specified tensor.</summary>
/// <param name="x">The <see cref="ReadOnlyTensorSpan{T}"/></param>
/// <param name="destination"></param>
public static ref readonly TensorSpan<T> Negate<T>(scoped in ReadOnlyTensorSpan<T> x, in TensorSpan<T> destination)
where T : IUnaryNegationOperators<T, T>
{
TensorOperation.ValidateCompatibility(x, destination);
TensorOperation.Invoke<TensorOperation.Negate<T>, T, T>(x, destination);
return ref destination;
}
#endregion
#region Norm
/// <summary>
/// Takes the norm of the <see cref="ReadOnlyTensorSpan{T}"/> and returns the result.
@ -4607,29 +4273,6 @@ namespace System.Numerics.Tensors
}
#endregion
#region OnesComplement
/// <summary>Computes the element-wise one's complement of numbers in the specified tensor.</summary>
/// <param name="x">The <see cref="ReadOnlyTensorSpan{T}"/></param>
public static Tensor<T> OnesComplement<T>(in ReadOnlyTensorSpan<T> x)
where T : IBitwiseOperators<T, T, T>
{
Tensor<T> destination = CreateFromShapeUninitialized<T>(x.Lengths);
TensorOperation.Invoke<TensorOperation.OnesComplement<T>, T, T>(x, destination);
return destination;
}
/// <summary>Computes the element-wise one's complement of numbers in the specified tensor.</summary>
/// <param name="y">The <see cref="ReadOnlyTensorSpan{T}"/></param>
/// <param name="destination"></param>
public static ref readonly TensorSpan<T> OnesComplement<T>(scoped in ReadOnlyTensorSpan<T> y, in TensorSpan<T> destination)
where T : IBitwiseOperators<T, T, T>
{
TensorOperation.ValidateCompatibility(y, destination);
TensorOperation.Invoke<TensorOperation.OnesComplement<T>, T, T>(y, destination);
return ref destination;
}
#endregion
#region PopCount
/// <summary>Computes the element-wise population count of numbers in the specified tensor.</summary>
/// <param name="x">The <see cref="ReadOnlyTensorSpan{T}"/></param>
@ -5125,89 +4768,6 @@ namespace System.Numerics.Tensors
}
#endregion
#region Subtract
/// <summary>
/// Subtracts <paramref name="y"/> from each element of <paramref name="x"/> and returns a new <see cref="Tensor{T}"/> with the result.
/// </summary>
/// <param name="x">The <see cref="ReadOnlyTensorSpan{T}"/>.</param>
/// <param name="y">The <typeparamref name="T"/> to subtract.</param>
public static Tensor<T> Subtract<T>(in ReadOnlyTensorSpan<T> x, T y)
where T : ISubtractionOperators<T, T, T>
{
Tensor<T> destination = CreateFromShapeUninitialized<T>(x.Lengths);
TensorOperation.Invoke<TensorOperation.Subtract<T>, T, T>(x, y, destination);
return destination;
}
/// <summary>
/// Subtracts each element of <paramref name="y"/> from <paramref name="x"/> and returns a new <see cref="Tensor{T}"/> with the result.
/// </summary>
/// <param name="x">The <typeparamref name="T"/> to be subtracted from.</param>
/// <param name="y">The <see cref="ReadOnlyTensorSpan{T}"/> of values to subtract.</param>
public static Tensor<T> Subtract<T>(T x, in ReadOnlyTensorSpan<T> y)
where T : ISubtractionOperators<T, T, T>
{
Tensor<T> destination = CreateFromShapeUninitialized<T>(y.Lengths);
TensorOperation.Invoke<TensorOperation.Subtract<T>, T, T>(x, y, destination);
return destination;
}
/// <summary>
/// Subtracts each element of <paramref name="x"/> from <paramref name="y"/> and returns a new <see cref="Tensor{T}"/> with the result.
/// </summary>
/// <param name="x">The <see cref="ReadOnlyTensorSpan{T}"/> with values to be subtracted from.</param>
/// <param name="y">The <see cref="ReadOnlyTensorSpan{T}"/> with values to subtract.</param>
public static Tensor<T> Subtract<T>(in ReadOnlyTensorSpan<T> x, in ReadOnlyTensorSpan<T> y)
where T : ISubtractionOperators<T, T, T>
{
TensorOperation.ValidateCompatibility(x, y, out Tensor<T> destination);
TensorOperation.Invoke<TensorOperation.Subtract<T>, T, T>(x, y, destination);
return destination;
}
/// <summary>
/// Subtracts <paramref name="y"/> from each element of <paramref name="x"/> and returns a new <see cref="TensorSpan{T}"/> with the result.
/// </summary>
/// <param name="x">The <see cref="ReadOnlyTensorSpan{T}"/> with values to be subtracted from.</param>
/// <param name="y">The <typeparamref name="T"/> value to subtract.</param>
/// <param name="destination"></param>
public static ref readonly TensorSpan<T> Subtract<T>(scoped in ReadOnlyTensorSpan<T> x, T y, in TensorSpan<T> destination)
where T : ISubtractionOperators<T, T, T>
{
TensorOperation.ValidateCompatibility(x, destination);
TensorOperation.Invoke<TensorOperation.Subtract<T>, T, T>(x, y, destination);
return ref destination;
}
/// <summary>
/// Subtracts each element of <paramref name="y"/> from <paramref name="x"/> and returns a new <see cref="TensorSpan{T}"/> with the result.
/// </summary>
/// <param name="x">The <typeparamref name="T"/> value to be subtracted from.</param>
/// <param name="y">The <see cref="ReadOnlyTensorSpan{T}"/> values to subtract.</param>
/// <param name="destination"></param>
public static ref readonly TensorSpan<T> Subtract<T>(T x, scoped in ReadOnlyTensorSpan<T> y, in TensorSpan<T> destination)
where T : ISubtractionOperators<T, T, T>
{
TensorOperation.ValidateCompatibility(y, destination);
TensorOperation.Invoke<TensorOperation.Subtract<T>, T, T>(x, y, destination);
return ref destination;
}
/// <summary>
/// Subtracts each element of <paramref name="x"/> from <paramref name="y"/> and returns a new <see cref="TensorSpan{T}"/> with the result.
/// </summary>
/// <param name="x">The <see cref="ReadOnlyTensorSpan{T}"/> of values to be subtracted from.</param>
/// <param name="y">The <see cref="ReadOnlyTensorSpan{T}"/>of values to subtract.</param>
/// <param name="destination"></param>
public static ref readonly TensorSpan<T> Subtract<T>(scoped in ReadOnlyTensorSpan<T> x, scoped in ReadOnlyTensorSpan<T> y, in TensorSpan<T> destination)
where T : ISubtractionOperators<T, T, T>
{
TensorOperation.ValidateCompatibility(x, y, destination);
TensorOperation.Invoke<TensorOperation.Subtract<T>, T, T>(x, y, destination);
return ref destination;
}
#endregion
#region Sum
/// <summary>
/// Sums the elements of the specified tensor.
@ -5352,58 +4912,6 @@ namespace System.Numerics.Tensors
return ref destination;
}
#endregion
#region Xor
/// <summary>Computes the element-wise XOR of numbers in the specified tensors.</summary>
/// <param name="x">The left <see cref="ReadOnlyTensorSpan{T}"/>.</param>
/// <param name="y">The right <see cref="ReadOnlyTensorSpan{T}"/>.</param>
public static Tensor<T> Xor<T>(in ReadOnlyTensorSpan<T> x, in ReadOnlyTensorSpan<T> y)
where T : IBitwiseOperators<T, T, T>
{
TensorOperation.ValidateCompatibility(x, y, out Tensor<T> destination);
TensorOperation.Invoke<TensorOperation.Xor<T>, T, T>(x, y, destination);
return destination;
}
/// <summary>Computes the element-wise XOR of numbers in the specified tensors.</summary>
/// <param name="x">The left <see cref="ReadOnlyTensorSpan{T}"/>.</param>
/// <param name="y">The right <see cref="ReadOnlyTensorSpan{T}"/>.</param>
/// <param name="destination"></param>
public static ref readonly TensorSpan<T> Xor<T>(scoped in ReadOnlyTensorSpan<T> x, scoped in ReadOnlyTensorSpan<T> y, in TensorSpan<T> destination)
where T : IBitwiseOperators<T, T, T>
{
TensorOperation.ValidateCompatibility(x, y, destination);
TensorOperation.Invoke<TensorOperation.Xor<T>, T, T>(x, y, destination);
return ref destination;
}
/// <summary>
/// Computes the element-wise Xor of the two input <see cref="ReadOnlyTensorSpan{T}"/> and returns a new <see cref="Tensor{T}"/> with the result.
/// </summary>
/// <param name="x">The left <see cref="ReadOnlyTensorSpan{T}"/>.</param>
/// <param name="y">The second value.</param>
public static Tensor<T> Xor<T>(in ReadOnlyTensorSpan<T> x, T y)
where T : IBitwiseOperators<T, T, T>
{
Tensor<T> destination = CreateFromShapeUninitialized<T>(x.Lengths);
TensorOperation.Invoke<TensorOperation.Xor<T>, T, T>(x, y, destination);
return destination;
}
/// <summary>
/// Computes the element-wise Xor of the two input <see cref="ReadOnlyTensorSpan{T}"/> and returns a new <see cref="TensorSpan{T}"/> with the result.
/// </summary>
/// <param name="x">The left <see cref="ReadOnlyTensorSpan{T}"/>.</param>
/// <param name="y">The second value.</param>
/// <param name="destination"></param>
public static ref readonly TensorSpan<T> Xor<T>(scoped in ReadOnlyTensorSpan<T> x, T y, in TensorSpan<T> destination)
where T : IBitwiseOperators<T, T, T>
{
TensorOperation.ValidateCompatibility(x, destination);
TensorOperation.Invoke<TensorOperation.Xor<T>, T, T>(x, y, destination);
return ref destination;
}
#endregion
#endregion
}
}

View File

@ -0,0 +1,132 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Numerics.Tensors
{
public static partial class Tensor
{
/// <summary>Performs element-wise addition between two tensors.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor to add with <paramref name="y" />.</param>
/// <param name="y">The tensor to add with <paramref name="x" />.</param>
/// <returns>A new tensor containing the result of <paramref name="x" /> + <paramref name="y" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="x" /> and <paramref name="y" /> are not compatible.</exception>
public static Tensor<T> Add<T>(in ReadOnlyTensorSpan<T> x, in ReadOnlyTensorSpan<T> y)
where T : IAdditionOperators<T, T, T>, IAdditiveIdentity<T, T>
{
TensorOperation.ValidateCompatibility(x, y, out Tensor<T> destination);
TensorOperation.Invoke<TensorOperation.Add<T>, T, T>(x, y, destination);
return destination;
}
/// <summary>Performs element-wise addition between a tensor and scalar.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor to add with <paramref name="y" />.</param>
/// <param name="y">The scalar to add with <paramref name="x" />.</param>
/// <returns>A new tensor containing the result of <paramref name="x" /> + <paramref name="y" />.</returns>
public static Tensor<T> Add<T>(in ReadOnlyTensorSpan<T> x, T y)
where T : IAdditionOperators<T, T, T>, IAdditiveIdentity<T, T>
{
Tensor<T> destination = CreateFromShapeUninitialized<T>(x.Lengths);
TensorOperation.Invoke<TensorOperation.Add<T>, T, T>(x, y, destination);
return destination;
}
/// <summary>Performs element-wise addition between two tensors.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor to add with <paramref name="y" />.</param>
/// <param name="y">The tensor to add with <paramref name="x" />.</param>
/// <param name="destination">The destination where the result of <paramref name="x" /> + <paramref name="y" /> is written.</param>
/// <returns>A reference to <paramref name="destination" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="x" />, <paramref name="y" />, and <paramref name="destination" /> are not compatible.</exception>
public static ref readonly TensorSpan<T> Add<T>(scoped in ReadOnlyTensorSpan<T> x, scoped in ReadOnlyTensorSpan<T> y, in TensorSpan<T> destination)
where T : IAdditionOperators<T, T, T>, IAdditiveIdentity<T, T>
{
TensorOperation.ValidateCompatibility(x, y, destination);
TensorOperation.Invoke<TensorOperation.Add<T>, T, T>(x, y, destination);
return ref destination;
}
/// <summary>Performs element-wise addition between a tensor and scalar.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor to add with <paramref name="y" />.</param>
/// <param name="y">The scalar to add with <paramref name="x" />.</param>
/// <param name="destination">The destination where the result of <paramref name="x" /> + <paramref name="y" /> is written.</param>
/// <returns>A reference to <paramref name="destination" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="x" /> and <paramref name="destination" /> are not compatible.</exception>
public static ref readonly TensorSpan<T> Add<T>(scoped in ReadOnlyTensorSpan<T> x, T y, in TensorSpan<T> destination)
where T : IAdditionOperators<T, T, T>, IAdditiveIdentity<T, T>
{
TensorOperation.ValidateCompatibility(x, destination);
TensorOperation.Invoke<TensorOperation.Add<T>, T, T>(x, y, destination);
return ref destination;
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
extension<TScalar>(ReadOnlyTensorSpan<TScalar>)
where TScalar : IAdditionOperators<TScalar, TScalar, TScalar>, IAdditiveIdentity<TScalar, TScalar>
{
/// <summary>Performs element-wise addition between two tensors.</summary>
/// <param name="left">The tensor to add with <paramref name="right" />.</param>
/// <param name="right">The tensor to add with <paramref name="left" />.</param>
/// <returns>A new tensor containing the result of <paramref name="left" /> + <paramref name="right" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="left" /> and <paramref name="right" /> are not compatible.</exception>
public static Tensor<TScalar> operator +(in ReadOnlyTensorSpan<TScalar> left, in ReadOnlyTensorSpan<TScalar> right) => Add(left, right);
/// <summary>Performs element-wise addition between a tensor and scalar.</summary>
/// <param name="left">The tensor to add with <paramref name="right" />.</param>
/// <param name="right">The scalar to add with <paramref name="left" />.</param>
/// <returns>A new tensor containing the result of <paramref name="left" /> + <paramref name="right" />.</returns>
public static Tensor<TScalar> operator +(in ReadOnlyTensorSpan<TScalar> left, TScalar right) => Add(left, right);
/// <summary>Performs element-wise addition between a tensor and scalar.</summary>
/// <param name="left">The scalar to add with <paramref name="right" />.</param>
/// <param name="right">The tensor to add with <paramref name="left" />.</param>
/// <returns>A new tensor containing the result of <paramref name="left" /> + <paramref name="right" />.</returns>
public static Tensor<TScalar> operator +(TScalar left, in ReadOnlyTensorSpan<TScalar> right) => Add(right, left);
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
extension<TScalar>(Tensor<TScalar> tensor)
where TScalar : IAdditionOperators<TScalar, TScalar, TScalar>, IAdditiveIdentity<TScalar, TScalar>
{
/// <inheritdoc cref="op_Addition{T}(in ReadOnlyTensorSpan{T}, in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator +(Tensor<TScalar> left, Tensor<TScalar> right) => Add<TScalar>(left, right);
/// <inheritdoc cref="op_Addition{T}(in ReadOnlyTensorSpan{T}, T)" />
public static Tensor<TScalar> operator +(Tensor<TScalar> left, TScalar right) => Add(left, right);
/// <inheritdoc cref="op_Addition{T}(T, in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator +(TScalar left, Tensor<TScalar> right) => Add(right, left);
/// <inheritdoc cref="op_AdditionAssignment{T}(ref TensorSpan{T}, in ReadOnlyTensorSpan{T})" />
public void operator +=(in ReadOnlyTensorSpan<TScalar> other) => Add(tensor, other, tensor);
/// <inheritdoc cref="op_AdditionAssignment{T}(ref TensorSpan{T}, T)" />
public void operator +=(TScalar other) => Add(tensor, other, tensor);
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
/// <param name="tensor">The tensor to operate on.</param>
extension<TScalar>(ref TensorSpan<TScalar> tensor)
where TScalar : IAdditionOperators<TScalar, TScalar, TScalar>, IAdditiveIdentity<TScalar, TScalar>
{
/// <inheritdoc cref="op_Addition{T}(in ReadOnlyTensorSpan{T}, in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator +(in TensorSpan<TScalar> left, in TensorSpan<TScalar> right) => Add<TScalar>(left, right);
/// <inheritdoc cref="op_Addition{T}(in ReadOnlyTensorSpan{T}, T)" />
public static Tensor<TScalar> operator +(in TensorSpan<TScalar> left, TScalar right) => Add(left, right);
/// <inheritdoc cref="op_Addition{T}(T, in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator +(TScalar left, in TensorSpan<TScalar> right) => Add(right, left);
/// <summary>Performs in-place element-wise addition between two tensors.</summary>
/// <param name="other">The tensor to add to the tensor being operated on.</param>
public void operator +=(in ReadOnlyTensorSpan<TScalar> other) => Add(tensor, other, tensor);
/// <summary>Performs in-place element-wise addition between a tensor and scalar.</summary>
/// <param name="other">The scalar to add to the tensor being operated on.</param>
public void operator +=(TScalar other) => Add(tensor, other, tensor);
}
}
}

View File

@ -0,0 +1,132 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Numerics.Tensors
{
public static partial class Tensor
{
/// <summary>Performs bitwise-and between two tensors.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor to bitwise-and with <paramref name="y" />.</param>
/// <param name="y">The tensor to bitwise-and with <paramref name="x" />.</param>
/// <returns>A new tensor containing the result of <paramref name="x" /> &amp; <paramref name="y" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="x" /> and <paramref name="y" /> are not compatible.</exception>
public static Tensor<T> BitwiseAnd<T>(in ReadOnlyTensorSpan<T> x, in ReadOnlyTensorSpan<T> y)
where T : IBitwiseOperators<T, T, T>
{
Tensor<T> destination = CreateFromShapeUninitialized<T>(x.Lengths);
TensorOperation.Invoke<TensorOperation.BitwiseAnd<T>, T, T>(x, y, destination);
return destination;
}
/// <summary>Performs bitwise-and between a tensor and scalar.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor to bitwise-and with <paramref name="y" />.</param>
/// <param name="y">The scalar to bitwise-and with <paramref name="x" />.</param>
/// <returns>A new tensor containing the result of <paramref name="x" /> &amp; <paramref name="y" />.</returns>
public static Tensor<T> BitwiseAnd<T>(in ReadOnlyTensorSpan<T> x, T y)
where T : IBitwiseOperators<T, T, T>
{
Tensor<T> destination = CreateFromShapeUninitialized<T>(x.Lengths);
TensorOperation.Invoke<TensorOperation.BitwiseAnd<T>, T, T>(x, y, destination);
return destination;
}
/// <summary>Performs bitwise-and between two tensors.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor to bitwise-and with <paramref name="y" />.</param>
/// <param name="y">The tensor to bitwise-and with <paramref name="x" />.</param>
/// <param name="destination">The destination where the result of <paramref name="x" /> &amp; <paramref name="y" /> is written.</param>
/// <returns>A reference to <paramref name="destination" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="x" />, <paramref name="y" />, and <paramref name="destination" /> are not compatible.</exception>
public static ref readonly TensorSpan<T> BitwiseAnd<T>(scoped in ReadOnlyTensorSpan<T> x, scoped in ReadOnlyTensorSpan<T> y, in TensorSpan<T> destination)
where T : IBitwiseOperators<T, T, T>
{
TensorOperation.ValidateCompatibility(x, y, destination);
TensorOperation.Invoke<TensorOperation.BitwiseAnd<T>, T, T>(x, y, destination);
return ref destination;
}
/// <summary>Performs bitwise-and between a tensor and scalar.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor to bitwise-and with <paramref name="y" />.</param>
/// <param name="y">The scalar to bitwise-and with <paramref name="x" />.</param>
/// <param name="destination">The destination where the result of <paramref name="x" /> &amp; <paramref name="y" /> is written.</param>
/// <returns>A reference to <paramref name="destination" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="x" /> and <paramref name="destination" /> are not compatible.</exception>
public static ref readonly TensorSpan<T> BitwiseAnd<T>(scoped in ReadOnlyTensorSpan<T> x, T y, in TensorSpan<T> destination)
where T : IBitwiseOperators<T, T, T>
{
TensorOperation.ValidateCompatibility(x, destination);
TensorOperation.Invoke<TensorOperation.BitwiseAnd<T>, T, T>(x, y, destination);
return ref destination;
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
extension<TScalar>(ReadOnlyTensorSpan<TScalar>)
where TScalar : IBitwiseOperators<TScalar, TScalar, TScalar>
{
/// <summary>Performs bitwise-and between two tensors.</summary>
/// <param name="left">The tensor to bitwise-and with <paramref name="right" />.</param>
/// <param name="right">The tensor to bitwise-and with <paramref name="left" />.</param>
/// <returns>A new tensor containing the result of <paramref name="left" /> &amp; <paramref name="right" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="left" /> and <paramref name="right" /> are not compatible.</exception>
public static Tensor<TScalar> operator &(in ReadOnlyTensorSpan<TScalar> left, in ReadOnlyTensorSpan<TScalar> right) => BitwiseAnd(left, right);
/// <summary>Performs bitwise-and between a tensor and scalar.</summary>
/// <param name="left">The tensor to bitwise-and with <paramref name="right" />.</param>
/// <param name="right">The scalar to bitwise-and with <paramref name="left" />.</param>
/// <returns>A new tensor containing the result of <paramref name="left" /> &amp; <paramref name="right" />.</returns>
public static Tensor<TScalar> operator &(in ReadOnlyTensorSpan<TScalar> left, TScalar right) => BitwiseAnd(left, right);
/// <summary>Performs bitwise-and between a tensor and scalar.</summary>
/// <param name="left">The scalar to bitwise-and with <paramref name="right" />.</param>
/// <param name="right">The tensor to bitwise-and with <paramref name="left" />.</param>
/// <returns>A new tensor containing the result of <paramref name="left" /> &amp; <paramref name="right" />.</returns>
public static Tensor<TScalar> operator &(TScalar left, in ReadOnlyTensorSpan<TScalar> right) => BitwiseAnd(right, left);
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
extension<TScalar>(Tensor<TScalar> tensor)
where TScalar : IBitwiseOperators<TScalar, TScalar, TScalar>
{
/// <inheritdoc cref="op_BitwiseAnd{T}(in ReadOnlyTensorSpan{T}, in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator &(Tensor<TScalar> left, Tensor<TScalar> right) => BitwiseAnd<TScalar>(left, right);
/// <inheritdoc cref="op_BitwiseAnd{T}(in ReadOnlyTensorSpan{T}, T)" />
public static Tensor<TScalar> operator &(Tensor<TScalar> left, TScalar right) => BitwiseAnd(left, right);
/// <inheritdoc cref="op_BitwiseAnd{T}(T, in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator &(TScalar left, Tensor<TScalar> right) => BitwiseAnd(right, left);
/// <inheritdoc cref="op_BitwiseAndAssignment{T}(ref TensorSpan{T}, in ReadOnlyTensorSpan{T})" />
public void operator &=(in ReadOnlyTensorSpan<TScalar> other) => BitwiseAnd(tensor, other, tensor);
/// <inheritdoc cref="op_BitwiseAndAssignment{T}(ref TensorSpan{T}, T)" />
public void operator &=(TScalar other) => BitwiseAnd(tensor, other, tensor);
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
/// <param name="tensor">The tensor to operate on.</param>
extension<TScalar>(ref TensorSpan<TScalar> tensor)
where TScalar : IBitwiseOperators<TScalar, TScalar, TScalar>
{
/// <inheritdoc cref="op_BitwiseAnd{T}(in ReadOnlyTensorSpan{T}, in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator &(in TensorSpan<TScalar> left, in TensorSpan<TScalar> right) => BitwiseAnd<TScalar>(left, right);
/// <inheritdoc cref="op_BitwiseAnd{T}(in ReadOnlyTensorSpan{T}, T)" />
public static Tensor<TScalar> operator &(in TensorSpan<TScalar> left, TScalar right) => BitwiseAnd(left, right);
/// <inheritdoc cref="op_BitwiseAnd{T}(T, in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator &(TScalar left, in TensorSpan<TScalar> right) => BitwiseAnd(right, left);
/// <summary>Performs in-place bitwise-and between two tensors.</summary>
/// <param name="other">The tensor to bitwise-and with the tensor being operated on.</param>
public void operator &=(in ReadOnlyTensorSpan<TScalar> other) => BitwiseAnd(tensor, other, tensor);
/// <summary>Performs in-place bitwise-and between a tensor and scalar.</summary>
/// <param name="other">The scalar to bitwise-and with the tensor being operated on.</param>
public void operator &=(TScalar other) => BitwiseAnd(tensor, other, tensor);
}
}
}

View File

@ -0,0 +1,132 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Numerics.Tensors
{
public static partial class Tensor
{
/// <summary>Performs bitwise-or between two tensors.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor to bitwise-or with <paramref name="y" />.</param>
/// <param name="y">The tensor to bitwise-or with <paramref name="x" />.</param>
/// <returns>A new tensor containing the result of <paramref name="x" /> | <paramref name="y" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="x" /> and <paramref name="y" /> are not compatible.</exception>
public static Tensor<T> BitwiseOr<T>(in ReadOnlyTensorSpan<T> x, in ReadOnlyTensorSpan<T> y)
where T : IBitwiseOperators<T, T, T>
{
Tensor<T> destination = CreateFromShapeUninitialized<T>(x.Lengths);
TensorOperation.Invoke<TensorOperation.BitwiseOr<T>, T, T>(x, y, destination);
return destination;
}
/// <summary>Performs bitwise-or between a tensor and scalar.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor to bitwise-or with <paramref name="y" />.</param>
/// <param name="y">The scalar to bitwise-or with <paramref name="x" />.</param>
/// <returns>A new tensor containing the result of <paramref name="x" /> | <paramref name="y" />.</returns>
public static Tensor<T> BitwiseOr<T>(in ReadOnlyTensorSpan<T> x, T y)
where T : IBitwiseOperators<T, T, T>
{
Tensor<T> destination = CreateFromShapeUninitialized<T>(x.Lengths);
TensorOperation.Invoke<TensorOperation.BitwiseOr<T>, T, T>(x, y, destination);
return destination;
}
/// <summary>Performs bitwise-or between two tensors.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor to bitwise-or with <paramref name="y" />.</param>
/// <param name="y">The tensor to bitwise-or with <paramref name="x" />.</param>
/// <param name="destination">The destination where the result of <paramref name="x" /> | <paramref name="y" /> is written.</param>
/// <returns>A reference to <paramref name="destination" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="x" />, <paramref name="y" />, and <paramref name="destination" /> are not compatible.</exception>
public static ref readonly TensorSpan<T> BitwiseOr<T>(scoped in ReadOnlyTensorSpan<T> x, scoped in ReadOnlyTensorSpan<T> y, in TensorSpan<T> destination)
where T : IBitwiseOperators<T, T, T>
{
TensorOperation.ValidateCompatibility(x, y, destination);
TensorOperation.Invoke<TensorOperation.BitwiseOr<T>, T, T>(x, y, destination);
return ref destination;
}
/// <summary>Performs bitwise-or between a tensor and scalar.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor to bitwise-or with <paramref name="y" />.</param>
/// <param name="y">The scalar to bitwise-or with <paramref name="x" />.</param>
/// <param name="destination">The destination where the result of <paramref name="x" /> | <paramref name="y" /> is written.</param>
/// <returns>A reference to <paramref name="destination" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="x" /> and <paramref name="destination" /> are not compatible.</exception>
public static ref readonly TensorSpan<T> BitwiseOr<T>(scoped in ReadOnlyTensorSpan<T> x, T y, in TensorSpan<T> destination)
where T : IBitwiseOperators<T, T, T>
{
TensorOperation.ValidateCompatibility(x, destination);
TensorOperation.Invoke<TensorOperation.BitwiseOr<T>, T, T>(x, y, destination);
return ref destination;
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
extension<TScalar>(ReadOnlyTensorSpan<TScalar>)
where TScalar : IBitwiseOperators<TScalar, TScalar, TScalar>
{
/// <summary>Performs bitwise-or between two tensors.</summary>
/// <param name="left">The tensor to bitwise-or with <paramref name="right" />.</param>
/// <param name="right">The tensor to bitwise-or with <paramref name="left" />.</param>
/// <returns>A new tensor containing the result of <paramref name="left" /> | <paramref name="right" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="left" /> and <paramref name="right" /> are not compatible.</exception>
public static Tensor<TScalar> operator |(in ReadOnlyTensorSpan<TScalar> left, in ReadOnlyTensorSpan<TScalar> right) => BitwiseOr(left, right);
/// <summary>Performs bitwise-or between a tensor and scalar.</summary>
/// <param name="left">The tensor to bitwise-or with <paramref name="right" />.</param>
/// <param name="right">The scalar to bitwise-or with <paramref name="left" />.</param>
/// <returns>A new tensor containing the result of <paramref name="left" /> | <paramref name="right" />.</returns>
public static Tensor<TScalar> operator |(in ReadOnlyTensorSpan<TScalar> left, TScalar right) => BitwiseOr(left, right);
/// <summary>Performs bitwise-or between a tensor and scalar.</summary>
/// <param name="left">The scalar to bitwise-or with <paramref name="right" />.</param>
/// <param name="right">The tensor to bitwise-or with <paramref name="left" />.</param>
/// <returns>A new tensor containing the result of <paramref name="left" /> | <paramref name="right" />.</returns>
public static Tensor<TScalar> operator |(TScalar left, in ReadOnlyTensorSpan<TScalar> right) => BitwiseOr(right, left);
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
extension<TScalar>(Tensor<TScalar> tensor)
where TScalar : IBitwiseOperators<TScalar, TScalar, TScalar>
{
/// <inheritdoc cref="op_BitwiseOr{T}(in ReadOnlyTensorSpan{T}, in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator |(Tensor<TScalar> left, Tensor<TScalar> right) => BitwiseOr<TScalar>(left, right);
/// <inheritdoc cref="op_BitwiseOr{T}(in ReadOnlyTensorSpan{T}, T)" />
public static Tensor<TScalar> operator |(Tensor<TScalar> left, TScalar right) => BitwiseOr(left, right);
/// <inheritdoc cref="op_BitwiseOr{T}(T, in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator |(TScalar left, Tensor<TScalar> right) => BitwiseOr(right, left);
/// <inheritdoc cref="op_BitwiseOrAssignment{T}(ref TensorSpan{T}, in ReadOnlyTensorSpan{T})" />
public void operator |=(in ReadOnlyTensorSpan<TScalar> other) => BitwiseOr(tensor, other, tensor);
/// <inheritdoc cref="op_BitwiseOrAssignment{T}(ref TensorSpan{T}, T)" />
public void operator |=(TScalar other) => BitwiseOr(tensor, other, tensor);
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
/// <param name="tensor">The tensor to operate on.</param>
extension<TScalar>(ref TensorSpan<TScalar> tensor)
where TScalar : IBitwiseOperators<TScalar, TScalar, TScalar>
{
/// <inheritdoc cref="op_BitwiseOr{T}(in ReadOnlyTensorSpan{T}, in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator |(in TensorSpan<TScalar> left, in TensorSpan<TScalar> right) => BitwiseOr<TScalar>(left, right);
/// <inheritdoc cref="op_BitwiseOr{T}(in ReadOnlyTensorSpan{T}, T)" />
public static Tensor<TScalar> operator |(in TensorSpan<TScalar> left, TScalar right) => BitwiseOr(left, right);
/// <inheritdoc cref="op_BitwiseOr{T}(T, in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator |(TScalar left, in TensorSpan<TScalar> right) => BitwiseOr(right, left);
/// <summary>Performs in-place bitwise-or between two tensors.</summary>
/// <param name="other">The tensor to bitwise-or with the tensor being operated on.</param>
public void operator |=(in ReadOnlyTensorSpan<TScalar> other) => BitwiseOr(tensor, other, tensor);
/// <summary>Performs in-place bitwise-or between a tensor and scalar.</summary>
/// <param name="other">The scalar to bitwise-or with the tensor being operated on.</param>
public void operator |=(TScalar other) => BitwiseOr(tensor, other, tensor);
}
}
}

View File

@ -0,0 +1,52 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Numerics.Tensors
{
public static partial class Tensor
{
/// <summary>Performs an decrement on a tensor.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor to decrement.</param>
/// <returns>A new tensor containing the result of ~<paramref name="x" />.</returns>
public static Tensor<T> Decrement<T>(in ReadOnlyTensorSpan<T> x)
where T : IDecrementOperators<T>
{
Tensor<T> destination = CreateFromShapeUninitialized<T>(x.Lengths);
TensorOperation.Invoke<TensorOperation.Decrement<T>, T, T>(x, destination);
return destination;
}
/// <summary>Performs an decrement on a tensor.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor to decrement.</param>
/// <param name="destination">The destination where the result of ~<paramref name="x" /> is written.</param>
/// <returns>A reference to <paramref name="destination" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="x" /> and <paramref name="destination" /> are not compatible.</exception>
public static ref readonly TensorSpan<T> Decrement<T>(scoped in ReadOnlyTensorSpan<T> x, in TensorSpan<T> destination)
where T : IDecrementOperators<T>
{
TensorOperation.ValidateCompatibility(x, destination);
TensorOperation.Invoke<TensorOperation.Decrement<T>, T, T>(x, destination);
return ref destination;
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
/// <param name="tensor">The tensor to operate on.</param>
extension<TScalar>(Tensor<TScalar> tensor)
where TScalar : IDecrementOperators<TScalar>
{
/// <inheritdoc cref="op_DecrementAssignment{T}(ref TensorSpan{T})" />
public void operator --() => Decrement<TScalar>(tensor, tensor);
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
/// <param name="tensor">The tensor to operate on.</param>
extension<TScalar>(ref TensorSpan<TScalar> tensor)
where TScalar : IDecrementOperators<TScalar>
{
/// <summary>Performs in-place decrement on a tensor.</summary>
public void operator --() => Decrement<TScalar>(tensor, tensor);
}
}
}

View File

@ -0,0 +1,159 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Numerics.Tensors
{
public static partial class Tensor
{
/// <summary>Performs element-wise division between two tensors.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor dividend.</param>
/// <param name="y">The tensor divisor.</param>
/// <returns>A new tensor containing the result of <paramref name="x" /> / <paramref name="y" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="x" /> and <paramref name="y" /> are not compatible.</exception>
public static Tensor<T> Divide<T>(in ReadOnlyTensorSpan<T> x, in ReadOnlyTensorSpan<T> y)
where T : IDivisionOperators<T, T, T>
{
TensorOperation.ValidateCompatibility(x, y, out Tensor<T> destination);
TensorOperation.Invoke<TensorOperation.Divide<T>, T, T>(x, y, destination);
return destination;
}
/// <summary>Performs element-wise division between a tensor and scalar.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor dividend.</param>
/// <param name="y">The scalar divisor.</param>
/// <returns>A new tensor containing the result of <paramref name="x" /> / <paramref name="y" />.</returns>
public static Tensor<T> Divide<T>(in ReadOnlyTensorSpan<T> x, T y)
where T : IDivisionOperators<T, T, T>
{
Tensor<T> destination = CreateFromShapeUninitialized<T>(x.Lengths);
TensorOperation.Invoke<TensorOperation.Divide<T>, T, T>(x, y, destination);
return destination;
}
/// <summary>Performs element-wise division between a tensor and scalar.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The scalar dividend.</param>
/// <param name="y">The tensor divisor.</param>
/// <returns>A new tensor containing the result of <paramref name="x" /> / <paramref name="y" />.</returns>
public static Tensor<T> Divide<T>(T x, in ReadOnlyTensorSpan<T> y)
where T : IDivisionOperators<T, T, T>
{
Tensor<T> destination = CreateFromShapeUninitialized<T>(y.Lengths);
TensorOperation.Invoke<TensorOperation.Divide<T>, T, T>(x, y, destination);
return destination;
}
/// <summary>Performs element-wise division between two tensors.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor dividend.</param>
/// <param name="y">The tensor divisor.</param>
/// <param name="destination">The destination where the result of <paramref name="x" /> / <paramref name="y" /> is written.</param>
/// <returns>A reference to <paramref name="destination" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="x" />, <paramref name="y" />, and <paramref name="destination" /> are not compatible.</exception>
public static ref readonly TensorSpan<T> Divide<T>(scoped in ReadOnlyTensorSpan<T> x, scoped in ReadOnlyTensorSpan<T> y, in TensorSpan<T> destination)
where T : IDivisionOperators<T, T, T>
{
TensorOperation.ValidateCompatibility(x, y, destination);
TensorOperation.Invoke<TensorOperation.Divide<T>, T, T>(x, y, destination);
return ref destination;
}
/// <summary>Performs element-wise division between a tensor and scalar.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor dividend.</param>
/// <param name="y">The scalar divisor.</param>
/// <param name="destination">The destination where the result of <paramref name="x" /> / <paramref name="y" /> is written.</param>
/// <returns>A reference to <paramref name="destination" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="x" /> and <paramref name="destination" /> are not compatible.</exception>
public static ref readonly TensorSpan<T> Divide<T>(scoped in ReadOnlyTensorSpan<T> x, T y, in TensorSpan<T> destination)
where T : IDivisionOperators<T, T, T>
{
TensorOperation.ValidateCompatibility(x, destination);
TensorOperation.Invoke<TensorOperation.Divide<T>, T, T>(x, y, destination);
return ref destination;
}
/// <summary>Performs element-wise division between a tensor and scalar.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The scalar dividend.</param>
/// <param name="y">The tensor divisor.</param>
/// <param name="destination">The destination where the result of <paramref name="x" /> / <paramref name="y" /> is written.</param>
/// <exception cref="ArgumentException">The shapes of <paramref name="y" /> and <paramref name="destination" /> are not compatible.</exception>
public static ref readonly TensorSpan<T> Divide<T>(T x, scoped in ReadOnlyTensorSpan<T> y, in TensorSpan<T> destination)
where T : IDivisionOperators<T, T, T>
{
TensorOperation.ValidateCompatibility(y, destination);
TensorOperation.Invoke<TensorOperation.Divide<T>, T, T>(x, y, destination);
return ref destination;
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
extension<TScalar>(ReadOnlyTensorSpan<TScalar>)
where TScalar : IDivisionOperators<TScalar, TScalar, TScalar>
{
/// <summary>Performs element-wise division between two tensors.</summary>
/// <param name="left">The tensor dividend.</param>
/// <param name="right">The tensor divisor.</param>
/// <returns>A new tensor containing the result of <paramref name="left" /> / <paramref name="right" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="left" /> and <paramref name="right" /> are not compatible.</exception>
public static Tensor<TScalar> operator /(in ReadOnlyTensorSpan<TScalar> left, in ReadOnlyTensorSpan<TScalar> right) => Divide(left, right);
/// <summary>Performs element-wise division between a tensor and scalar.</summary>
/// <param name="left">The tensor dividend.</param>
/// <param name="right">The scalar divisor.</param>
/// <returns>A new tensor containing the result of <paramref name="left" /> / <paramref name="right" />.</returns>
public static Tensor<TScalar> operator /(in ReadOnlyTensorSpan<TScalar> left, TScalar right) => Divide(left, right);
/// <summary>Performs element-wise division between a tensor and scalar.</summary>
/// <param name="left">The scalar dividend.</param>
/// <param name="right">The tensor divisor.</param>
/// <returns>A new tensor containing the result of <paramref name="left" /> / <paramref name="right" />.</returns>
public static Tensor<TScalar> operator /(TScalar left, in ReadOnlyTensorSpan<TScalar> right) => Divide(right, left);
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
extension<TScalar>(Tensor<TScalar> tensor)
where TScalar : IDivisionOperators<TScalar, TScalar, TScalar>
{
/// <inheritdoc cref="op_Division{T}(in ReadOnlyTensorSpan{T}, in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator /(Tensor<TScalar> left, Tensor<TScalar> right) => Divide<TScalar>(left, right);
/// <inheritdoc cref="op_Division{T}(in ReadOnlyTensorSpan{T}, T)" />
public static Tensor<TScalar> operator /(Tensor<TScalar> left, TScalar right) => Divide(left, right);
/// <inheritdoc cref="op_Division{T}(T, in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator /(TScalar left, Tensor<TScalar> right) => Divide(right, left);
/// <inheritdoc cref="op_DivisionAssignment{T}(ref TensorSpan{T}, in ReadOnlyTensorSpan{T})" />
public void operator /=(in ReadOnlyTensorSpan<TScalar> other) => Divide(tensor, other, tensor);
/// <inheritdoc cref="op_DivisionAssignment{T}(ref TensorSpan{T}, T)" />
public void operator /=(TScalar other) => Divide(tensor, other, tensor);
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
/// <param name="tensor">The tensor to operate on.</param>
extension<TScalar>(ref TensorSpan<TScalar> tensor)
where TScalar : IDivisionOperators<TScalar, TScalar, TScalar>
{
/// <inheritdoc cref="op_Division{T}(in ReadOnlyTensorSpan{T}, in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator /(in TensorSpan<TScalar> left, in TensorSpan<TScalar> right) => Divide<TScalar>(left, right);
/// <inheritdoc cref="op_Division{T}(in ReadOnlyTensorSpan{T}, T)" />
public static Tensor<TScalar> operator /(in TensorSpan<TScalar> left, TScalar right) => Divide(left, right);
/// <inheritdoc cref="op_Division{T}(T, in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator /(TScalar left, in TensorSpan<TScalar> right) => Divide(right, left);
/// <summary>Performs in-place element-wise division between two tensors.</summary>
/// <param name="other">The tensor divisor.</param>
public void operator /=(in ReadOnlyTensorSpan<TScalar> other) => Divide(tensor, other, tensor);
/// <summary>Performs in-place element-wise division between a tensor and scalar.</summary>
/// <param name="other">The scalar divisor.</param>
public void operator /=(TScalar other) => Divide(tensor, other, tensor);
}
}
}

View File

@ -0,0 +1,132 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Numerics.Tensors
{
public static partial class Tensor
{
/// <summary>Performs exclusive-or between two tensors.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor to exclusive-or with <paramref name="y" />.</param>
/// <param name="y">The tensor to exclusive-or with <paramref name="x" />.</param>
/// <returns>A new tensor containing the result of <paramref name="x" /> ^ <paramref name="y" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="x" /> and <paramref name="y" /> are not compatible.</exception>
public static Tensor<T> Xor<T>(in ReadOnlyTensorSpan<T> x, in ReadOnlyTensorSpan<T> y)
where T : IBitwiseOperators<T, T, T>
{
Tensor<T> destination = CreateFromShapeUninitialized<T>(x.Lengths);
TensorOperation.Invoke<TensorOperation.Xor<T>, T, T>(x, y, destination);
return destination;
}
/// <summary>Performs exclusive-or between a tensor and scalar.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor to exclusive-or with <paramref name="y" />.</param>
/// <param name="y">The scalar to exclusive-or with <paramref name="x" />.</param>
/// <returns>A new tensor containing the result of <paramref name="x" /> ^ <paramref name="y" />.</returns>
public static Tensor<T> Xor<T>(in ReadOnlyTensorSpan<T> x, T y)
where T : IBitwiseOperators<T, T, T>
{
Tensor<T> destination = CreateFromShapeUninitialized<T>(x.Lengths);
TensorOperation.Invoke<TensorOperation.Xor<T>, T, T>(x, y, destination);
return destination;
}
/// <summary>Performs exclusive-or between two tensors.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor to exclusive-or with <paramref name="y" />.</param>
/// <param name="y">The tensor to exclusive-or with <paramref name="x" />.</param>
/// <param name="destination">The destination where the result of <paramref name="x" /> ^ <paramref name="y" /> is written.</param>
/// <returns>A reference to <paramref name="destination" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="x" />, <paramref name="y" />, and <paramref name="destination" /> are not compatible.</exception>
public static ref readonly TensorSpan<T> Xor<T>(scoped in ReadOnlyTensorSpan<T> x, scoped in ReadOnlyTensorSpan<T> y, in TensorSpan<T> destination)
where T : IBitwiseOperators<T, T, T>
{
TensorOperation.ValidateCompatibility(x, y, destination);
TensorOperation.Invoke<TensorOperation.Xor<T>, T, T>(x, y, destination);
return ref destination;
}
/// <summary>Performs exclusive-or between a tensor and scalar.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor to exclusive-or with <paramref name="y" />.</param>
/// <param name="y">The scalar to exclusive-or with <paramref name="x" />.</param>
/// <param name="destination">The destination where the result of <paramref name="x" /> ^ <paramref name="y" /> is written.</param>
/// <returns>A reference to <paramref name="destination" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="x" /> and <paramref name="destination" /> are not compatible.</exception>
public static ref readonly TensorSpan<T> Xor<T>(scoped in ReadOnlyTensorSpan<T> x, T y, in TensorSpan<T> destination)
where T : IBitwiseOperators<T, T, T>
{
TensorOperation.ValidateCompatibility(x, destination);
TensorOperation.Invoke<TensorOperation.Xor<T>, T, T>(x, y, destination);
return ref destination;
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
extension<TScalar>(ReadOnlyTensorSpan<TScalar>)
where TScalar : IBitwiseOperators<TScalar, TScalar, TScalar>
{
/// <summary>Performs exclusive-or between two tensors.</summary>
/// <param name="left">The tensor to exclusive-or with <paramref name="right" />.</param>
/// <param name="right">The tensor to exclusive-or with <paramref name="left" />.</param>
/// <returns>A new tensor containing the result of <paramref name="left" /> ^ <paramref name="right" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="left" /> and <paramref name="right" /> are not compatible.</exception>
public static Tensor<TScalar> operator ^(in ReadOnlyTensorSpan<TScalar> left, in ReadOnlyTensorSpan<TScalar> right) => Xor(left, right);
/// <summary>Performs exclusive-or between a tensor and scalar.</summary>
/// <param name="left">The tensor to exclusive-or with <paramref name="right" />.</param>
/// <param name="right">The scalar to exclusive-or with <paramref name="left" />.</param>
/// <returns>A new tensor containing the result of <paramref name="left" /> ^ <paramref name="right" />.</returns>
public static Tensor<TScalar> operator ^(in ReadOnlyTensorSpan<TScalar> left, TScalar right) => Xor(left, right);
/// <summary>Performs exclusive-or between a tensor and scalar.</summary>
/// <param name="left">The scalar to exclusive-or with <paramref name="right" />.</param>
/// <param name="right">The tensor to exclusive-or with <paramref name="left" />.</param>
/// <returns>A new tensor containing the result of <paramref name="left" /> ^ <paramref name="right" />.</returns>
public static Tensor<TScalar> operator ^(TScalar left, in ReadOnlyTensorSpan<TScalar> right) => Xor(right, left);
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
extension<TScalar>(Tensor<TScalar> tensor)
where TScalar : IBitwiseOperators<TScalar, TScalar, TScalar>
{
/// <inheritdoc cref="op_ExclusiveOr{T}(in ReadOnlyTensorSpan{T}, in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator ^(Tensor<TScalar> left, Tensor<TScalar> right) => Xor<TScalar>(left, right);
/// <inheritdoc cref="op_ExclusiveOr{T}(in ReadOnlyTensorSpan{T}, T)" />
public static Tensor<TScalar> operator ^(Tensor<TScalar> left, TScalar right) => Xor(left, right);
/// <inheritdoc cref="op_ExclusiveOr{T}(T, in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator ^(TScalar left, Tensor<TScalar> right) => Xor(right, left);
/// <inheritdoc cref="op_ExclusiveOrAssignment{T}(ref TensorSpan{T}, in ReadOnlyTensorSpan{T})" />
public void operator ^=(in ReadOnlyTensorSpan<TScalar> other) => Xor(tensor, other, tensor);
/// <inheritdoc cref="op_ExclusiveOrAssignment{T}(ref TensorSpan{T}, T)" />
public void operator ^=(TScalar other) => Xor(tensor, other, tensor);
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
/// <param name="tensor">The tensor to operate on.</param>
extension<TScalar>(ref TensorSpan<TScalar> tensor)
where TScalar : IBitwiseOperators<TScalar, TScalar, TScalar>
{
/// <inheritdoc cref="op_ExclusiveOr{T}(in ReadOnlyTensorSpan{T}, in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator ^(in TensorSpan<TScalar> left, in TensorSpan<TScalar> right) => Xor<TScalar>(left, right);
/// <inheritdoc cref="op_ExclusiveOr{T}(in ReadOnlyTensorSpan{T}, T)" />
public static Tensor<TScalar> operator ^(in TensorSpan<TScalar> left, TScalar right) => Xor(left, right);
/// <inheritdoc cref="op_ExclusiveOr{T}(T, in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator ^(TScalar left, in TensorSpan<TScalar> right) => Xor(right, left);
/// <summary>Performs in-place exclusive-or between two tensors.</summary>
/// <param name="other">The tensor to exclusive-or with the tensor being operated on.</param>
public void operator ^=(in ReadOnlyTensorSpan<TScalar> other) => Xor(tensor, other, tensor);
/// <summary>Performs in-place exclusive-or between a tensor and scalar.</summary>
/// <param name="other">The scalar to exclusive-or with the tensor being operated on.</param>
public void operator ^=(TScalar other) => Xor(tensor, other, tensor);
}
}
}

View File

@ -0,0 +1,52 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Numerics.Tensors
{
public static partial class Tensor
{
/// <summary>Performs an increment on a tensor.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor to increment.</param>
/// <returns>A new tensor containing the result of ~<paramref name="x" />.</returns>
public static Tensor<T> Increment<T>(in ReadOnlyTensorSpan<T> x)
where T : IIncrementOperators<T>
{
Tensor<T> destination = CreateFromShapeUninitialized<T>(x.Lengths);
TensorOperation.Invoke<TensorOperation.Increment<T>, T, T>(x, destination);
return destination;
}
/// <summary>Performs an increment on a tensor.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor to increment.</param>
/// <param name="destination">The destination where the result of ~<paramref name="x" /> is written.</param>
/// <returns>A reference to <paramref name="destination" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="x" /> and <paramref name="destination" /> are not compatible.</exception>
public static ref readonly TensorSpan<T> Increment<T>(scoped in ReadOnlyTensorSpan<T> x, in TensorSpan<T> destination)
where T : IIncrementOperators<T>
{
TensorOperation.ValidateCompatibility(x, destination);
TensorOperation.Invoke<TensorOperation.Increment<T>, T, T>(x, destination);
return ref destination;
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
/// <param name="tensor">The tensor to operate on.</param>
extension<TScalar>(Tensor<TScalar> tensor)
where TScalar : IIncrementOperators<TScalar>
{
/// <inheritdoc cref="op_IncrementAssignment{T}(ref TensorSpan{T})" />
public void operator ++() => Increment<TScalar>(tensor, tensor);
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
/// <param name="tensor">The tensor to operate on.</param>
extension<TScalar>(ref TensorSpan<TScalar> tensor)
where TScalar : IIncrementOperators<TScalar>
{
/// <summary>Performs in-place increment on a tensor.</summary>
public void operator ++() => Increment<TScalar>(tensor, tensor);
}
}
}

View File

@ -0,0 +1,82 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Numerics.Tensors
{
public static partial class Tensor
{
/// <summary>Performs an element-wise left shift on a tensor.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor to left shift.</param>
/// <param name="shiftAmount">The amount to shift each element in <paramref name="x" />.</param>
/// <returns>A new tensor containing the result of <paramref name="x" /> &lt;&lt; <paramref name="shiftAmount" />.</returns>
public static Tensor<T> ShiftLeft<T>(in ReadOnlyTensorSpan<T> x, int shiftAmount)
where T : IShiftOperators<T, int, T>
{
Tensor<T> destination = CreateFromShapeUninitialized<T>(x.Lengths);
TensorOperation.Invoke<TensorOperation.ShiftLeft<T>, T, int, T>(x, shiftAmount, destination);
return destination;
}
/// <summary>Performs an element-wise left shift on a tensor.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor to left shift.</param>
/// <param name="shiftAmount">The amount to shift each element in <paramref name="x" />.</param>
/// <param name="destination">The destination where the result of <paramref name="x" /> &lt;&lt; <paramref name="shiftAmount" /> is written.</param>
/// <returns>A reference to <paramref name="destination" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="x" /> and <paramref name="destination" /> are not compatible.</exception>
public static ref readonly TensorSpan<T> ShiftLeft<T>(scoped in ReadOnlyTensorSpan<T> x, int shiftAmount, in TensorSpan<T> destination)
where T : IShiftOperators<T, int, T>
{
TensorOperation.ValidateCompatibility(x, destination);
TensorOperation.Invoke<TensorOperation.ShiftLeft<T>, T, int, T>(x, shiftAmount, destination);
return ref destination;
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
extension<TScalar>(ReadOnlyTensorSpan<TScalar>)
where TScalar : IShiftOperators<TScalar, int, TScalar>
{
/// <summary>Performs an element-wise left shift on a tensor.</summary>
/// <param name="tensor">The tensor to left shift.</param>
/// <param name="shiftAmount">The amount to shift each element in <paramref name="tensor" />.</param>
/// <returns>A new tensor containing the result of <paramref name="tensor" /> &lt;&lt; <paramref name="shiftAmount" />.</returns>
public static Tensor<TScalar> operator <<(in ReadOnlyTensorSpan<TScalar> tensor, int shiftAmount) => ShiftLeft(tensor, shiftAmount);
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
extension<TScalar>(Tensor<TScalar>)
where TScalar : IShiftOperators<TScalar, int, TScalar>
{
/// <inheritdoc cref="op_LeftShift{T}(in ReadOnlyTensorSpan{T}, int)" />
public static Tensor<TScalar> operator <<(Tensor<TScalar> tensor, int shiftAmount) => ShiftLeft<TScalar>(tensor, shiftAmount);
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
/// <param name="tensor">The tensor to operate on.</param>
extension<TScalar>(Tensor<TScalar> tensor)
where TScalar : IShiftOperators<TScalar, int, TScalar>
{
/// <inheritdoc cref="op_LeftShiftAssignment{T}(ref TensorSpan{T}, int)" />
public void operator <<=(int shiftAmount) => ShiftLeft<TScalar>(tensor, shiftAmount, tensor);
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
extension<TScalar>(TensorSpan<TScalar>)
where TScalar : IShiftOperators<TScalar, int, TScalar>
{
/// <inheritdoc cref="op_LeftShift{T}(in ReadOnlyTensorSpan{T}, int)" />
public static Tensor<TScalar> operator <<(in TensorSpan<TScalar> tensor, int shiftAmount) => ShiftLeft<TScalar>(tensor, shiftAmount);
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
/// <param name="tensor">The tensor to operate on.</param>
extension<TScalar>(ref TensorSpan<TScalar> tensor)
where TScalar : IShiftOperators<TScalar, int, TScalar>
{
/// <summary>Performs in-place element-wise left shift on a tensor.</summary>
/// <param name="shiftAmount">The amount to shift each element in the tensor.</param>
public void operator <<=(int shiftAmount) => ShiftLeft<TScalar>(tensor, shiftAmount, tensor);
}
}
}

View File

@ -0,0 +1,132 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Numerics.Tensors
{
public static partial class Tensor
{
/// <summary>Performs element-wise multiplication between two tensors.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor to multiply with <paramref name="y" />.</param>
/// <param name="y">The tensor to multiply with <paramref name="x" />.</param>
/// <returns>A new tensor containing the result of <paramref name="x" /> * <paramref name="y" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="x" /> and <paramref name="y" /> are not compatible.</exception>
public static Tensor<T> Multiply<T>(in ReadOnlyTensorSpan<T> x, in ReadOnlyTensorSpan<T> y)
where T : IMultiplyOperators<T, T, T>, IMultiplicativeIdentity<T, T>
{
TensorOperation.ValidateCompatibility(x, y, out Tensor<T> destination);
TensorOperation.Invoke<TensorOperation.Multiply<T>, T, T>(x, y, destination);
return destination;
}
/// <summary>Performs element-wise multiplication between a tensor and scalar.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor to multiply with <paramref name="y" />.</param>
/// <param name="y">The scalar to multiply with <paramref name="x" />.</param>
/// <returns>A new tensor containing the result of <paramref name="x" /> * <paramref name="y" />.</returns>
public static Tensor<T> Multiply<T>(in ReadOnlyTensorSpan<T> x, T y)
where T : IMultiplyOperators<T, T, T>, IMultiplicativeIdentity<T, T>
{
Tensor<T> destination = CreateFromShape<T>(x.Lengths);
TensorOperation.Invoke<TensorOperation.Multiply<T>, T, T>(x, y, destination);
return destination;
}
/// <summary>Performs element-wise multiplication between two tensors.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor to multiply with <paramref name="y" />.</param>
/// <param name="y">The tensor to multiply with <paramref name="x" />.</param>
/// <param name="destination">The destination where the result of <paramref name="x" /> * <paramref name="y" /> is written.</param>
/// <returns>A reference to <paramref name="destination" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="x" />, <paramref name="y" />, and <paramref name="destination" /> are not compatible.</exception>
public static ref readonly TensorSpan<T> Multiply<T>(scoped in ReadOnlyTensorSpan<T> x, scoped in ReadOnlyTensorSpan<T> y, in TensorSpan<T> destination)
where T : IMultiplyOperators<T, T, T>, IMultiplicativeIdentity<T, T>
{
TensorOperation.ValidateCompatibility(x, y, destination);
TensorOperation.Invoke<TensorOperation.Multiply<T>, T, T>(x, y, destination);
return ref destination;
}
/// <summary>Performs element-wise multiplication between a tensor and scalar.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor to multiply with <paramref name="y" />.</param>
/// <param name="y">The scalar to multiply with <paramref name="x" />.</param>
/// <param name="destination">The destination where the result of <paramref name="x" /> * <paramref name="y" /> is written.</param>
/// <returns>A reference to <paramref name="destination" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="x" /> and <paramref name="destination" /> are not compatible.</exception>
public static ref readonly TensorSpan<T> Multiply<T>(scoped in ReadOnlyTensorSpan<T> x, T y, in TensorSpan<T> destination)
where T : IMultiplyOperators<T, T, T>, IMultiplicativeIdentity<T, T>
{
TensorOperation.ValidateCompatibility(x, destination);
TensorOperation.Invoke<TensorOperation.Multiply<T>, T, T>(x, y, destination);
return ref destination;
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
extension<TScalar>(ReadOnlyTensorSpan<TScalar>)
where TScalar : IMultiplyOperators<TScalar, TScalar, TScalar>, System.Numerics.IMultiplicativeIdentity<TScalar, TScalar>
{
/// <summary>Performs element-wise multiplication between two tensors.</summary>
/// <param name="left">The tensor to multiply with <paramref name="right" />.</param>
/// <param name="right">The tensor to multiply with <paramref name="left" />.</param>
/// <returns>A new tensor containing the result of <paramref name="left" /> * <paramref name="right" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="left" /> and <paramref name="right" /> are not compatible.</exception>
public static Tensor<TScalar> operator *(in ReadOnlyTensorSpan<TScalar> left, in ReadOnlyTensorSpan<TScalar> right) => Multiply(left, right);
/// <summary>Performs element-wise multiplication between a tensor and scalar.</summary>
/// <param name="left">The tensor to multiply with <paramref name="right" />.</param>
/// <param name="right">The scalar to multiply with <paramref name="left" />.</param>
/// <returns>A new tensor containing the result of <paramref name="left" /> * <paramref name="right" />.</returns>
public static Tensor<TScalar> operator *(in ReadOnlyTensorSpan<TScalar> left, TScalar right) => Multiply(left, right);
/// <summary>Performs element-wise multiplication between a tensor and scalar.</summary>
/// <param name="left">The scalar to multiply with <paramref name="right" />.</param>
/// <param name="right">The tensor to multiply with <paramref name="left" />.</param>
/// <returns>A new tensor containing the result of <paramref name="left" /> * <paramref name="right" />.</returns>
public static Tensor<TScalar> operator *(TScalar left, in ReadOnlyTensorSpan<TScalar> right) => Multiply(right, left);
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
extension<TScalar>(Tensor<TScalar> tensor)
where TScalar : IMultiplyOperators<TScalar, TScalar, TScalar>, System.Numerics.IMultiplicativeIdentity<TScalar, TScalar>
{
/// <inheritdoc cref="op_Multiply{T}(in ReadOnlyTensorSpan{T}, in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator *(Tensor<TScalar> left, Tensor<TScalar> right) => Multiply<TScalar>(left, right);
/// <inheritdoc cref="op_Multiply{T}(in ReadOnlyTensorSpan{T}, T)" />
public static Tensor<TScalar> operator *(Tensor<TScalar> left, TScalar right) => Multiply(left, right);
/// <inheritdoc cref="op_Multiply{T}(T, in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator *(TScalar left, Tensor<TScalar> right) => Multiply(right, left);
/// <inheritdoc cref="op_MultiplicationAssignment{T}(ref TensorSpan{T}, in ReadOnlyTensorSpan{T})" />
public void operator *=(in ReadOnlyTensorSpan<TScalar> other) => Multiply(tensor, other, tensor);
/// <inheritdoc cref="op_MultiplicationAssignment{T}(ref TensorSpan{T}, T)" />
public void operator *=(TScalar other) => Multiply(tensor, other, tensor);
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
/// <param name="tensor">The tensor to operate on.</param>
extension<TScalar>(ref TensorSpan<TScalar> tensor)
where TScalar : IMultiplyOperators<TScalar, TScalar, TScalar>, System.Numerics.IMultiplicativeIdentity<TScalar, TScalar>
{
/// <inheritdoc cref="op_Multiply{T}(in ReadOnlyTensorSpan{T}, in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator *(in TensorSpan<TScalar> left, in TensorSpan<TScalar> right) => Multiply<TScalar>(left, right);
/// <inheritdoc cref="op_Multiply{T}(in ReadOnlyTensorSpan{T}, T)" />
public static Tensor<TScalar> operator *(in TensorSpan<TScalar> left, TScalar right) => Multiply(left, right);
/// <inheritdoc cref="op_Multiply{T}(T, in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator *(TScalar left, in TensorSpan<TScalar> right) => Multiply(right, left);
/// <summary>Performs in-place element-wise multiplication between two tensors.</summary>
/// <param name="other">The tensor used to multiply the tensor being operated on.</param>
public void operator *=(in ReadOnlyTensorSpan<TScalar> other) => Multiply(tensor, other, tensor);
/// <summary>Performs in-place element-wise multiplication between a tensor and scalar.</summary>
/// <param name="other">The scalar used to multiply the tensor being operated on.</param>
public void operator *=(TScalar other) => Multiply(tensor, other, tensor);
}
}
}

View File

@ -0,0 +1,60 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Numerics.Tensors
{
public static partial class Tensor
{
/// <summary>Performs a one's complement on a tensor.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor to one's complement.</param>
/// <returns>A new tensor containing the result of ~<paramref name="x" />.</returns>
public static Tensor<T> OnesComplement<T>(in ReadOnlyTensorSpan<T> x)
where T : IBitwiseOperators<T, T, T>
{
Tensor<T> destination = CreateFromShapeUninitialized<T>(x.Lengths);
TensorOperation.Invoke<TensorOperation.OnesComplement<T>, T, T>(x, destination);
return destination;
}
/// <summary>Performs a one's complement on a tensor.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor to one's complement.</param>
/// <param name="destination">The destination where the result of ~<paramref name="x" /> is written.</param>
/// <returns>A reference to <paramref name="destination" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="x" /> and <paramref name="destination" /> are not compatible.</exception>
public static ref readonly TensorSpan<T> OnesComplement<T>(scoped in ReadOnlyTensorSpan<T> x, in TensorSpan<T> destination)
where T : IBitwiseOperators<T, T, T>
{
TensorOperation.ValidateCompatibility(x, destination);
TensorOperation.Invoke<TensorOperation.OnesComplement<T>, T, T>(x, destination);
return ref destination;
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
extension<TScalar>(ReadOnlyTensorSpan<TScalar>)
where TScalar : IBitwiseOperators<TScalar, TScalar, TScalar>
{
/// <summary>Performs a one's complement on a tensor.</summary>
/// <param name="tensor">The tensor to one's complement.</param>
/// <returns>A new tensor containing the result of ~<paramref name="tensor" />.</returns>
public static Tensor<TScalar> operator ~(in ReadOnlyTensorSpan<TScalar> tensor) => OnesComplement(tensor);
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
extension<TScalar>(Tensor<TScalar>)
where TScalar : IBitwiseOperators<TScalar, TScalar, TScalar>
{
/// <inheritdoc cref="op_OnesComplement{T}(in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator ~(Tensor<TScalar> tensor) => OnesComplement<TScalar>(tensor);
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
extension<TScalar>(TensorSpan<TScalar>)
where TScalar : IBitwiseOperators<TScalar, TScalar, TScalar>
{
/// <inheritdoc cref="op_OnesComplement{T}(in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator ~(in TensorSpan<TScalar> tensor) => OnesComplement<TScalar>(tensor);
}
}
}

View File

@ -0,0 +1,82 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Numerics.Tensors
{
public static partial class Tensor
{
/// <summary>Performs an element-wise arithmetic right shift on a tensor.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor to arithmetic right shift.</param>
/// <param name="shiftAmount">The amount to shift each element in <paramref name="x" />.</param>
/// <returns>A new tensor containing the result of <paramref name="x" /> &gt;&gt; <paramref name="shiftAmount" />.</returns>
public static Tensor<T> ShiftRightArithmetic<T>(in ReadOnlyTensorSpan<T> x, int shiftAmount)
where T : IShiftOperators<T, int, T>
{
Tensor<T> destination = CreateFromShapeUninitialized<T>(x.Lengths);
TensorOperation.Invoke<TensorOperation.ShiftRightArithmetic<T>, T, int, T>(x, shiftAmount, destination);
return destination;
}
/// <summary>Performs an element-wise arithmetic right shift on a tensor.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor to arithmetic right shift.</param>
/// <param name="shiftAmount">The amount to shift each element in <paramref name="x" />.</param>
/// <param name="destination">The destination where the result of <paramref name="x" /> &gt;&gt; <paramref name="shiftAmount" /> is written.</param>
/// <returns>A reference to <paramref name="destination" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="x" /> and <paramref name="destination" /> are not compatible.</exception>
public static ref readonly TensorSpan<T> ShiftRightArithmetic<T>(scoped in ReadOnlyTensorSpan<T> x, int shiftAmount, in TensorSpan<T> destination)
where T : IShiftOperators<T, int, T>
{
TensorOperation.ValidateCompatibility(x, destination);
TensorOperation.Invoke<TensorOperation.ShiftRightArithmetic<T>, T, int, T>(x, shiftAmount, destination);
return ref destination;
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
extension<TScalar>(ReadOnlyTensorSpan<TScalar>)
where TScalar : IShiftOperators<TScalar, int, TScalar>
{
/// <summary>Performs an element-wise arithmetic right shift on a tensor.</summary>
/// <param name="tensor">The tensor to arithmetic right shift.</param>
/// <param name="shiftAmount">The amount to shift each element in <paramref name="tensor" />.</param>
/// <returns>A new tensor containing the result of <paramref name="tensor" /> &gt;&gt; <paramref name="shiftAmount" />.</returns>
public static Tensor<TScalar> operator >>(in ReadOnlyTensorSpan<TScalar> tensor, int shiftAmount) => ShiftRightArithmetic(tensor, shiftAmount);
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
extension<TScalar>(Tensor<TScalar>)
where TScalar : IShiftOperators<TScalar, int, TScalar>
{
/// <inheritdoc cref="op_LeftShift{T}(in ReadOnlyTensorSpan{T}, int)" />
public static Tensor<TScalar> operator >>(Tensor<TScalar> tensor, int shiftAmount) => ShiftRightArithmetic<TScalar>(tensor, shiftAmount);
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
/// <param name="tensor">The tensor to operate on.</param>
extension<TScalar>(Tensor<TScalar> tensor)
where TScalar : IShiftOperators<TScalar, int, TScalar>
{
/// <inheritdoc cref="op_LeftShiftAssignment{T}(ref TensorSpan{T}, int)" />
public void operator >>=(int shiftAmount) => ShiftRightArithmetic<TScalar>(tensor, shiftAmount, tensor);
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
extension<TScalar>(TensorSpan<TScalar>)
where TScalar : IShiftOperators<TScalar, int, TScalar>
{
/// <inheritdoc cref="op_LeftShift{T}(in ReadOnlyTensorSpan{T}, int)" />
public static Tensor<TScalar> operator >>(in TensorSpan<TScalar> tensor, int shiftAmount) => ShiftRightArithmetic<TScalar>(tensor, shiftAmount);
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
/// <param name="tensor">The tensor to operate on.</param>
extension<TScalar>(ref TensorSpan<TScalar> tensor)
where TScalar : IShiftOperators<TScalar, int, TScalar>
{
/// <summary>Performs in-place element-wise arithmetic right shift on a tensor.</summary>
/// <param name="shiftAmount">The amount to shift each element in the tensor.</param>
public void operator >>=(int shiftAmount) => ShiftRightArithmetic<TScalar>(tensor, shiftAmount, tensor);
}
}
}

View File

@ -0,0 +1,160 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Numerics.Tensors
{
public static partial class Tensor
{
/// <summary>Performs element-wise subtraction between two tensors.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor from which to subtract <paramref name="y" />.</param>
/// <param name="y">The tensor to subtract from <paramref name="x" />.</param>
/// <returns>A new tensor containing the result of <paramref name="x" /> - <paramref name="y" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="x" /> and <paramref name="y" /> are not compatible.</exception>
public static Tensor<T> Subtract<T>(in ReadOnlyTensorSpan<T> x, in ReadOnlyTensorSpan<T> y)
where T : ISubtractionOperators<T, T, T>
{
TensorOperation.ValidateCompatibility(x, y, out Tensor<T> destination);
TensorOperation.Invoke<TensorOperation.Subtract<T>, T, T>(x, y, destination);
return destination;
}
/// <summary>Performs element-wise subtraction between a tensor and scalar.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor from which to subtract <paramref name="y" />.</param>
/// <param name="y">The scalar to subtract from <paramref name="x" />.</param>
/// <returns>A new tensor containing the result of <paramref name="x" /> - <paramref name="y" />.</returns>
public static Tensor<T> Subtract<T>(in ReadOnlyTensorSpan<T> x, T y)
where T : ISubtractionOperators<T, T, T>
{
Tensor<T> destination = CreateFromShapeUninitialized<T>(x.Lengths);
TensorOperation.Invoke<TensorOperation.Subtract<T>, T, T>(x, y, destination);
return destination;
}
/// <summary>Performs element-wise subtraction between a tensor and scalar.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The scalar from which to subtract <paramref name="y" />.</param>
/// <param name="y">The tensor to subtract from <paramref name="x" />.</param>
/// <returns>A new tensor containing the result of <paramref name="x" /> - <paramref name="y" />.</returns>
public static Tensor<T> Subtract<T>(T x, in ReadOnlyTensorSpan<T> y)
where T : ISubtractionOperators<T, T, T>
{
Tensor<T> destination = CreateFromShapeUninitialized<T>(y.Lengths);
TensorOperation.Invoke<TensorOperation.Subtract<T>, T, T>(x, y, destination);
return destination;
}
/// <summary>Performs element-wise subtraction between two tensors.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor from which to subtract <paramref name="y" />.</param>
/// <param name="y">The tensor to subtract from <paramref name="x" />.</param>
/// <param name="destination">The destination where the result of <paramref name="x" /> - <paramref name="y" /> is written.</param>
/// <returns>A reference to <paramref name="destination" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="x" />, <paramref name="y" />, and <paramref name="destination" /> are not compatible.</exception>
public static ref readonly TensorSpan<T> Subtract<T>(scoped in ReadOnlyTensorSpan<T> x, scoped in ReadOnlyTensorSpan<T> y, in TensorSpan<T> destination)
where T : ISubtractionOperators<T, T, T>
{
TensorOperation.ValidateCompatibility(x, y, destination);
TensorOperation.Invoke<TensorOperation.Subtract<T>, T, T>(x, y, destination);
return ref destination;
}
/// <summary>Performs element-wise subtraction between a tensor and scalar.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor from which to subtract <paramref name="y" />.</param>
/// <param name="y">The scalar to subtract from <paramref name="x" />.</param>
/// <param name="destination">The destination where the result of <paramref name="x" /> - <paramref name="y" /> is written.</param>
/// <returns>A reference to <paramref name="destination" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="x" /> and <paramref name="destination" /> are not compatible.</exception>
public static ref readonly TensorSpan<T> Subtract<T>(scoped in ReadOnlyTensorSpan<T> x, T y, in TensorSpan<T> destination)
where T : ISubtractionOperators<T, T, T>
{
TensorOperation.ValidateCompatibility(x, destination);
TensorOperation.Invoke<TensorOperation.Subtract<T>, T, T>(x, y, destination);
return ref destination;
}
/// <summary>Performs element-wise subtraction between a tensor and scalar.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The scalar from which to subtract <paramref name="y" />.</param>
/// <param name="y">The tensor to subtract from <paramref name="x" />.</param>
/// <param name="destination">The destination where the result of <paramref name="x" /> - <paramref name="y" /> is written.</param>
/// <returns>A reference to <paramref name="destination" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="y" /> and <paramref name="destination" /> are not compatible.</exception>
public static ref readonly TensorSpan<T> Subtract<T>(T x, scoped in ReadOnlyTensorSpan<T> y, in TensorSpan<T> destination)
where T : ISubtractionOperators<T, T, T>
{
TensorOperation.ValidateCompatibility(y, destination);
TensorOperation.Invoke<TensorOperation.Subtract<T>, T, T>(x, y, destination);
return ref destination;
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
extension<TScalar>(ReadOnlyTensorSpan<TScalar>)
where TScalar : ISubtractionOperators<TScalar, TScalar, TScalar>
{
/// <summary>Performs element-wise subtraction between two tensors.</summary>
/// <param name="left">The tensor from which to subtract <paramref name="right" />.</param>
/// <param name="right">The tensor to subtract from <paramref name="left" />.</param>
/// <returns>A new tensor containing the result of <paramref name="left" /> - <paramref name="right" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="left" /> and <paramref name="right" /> are not compatible.</exception>
public static Tensor<TScalar> operator -(in ReadOnlyTensorSpan<TScalar> left, in ReadOnlyTensorSpan<TScalar> right) => Subtract(left, right);
/// <summary>Performs element-wise subtraction between a tensor and scalar.</summary>
/// <param name="left">The tensor from which to subtract <paramref name="right" />.</param>
/// <param name="right">The scalar to subtract from <paramref name="left" />.</param>
/// <returns>A new tensor containing the result of <paramref name="left" /> - <paramref name="right" />.</returns>
public static Tensor<TScalar> operator -(in ReadOnlyTensorSpan<TScalar> left, TScalar right) => Subtract(left, right);
/// <summary>Performs element-wise subtraction between a tensor and scalar.</summary>
/// <param name="left">The scalar from which to subtract <paramref name="right" />.</param>
/// <param name="right">The tensor to subtract from <paramref name="left" />.</param>
/// <returns>A new tensor containing the result of <paramref name="left" /> - <paramref name="right" />.</returns>
public static Tensor<TScalar> operator -(TScalar left, in ReadOnlyTensorSpan<TScalar> right) => Subtract(right, left);
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
extension<TScalar>(Tensor<TScalar> tensor)
where TScalar : ISubtractionOperators<TScalar, TScalar, TScalar>
{
/// <inheritdoc cref="op_Subtraction{T}(in ReadOnlyTensorSpan{T}, in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator -(Tensor<TScalar> left, Tensor<TScalar> right) => Subtract<TScalar>(left, right);
/// <inheritdoc cref="op_Subtraction{T}(in ReadOnlyTensorSpan{T}, T)" />
public static Tensor<TScalar> operator -(Tensor<TScalar> left, TScalar right) => Subtract(left, right);
/// <inheritdoc cref="op_Subtraction{T}(T, in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator -(TScalar left, Tensor<TScalar> right) => Subtract(right, left);
/// <inheritdoc cref="op_SubtractionAssignment{T}(ref TensorSpan{T}, in ReadOnlyTensorSpan{T})" />
public void operator -=(in ReadOnlyTensorSpan<TScalar> other) => Subtract(tensor, other, tensor);
/// <inheritdoc cref="op_SubtractionAssignment{T}(ref TensorSpan{T}, T)" />
public void operator -=(TScalar other) => Subtract(tensor, other, tensor);
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
/// <param name="tensor">The tensor to operate on.</param>
extension<TScalar>(ref TensorSpan<TScalar> tensor)
where TScalar : ISubtractionOperators<TScalar, TScalar, TScalar>
{
/// <inheritdoc cref="op_Subtraction{T}(in ReadOnlyTensorSpan{T}, in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator -(in TensorSpan<TScalar> left, in TensorSpan<TScalar> right) => Subtract<TScalar>(left, right);
/// <inheritdoc cref="op_Subtraction{T}(in ReadOnlyTensorSpan{T}, T)" />
public static Tensor<TScalar> operator -(in TensorSpan<TScalar> left, TScalar right) => Subtract(left, right);
/// <inheritdoc cref="op_Subtraction{T}(T, in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator -(TScalar left, in TensorSpan<TScalar> right) => Subtract(right, left);
/// <summary>Performs in-place element-wise subtraction between two tensors.</summary>
/// <param name="other">The tensor to subtract from the tensor being operated on.</param>
public void operator -=(in ReadOnlyTensorSpan<TScalar> other) => Subtract(tensor, other, tensor);
/// <summary>Performs in-place element-wise subtraction between a tensor and scalar.</summary>
/// <param name="other">The scalar to subtract from the tensor being operated on.</param>
public void operator -=(TScalar other) => Subtract(tensor, other, tensor);
}
}
}

View File

@ -0,0 +1,58 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Numerics.Tensors
{
public static partial class Tensor
{
/// <summary>Performs element-wise unary negation on a tensor.</summary>
/// <param name="x">The tensor to negate.</param>
/// <returns>A new tensor containing the result of -<paramref name="x" />.</returns>
public static Tensor<T> Negate<T>(in ReadOnlyTensorSpan<T> x)
where T : IUnaryNegationOperators<T, T>
{
Tensor<T> destination = CreateFromShapeUninitialized<T>(x.Lengths);
TensorOperation.Invoke<TensorOperation.Negate<T>, T, T>(x, destination);
return destination;
}
/// <summary>Performs element-wise unary negation on a tensor.</summary>
/// <param name="x">The tensor to negate.</param>
/// <param name="destination">The destination where the result of -<paramref name="x" /> is written.</param>
/// <returns>A reference to <paramref name="destination" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="x" /> and <paramref name="destination" /> are not compatible.</exception>
public static ref readonly TensorSpan<T> Negate<T>(scoped in ReadOnlyTensorSpan<T> x, in TensorSpan<T> destination)
where T : IUnaryNegationOperators<T, T>
{
TensorOperation.ValidateCompatibility(x, destination);
TensorOperation.Invoke<TensorOperation.Negate<T>, T, T>(x, destination);
return ref destination;
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
extension<TScalar>(ReadOnlyTensorSpan<TScalar>)
where TScalar : IUnaryNegationOperators<TScalar, TScalar>
{
/// <summary>Performs element-wise unary negation on a tensor.</summary>
/// <param name="tensor">The tensor to negate.</param>
/// <returns>A new tensor containing the result of -<paramref name="tensor" />.</returns>
public static Tensor<TScalar> operator -(in ReadOnlyTensorSpan<TScalar> tensor) => Negate(tensor);
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
extension<TScalar>(Tensor<TScalar>)
where TScalar : IUnaryNegationOperators<TScalar, TScalar>
{
/// <inheritdoc cref="op_UnaryNegation{T}(in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator -(Tensor<TScalar> tensor) => Negate<TScalar>(tensor);
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
extension<TScalar>(TensorSpan<TScalar>)
where TScalar : IUnaryNegationOperators<TScalar, TScalar>
{
/// <inheritdoc cref="op_UnaryNegation{T}(in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator -(in TensorSpan<TScalar> tensor) => Negate<TScalar>(tensor);
}
}
}

View File

@ -0,0 +1,34 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Numerics.Tensors
{
public static partial class Tensor
{
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
extension<TScalar>(ReadOnlyTensorSpan<TScalar>)
where TScalar : IUnaryPlusOperators<TScalar, TScalar>
{
/// <summary>Performs element-wise unary plus on a tensor.</summary>
/// <param name="tensor">The tensor to return.</param>
/// <returns><paramref name="tensor" /></returns>
public static ReadOnlyTensorSpan<TScalar> operator +(in ReadOnlyTensorSpan<TScalar> tensor) => tensor;
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
extension<TScalar>(Tensor<TScalar>)
where TScalar : IUnaryPlusOperators<TScalar, TScalar>
{
/// <inheritdoc cref="op_UnaryPlus{T}(in ReadOnlyTensorSpan{T})" />
public static Tensor<TScalar> operator +(Tensor<TScalar> tensor) => tensor;
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
extension<TScalar>(TensorSpan<TScalar>)
where TScalar : IUnaryPlusOperators<TScalar, TScalar>
{
/// <inheritdoc cref="op_UnaryPlus{T}(in ReadOnlyTensorSpan{T})" />
public static TensorSpan<TScalar> operator +(in TensorSpan<TScalar> tensor) => tensor;
}
}
}

View File

@ -0,0 +1,82 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Numerics.Tensors
{
public static partial class Tensor
{
/// <summary>Performs an element-wise logical right shift on a tensor.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor to logical right shift.</param>
/// <param name="shiftAmount">The amount to shift each element in <paramref name="x" />.</param>
/// <returns>A new tensor containing the result of <paramref name="x" /> &gt;&gt;&gt; <paramref name="shiftAmount" />.</returns>
public static Tensor<T> ShiftRightLogical<T>(in ReadOnlyTensorSpan<T> x, int shiftAmount)
where T : IShiftOperators<T, int, T>
{
Tensor<T> destination = CreateFromShapeUninitialized<T>(x.Lengths);
TensorOperation.Invoke<TensorOperation.ShiftRightLogical<T>, T, int, T>(x, shiftAmount, destination);
return destination;
}
/// <summary>Performs an element-wise logical right shift on a tensor.</summary>
/// <typeparam name="T">The type of the elements in the tensor.</typeparam>
/// <param name="x">The tensor to logical right shift.</param>
/// <param name="shiftAmount">The amount to shift each element in <paramref name="x" />.</param>
/// <param name="destination">The destination where the result of <paramref name="x" /> &gt;&gt;&gt; <paramref name="shiftAmount" /> is written.</param>
/// <returns>A reference to <paramref name="destination" />.</returns>
/// <exception cref="ArgumentException">The shapes of <paramref name="x" /> and <paramref name="destination" /> are not compatible.</exception>
public static ref readonly TensorSpan<T> ShiftRightLogical<T>(scoped in ReadOnlyTensorSpan<T> x, int shiftAmount, in TensorSpan<T> destination)
where T : IShiftOperators<T, int, T>
{
TensorOperation.ValidateCompatibility(x, destination);
TensorOperation.Invoke<TensorOperation.ShiftRightLogical<T>, T, int, T>(x, shiftAmount, destination);
return ref destination;
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
extension<TScalar>(ReadOnlyTensorSpan<TScalar>)
where TScalar : IShiftOperators<TScalar, int, TScalar>
{
/// <summary>Performs an element-wise logical right shift on a tensor.</summary>
/// <param name="tensor">The tensor to logical right shift.</param>
/// <param name="shiftAmount">The amount to shift each element in <paramref name="tensor" />.</param>
/// <returns>A new tensor containing the result of <paramref name="tensor" /> &gt;&gt;&gt; <paramref name="shiftAmount" />.</returns>
public static Tensor<TScalar> operator >>>(in ReadOnlyTensorSpan<TScalar> tensor, int shiftAmount) => ShiftRightLogical(tensor, shiftAmount);
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
extension<TScalar>(Tensor<TScalar>)
where TScalar : IShiftOperators<TScalar, int, TScalar>
{
/// <inheritdoc cref="op_LeftShift{T}(in ReadOnlyTensorSpan{T}, int)" />
public static Tensor<TScalar> operator >>>(Tensor<TScalar> tensor, int shiftAmount) => ShiftRightLogical<TScalar>(tensor, shiftAmount);
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
/// <param name="tensor">The tensor to operate on.</param>
extension<TScalar>(Tensor<TScalar> tensor)
where TScalar : IShiftOperators<TScalar, int, TScalar>
{
/// <inheritdoc cref="op_LeftShiftAssignment{T}(ref TensorSpan{T}, int)" />
public void operator >>>=(int shiftAmount) => ShiftRightLogical<TScalar>(tensor, shiftAmount, tensor);
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
extension<TScalar>(TensorSpan<TScalar>)
where TScalar : IShiftOperators<TScalar, int, TScalar>
{
/// <inheritdoc cref="op_LeftShift{T}(in ReadOnlyTensorSpan{T}, int)" />
public static Tensor<TScalar> operator >>>(in TensorSpan<TScalar> tensor, int shiftAmount) => ShiftRightLogical<TScalar>(tensor, shiftAmount);
}
/// <typeparam name="TScalar">The type of the elements in the tensor.</typeparam>
/// <param name="tensor">The tensor to operate on.</param>
extension<TScalar>(ref TensorSpan<TScalar> tensor)
where TScalar : IShiftOperators<TScalar, int, TScalar>
{
/// <summary>Performs in-place element-wise logical right shift on a tensor.</summary>
/// <param name="shiftAmount">The amount to shift each element in the tensor.</param>
public void operator >>>=(int shiftAmount) => ShiftRightLogical<TScalar>(tensor, shiftAmount, tensor);
}
}
}

View File

@ -949,6 +949,22 @@ namespace System.Numerics.Tensors
}
}
public readonly struct Decrement<T>
: IUnaryOperation_Tensor<T, T>
where T : IDecrementOperators<T>
{
public static void Invoke(ref readonly T x, ref T destination)
{
T tmp = x;
destination = --tmp;
}
public static void Invoke(ReadOnlySpan<T> x, Span<T> destination)
{
TensorPrimitives.Decrement(x, destination);
}
}
public readonly struct DegreesToRadians<T>
: IUnaryOperation_Tensor<T, T>
where T : ITrigonometricFunctions<T>
@ -1186,6 +1202,22 @@ namespace System.Numerics.Tensors
}
}
public readonly struct Increment<T>
: IUnaryOperation_Tensor<T, T>
where T : IIncrementOperators<T>
{
public static void Invoke(ref readonly T x, ref T destination)
{
T tmp = x;
destination = ++tmp;
}
public static void Invoke(ReadOnlySpan<T> x, Span<T> destination)
{
TensorPrimitives.Increment(x, destination);
}
}
public readonly struct LeadingZeroCount<T>
: IUnaryOperation_Tensor<T, T>
where T : IBinaryInteger<T>
@ -1831,6 +1863,51 @@ namespace System.Numerics.Tensors
}
}
public readonly struct ShiftLeft<T>
: IBinaryOperation_Tensor_Scalar<T, int, T>
where T : IShiftOperators<T, int, T>
{
public static void Invoke(ref readonly T x, int shiftAmount, ref T destination)
{
destination = x << shiftAmount;
}
public static void Invoke(ReadOnlySpan<T> x, int shiftAmount, Span<T> destination)
{
TensorPrimitives.ShiftLeft(x, shiftAmount, destination);
}
}
public readonly struct ShiftRightArithmetic<T>
: IBinaryOperation_Tensor_Scalar<T, int, T>
where T : IShiftOperators<T, int, T>
{
public static void Invoke(ref readonly T x, int shiftAmount, ref T destination)
{
destination = x >> shiftAmount;
}
public static void Invoke(ReadOnlySpan<T> x, int shiftAmount, Span<T> destination)
{
TensorPrimitives.ShiftRightArithmetic(x, shiftAmount, destination);
}
}
public readonly struct ShiftRightLogical<T>
: IBinaryOperation_Tensor_Scalar<T, int, T>
where T : IShiftOperators<T, int, T>
{
public static void Invoke(ref readonly T x, int shiftAmount, ref T destination)
{
destination = x >>> shiftAmount;
}
public static void Invoke(ReadOnlySpan<T> x, int shiftAmount, Span<T> destination)
{
TensorPrimitives.ShiftRightLogical(x, shiftAmount, destination);
}
}
public readonly struct Sigmoid<T>
: IUnaryOperation_Tensor<T, T>
where T : IExponentialFunctions<T>

View File

@ -22,36 +22,6 @@ namespace System.Numerics.Tensors
where T : IShiftOperators<T, int, T> =>
InvokeSpanIntoSpan(x, new ShiftLeftOperator<T>(shiftAmount), destination);
/// <summary>Computes the element-wise arithmetic (signed) shifting right of numbers in the specified tensor by the specified shift amount.</summary>
/// <param name="x">The tensor, represented as a span.</param>
/// <param name="destination">The destination tensor, represented as a span.</param>
/// <param name="shiftAmount">The number of bits to shift, represented as a scalar.</param>
/// <exception cref="ArgumentException">Destination is too short.</exception>
/// <exception cref="ArgumentException"><paramref name="x"/> and <paramref name="destination"/> reference overlapping memory locations and do not begin at the same location.</exception>
/// <remarks>
/// <para>
/// This method effectively computes <c><paramref name="destination" />[i] = <paramref name="x" />[i] &gt;&gt; <paramref name="shiftAmount"/></c>.
/// </para>
/// </remarks>
public static void ShiftRightArithmetic<T>(ReadOnlySpan<T> x, int shiftAmount, Span<T> destination)
where T : IShiftOperators<T, int, T> =>
InvokeSpanIntoSpan(x, new ShiftRightArithmeticOperator<T>(shiftAmount), destination);
/// <summary>Computes the element-wise logical (unsigned) shifting right of numbers in the specified tensor by the specified shift amount.</summary>
/// <param name="x">The tensor, represented as a span.</param>
/// <param name="destination">The destination tensor, represented as a span.</param>
/// <param name="shiftAmount">The number of bits to shift, represented as a scalar.</param>
/// <exception cref="ArgumentException">Destination is too short.</exception>
/// <exception cref="ArgumentException"><paramref name="x"/> and <paramref name="destination"/> reference overlapping memory locations and do not begin at the same location.</exception>
/// <remarks>
/// <para>
/// This method effectively computes <c><paramref name="destination" />[i] = <paramref name="x" />[i] &gt;&gt;&gt; <paramref name="shiftAmount"/></c>.
/// </para>
/// </remarks>
public static void ShiftRightLogical<T>(ReadOnlySpan<T> x, int shiftAmount, Span<T> destination)
where T : IShiftOperators<T, int, T> =>
InvokeSpanIntoSpan(x, new ShiftRightLogicalOperator<T>(shiftAmount), destination);
/// <summary>T &lt;&lt; amount</summary>
private readonly struct ShiftLeftOperator<T>(int amount) : IStatefulUnaryOperator<T> where T : IShiftOperators<T, int, T>
{
@ -64,31 +34,5 @@ namespace System.Numerics.Tensors
public Vector256<T> Invoke(Vector256<T> x) => x << _amount;
public Vector512<T> Invoke(Vector512<T> x) => x << _amount;
}
/// <summary>T &gt;&gt; amount</summary>
private readonly struct ShiftRightArithmeticOperator<T>(int amount) : IStatefulUnaryOperator<T> where T : IShiftOperators<T, int, T>
{
private readonly int _amount = amount;
public static bool Vectorizable => true;
public T Invoke(T x) => x >> _amount;
public Vector128<T> Invoke(Vector128<T> x) => x >> _amount;
public Vector256<T> Invoke(Vector256<T> x) => x >> _amount;
public Vector512<T> Invoke(Vector512<T> x) => x >> _amount;
}
/// <summary>T &gt;&gt;&gt; amount</summary>
private readonly struct ShiftRightLogicalOperator<T>(int amount) : IStatefulUnaryOperator<T> where T : IShiftOperators<T, int, T>
{
private readonly int _amount = amount;
public static bool Vectorizable => true;
public T Invoke(T x) => x >>> _amount;
public Vector128<T> Invoke(Vector128<T> x) => x >>> _amount;
public Vector256<T> Invoke(Vector256<T> x) => x >>> _amount;
public Vector512<T> Invoke(Vector512<T> x) => x >>> _amount;
}
}
}

View File

@ -0,0 +1,38 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Runtime.Intrinsics;
namespace System.Numerics.Tensors
{
public static partial class TensorPrimitives
{
/// <summary>Computes the element-wise arithmetic (signed) shifting right of numbers in the specified tensor by the specified shift amount.</summary>
/// <param name="x">The tensor, represented as a span.</param>
/// <param name="destination">The destination tensor, represented as a span.</param>
/// <param name="shiftAmount">The number of bits to shift, represented as a scalar.</param>
/// <exception cref="ArgumentException">Destination is too short.</exception>
/// <exception cref="ArgumentException"><paramref name="x"/> and <paramref name="destination"/> reference overlapping memory locations and do not begin at the same location.</exception>
/// <remarks>
/// <para>
/// This method effectively computes <c><paramref name="destination" />[i] = <paramref name="x" />[i] &gt;&gt; <paramref name="shiftAmount"/></c>.
/// </para>
/// </remarks>
public static void ShiftRightArithmetic<T>(ReadOnlySpan<T> x, int shiftAmount, Span<T> destination)
where T : IShiftOperators<T, int, T> =>
InvokeSpanIntoSpan(x, new ShiftRightArithmeticOperator<T>(shiftAmount), destination);
/// <summary>T &gt;&gt; amount</summary>
private readonly struct ShiftRightArithmeticOperator<T>(int amount) : IStatefulUnaryOperator<T> where T : IShiftOperators<T, int, T>
{
private readonly int _amount = amount;
public static bool Vectorizable => true;
public T Invoke(T x) => x >> _amount;
public Vector128<T> Invoke(Vector128<T> x) => x >> _amount;
public Vector256<T> Invoke(Vector256<T> x) => x >> _amount;
public Vector512<T> Invoke(Vector512<T> x) => x >> _amount;
}
}
}

View File

@ -0,0 +1,38 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Runtime.Intrinsics;
namespace System.Numerics.Tensors
{
public static partial class TensorPrimitives
{
/// <summary>Computes the element-wise logical (unsigned) shifting right of numbers in the specified tensor by the specified shift amount.</summary>
/// <param name="x">The tensor, represented as a span.</param>
/// <param name="destination">The destination tensor, represented as a span.</param>
/// <param name="shiftAmount">The number of bits to shift, represented as a scalar.</param>
/// <exception cref="ArgumentException">Destination is too short.</exception>
/// <exception cref="ArgumentException"><paramref name="x"/> and <paramref name="destination"/> reference overlapping memory locations and do not begin at the same location.</exception>
/// <remarks>
/// <para>
/// This method effectively computes <c><paramref name="destination" />[i] = <paramref name="x" />[i] &gt;&gt;&gt; <paramref name="shiftAmount"/></c>.
/// </para>
/// </remarks>
public static void ShiftRightLogical<T>(ReadOnlySpan<T> x, int shiftAmount, Span<T> destination)
where T : IShiftOperators<T, int, T> =>
InvokeSpanIntoSpan(x, new ShiftRightLogicalOperator<T>(shiftAmount), destination);
/// <summary>T &gt;&gt;&gt; amount</summary>
private readonly struct ShiftRightLogicalOperator<T>(int amount) : IStatefulUnaryOperator<T> where T : IShiftOperators<T, int, T>
{
private readonly int _amount = amount;
public static bool Vectorizable => true;
public T Invoke(T x) => x >>> _amount;
public Vector128<T> Invoke(Vector128<T> x) => x >>> _amount;
public Vector256<T> Invoke(Vector256<T> x) => x >>> _amount;
public Vector512<T> Invoke(Vector512<T> x) => x >>> _amount;
}
}
}

View File

@ -134,8 +134,18 @@ namespace ILLink.RoslynAnalyzer.TrimAnalysis
public override MultiValue VisitParameterReference(IParameterReferenceOperation paramRef, StateValue state)
{
IParameterSymbol parameter = paramRef.Parameter;
if (parameter.ContainingSymbol is not IMethodSymbol)
{
// TODO: Extension members allows parameters to be on types, rather than methods.
// For example: `extension<T>(ref T value) { }` will enumerate `value` where
// the containing symbol is a `NonErrorNamedTypeSymbol`
return TopValue;
}
// Reading from a parameter always returns the same annotated value. We don't track modifications.
return GetParameterTargetValue(paramRef.Parameter);
return GetParameterTargetValue(parameter);
}
public override MultiValue VisitInstanceReference(IInstanceReferenceOperation instanceRef, StateValue state)