|
// 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 TensorPrimitives
{
/// <summary>
/// Copies <paramref name="source"/> to <paramref name="destination"/>, converting each <see cref="float" />
/// value to its nearest representable half-precision floating-point value.
/// </summary>
/// <param name="source">The source span from which to copy values.</param>
/// <param name="destination">The destination span into which the converted values should be written.</param>
/// <exception cref="ArgumentException">Destination is too short.</exception>
/// <remarks>
/// <para>
/// This method effectively computes <c><paramref name="destination" />[i] = (Half)<paramref name="source" />[i]</c>.
/// </para>
/// <para>
/// <paramref name="source"/> and <paramref name="destination"/> must not overlap. If they do, behavior is undefined.
/// </para>
/// </remarks>
public static void ConvertToHalf(ReadOnlySpan<float> source, Span<Half> destination) =>
ConvertTruncating(source, destination);
/// <summary>
/// Copies <paramref name="source"/> to <paramref name="destination"/>, converting each half-precision
/// floating-point value to its nearest representable <see cref="float"/> value.
/// </summary>
/// <param name="source">The source span from which to copy values.</param>
/// <param name="destination">The destination span into which the converted values should be written.</param>
/// <exception cref="ArgumentException">Destination is too short.</exception>
/// <remarks>
/// <para>
/// This method effectively computes <c><paramref name="destination" />[i] = (float)<paramref name="source" />[i]</c>.
/// </para>
/// <para>
/// <paramref name="source"/> and <paramref name="destination"/> must not overlap. If they do, behavior is undefined.
/// </para>
/// </remarks>
public static void ConvertToSingle(ReadOnlySpan<Half> source, Span<float> destination) =>
ConvertTruncating(source, destination);
}
}
|