Table of Contents

Struct ScalarLane<TNumber>

Namespace
Misaki.HighPerformance.Mathematics.SPMD
Assembly
Misaki.HighPerformance.Mathematics.SPMD.dll
public readonly struct ScalarLane<TNumber> : ISPMDLane<ScalarLane<TNumber>, TNumber>, ISPMDLane, IEquatable<ScalarLane<TNumber>> where TNumber : unmanaged, INumber<TNumber>, IBinaryNumber<TNumber>, IMinMaxValue<TNumber>, IBitwiseOperators<TNumber, TNumber, TNumber>

Type Parameters

TNumber
Implements
ISPMDLane<ScalarLane<TNumber>, TNumber>
Inherited Members

Constructors

ScalarLane(TNumber)

public ScalarLane(TNumber value)

Parameters

value TNumber

Fields

value

public readonly TNumber value

Field Value

TNumber

Properties

AllBitsSet

Gets a lane value where all bits are set to 1 for each lane.

public static ScalarLane<TNumber> AllBitsSet { get; }

Property Value

ScalarLane<TNumber>

this[int]

Gets the element value for the specified lane index.

public TNumber this[int index] { get; }

Parameters

index int

The zero-based lane index.

Property Value

TNumber

LaneWidth

Gets the number of lanes (vector width) for the SPMD implementation.

public static int LaneWidth { get; }

Property Value

int

MaxValue

Gets a lane value where all lanes are set to the maximum representable value of the underlying numeric type.

public static ScalarLane<TNumber> MaxValue { get; }

Property Value

ScalarLane<TNumber>

MinValue

Gets a lane value where all lanes are set to the minimum representable value of the underlying numeric type.

public static ScalarLane<TNumber> MinValue { get; }

Property Value

ScalarLane<TNumber>

One

Gets a lane value where all lanes are set to numeric one.

public static ScalarLane<TNumber> One { get; }

Property Value

ScalarLane<TNumber>

Zero

Gets a lane value where all lanes are set to numeric zero.

public static ScalarLane<TNumber> Zero { get; }

Property Value

ScalarLane<TNumber>

Methods

Abs(ScalarLane<TNumber>)

Computes the absolute value of the lane value element-wise.

public static ScalarLane<TNumber> Abs(ScalarLane<TNumber> value)

Parameters

value ScalarLane<TNumber>

Returns

ScalarLane<TNumber>

The absolute lane value.

Acos(ScalarLane<TNumber>)

Computes the arccosine of each lane element.

public static ScalarLane<TNumber> Acos(ScalarLane<TNumber> value)

Parameters

value ScalarLane<TNumber>

The source lane value.

Returns

ScalarLane<TNumber>

The arccosine of each lane element.

Remarks

Input is expected to be in [-1, 1]; implementations often rely on approximation polynomials combined with range reduction.

All(ScalarLane<TNumber>)

Checks if all lanes in the mask are true.

public static bool All(ScalarLane<TNumber> mask)

Parameters

mask ScalarLane<TNumber>

The mask to check.

Returns

bool

True if all lanes are true; otherwise, false.

Any(ScalarLane<TNumber>)

Checks if any lane in the mask is true.

public static bool Any(ScalarLane<TNumber> mask)

Parameters

mask ScalarLane<TNumber>

The mask to check.

Returns

bool

True if any lane is true; otherwise, false.

AsVector()

Converts the lane value to a vector.

public Vector<TNumber> AsVector()

Returns

Vector<TNumber>

The backing vector representation.

Asin(ScalarLane<TNumber>)

Computes the arcsine of each lane element.

public static ScalarLane<TNumber> Asin(ScalarLane<TNumber> value)

Parameters

value ScalarLane<TNumber>

The source lane value.

Returns

ScalarLane<TNumber>

The arcsine of each lane element.

Remarks

Implementations typically assume input is within [-1, 1] and may use polynomial approximations for performance.

Atan(ScalarLane<TNumber>)

Computes the arctangent of each lane element.

public static ScalarLane<TNumber> Atan(ScalarLane<TNumber> value)

Parameters

value ScalarLane<TNumber>

The source lane value.

Returns

ScalarLane<TNumber>

The arctangent of each lane element.

Remarks

Polynomial approximations with restricted input ranges are commonly used for performance-sensitive implementations.

Atan2(ScalarLane<TNumber>, ScalarLane<TNumber>)

Computes the arctangent of y/x for each lane element.

public static ScalarLane<TNumber> Atan2(ScalarLane<TNumber> y, ScalarLane<TNumber> x)

Parameters

y ScalarLane<TNumber>

The numerator lane value.

x ScalarLane<TNumber>

The denominator lane value.

Returns

ScalarLane<TNumber>

The arctangent of each lane pair.

Remarks

Implementations often rely on quadrant-aware polynomial routines and assume inputs are finite to avoid NaNs.

BitCast<TOther, TOtherNumber>()

Bitwise reinterprets the lane value as another SPMD lane type with a different underlying numeric type.

public TOther BitCast<TOther, TOtherNumber>() where TOther : ISPMDLane<TOther, TOtherNumber> where TOtherNumber : unmanaged, INumber<TOtherNumber>, IBinaryNumber<TOtherNumber>, IMinMaxValue<TOtherNumber>, IBitwiseOperators<TOtherNumber, TOtherNumber, TOtherNumber>

Returns

TOther

The bit-cast lane value.

Type Parameters

TOther

The type of the other SPMD lane.

TOtherNumber

The underlying numeric type of the other SPMD lane.

Cast<TOther, TOtherNumber>()

Casts the lane value to another SPMD lane type with a different underlying numeric type.

public TOther Cast<TOther, TOtherNumber>() where TOther : ISPMDLane<TOther, TOtherNumber> where TOtherNumber : unmanaged, INumber<TOtherNumber>, IBinaryNumber<TOtherNumber>, IMinMaxValue<TOtherNumber>, IBitwiseOperators<TOtherNumber, TOtherNumber, TOtherNumber>

Returns

TOther

The casted lane value.

Type Parameters

TOther

The type of the other SPMD lane.

TOtherNumber

The underlying numeric type of the other SPMD lane.

Ceil(ScalarLane<TNumber>)

Computes the ceiling of each lane element.

public static ScalarLane<TNumber> Ceil(ScalarLane<TNumber> value)

Parameters

value ScalarLane<TNumber>

Returns

ScalarLane<TNumber>

The smallest integral value greater than or equal to each element.

Remarks

Implementations should use Vector helpers for floating-point types when available.

Clamp(ScalarLane<TNumber>, ScalarLane<TNumber>, ScalarLane<TNumber>)

Clamps each element of the lane value between the specified minimum and maximum values.

public static ScalarLane<TNumber> Clamp(ScalarLane<TNumber> value, ScalarLane<TNumber> min, ScalarLane<TNumber> max)

Parameters

value ScalarLane<TNumber>

The lane value to clamp.

min ScalarLane<TNumber>

The inclusive minimum.

max ScalarLane<TNumber>

The inclusive maximum.

Returns

ScalarLane<TNumber>

The clamped lane value.

CompressStore(TNumber*, ScalarLane<TNumber>)

Compresses the data specified by the given mask and stores the compressed result in the provided destination variable.

public int CompressStore(TNumber* pDestination, ScalarLane<TNumber> mask)

Parameters

pDestination TNumber*

A pointer to the variable where the compressed data will be stored.

mask ScalarLane<TNumber>

A mask value that determines which elements are included in the compression operation.

Returns

int

The number of elements written to the destination as a result of the compression. Returns 0 if no elements are compressed.

Remarks

Implementations may use hardware-specific shuffle tables to reorder the selected lanes before storing, falling back to a scalar loop otherwise.

CompressStore(ref TNumber, ScalarLane<TNumber>)

Compresses the data specified by the given mask and stores the compressed result in the provided destination variable.

public int CompressStore(ref TNumber destination, ScalarLane<TNumber> mask)

Parameters

destination TNumber

A reference to the variable where the compressed data will be stored.

mask ScalarLane<TNumber>

A mask value that determines which elements are included in the compression operation.

Returns

int

The number of elements written to the destination as a result of the compression. Returns 0 if no elements are compressed.

Remarks

Implementations may use hardware-specific shuffle tables to reorder the selected lanes before storing, falling back to a scalar loop otherwise.

CopySign(ScalarLane<TNumber>, ScalarLane<TNumber>)

Copies the sign of the second lane value to the magnitude of the first.

public static ScalarLane<TNumber> CopySign(ScalarLane<TNumber> magnitude, ScalarLane<TNumber> sign)

Parameters

magnitude ScalarLane<TNumber>

The magnitude lane value.

sign ScalarLane<TNumber>

The sign lane value.

Returns

ScalarLane<TNumber>

The result of merging magnitude with sign.

Cos(ScalarLane<TNumber>)

Computes the cosine of each lane element.

public static ScalarLane<TNumber> Cos(ScalarLane<TNumber> value)

Parameters

value ScalarLane<TNumber>

The source lane value.

Returns

ScalarLane<TNumber>

The cosine of each lane element.

Remarks

Implementations may rely on vectorized math intrinsics for float/double and approximate values for other types.

Create(Vector<TNumber>)

Creates a lane value from the specified vector.

public static ScalarLane<TNumber> Create(Vector<TNumber> value)

Parameters

value Vector<TNumber>

The vector to create the lane value from.

Returns

ScalarLane<TNumber>

The lane value built from the vector.

Create(params ReadOnlySpan<TNumber>)

Creates a new instance of the type from the specified sequence of numeric values.

public static ScalarLane<TNumber> Create(params ReadOnlySpan<TNumber> values)

Parameters

values ReadOnlySpan<TNumber>

A parameter array of read-only spans containing the numeric values to use for initialization.

Returns

ScalarLane<TNumber>

A new instance of the type initialized with the provided numeric values.

Create(TNumber)

Creates a lane value where all lanes are set to the specified value.

public static ScalarLane<TNumber> Create(TNumber value)

Parameters

value TNumber

The value to set for all lanes.

Returns

ScalarLane<TNumber>

The created lane value.

Equal(ScalarLane<TNumber>, ScalarLane<TNumber>)

Compares two lane values for equality element-wise.

public static ScalarLane<TNumber> Equal(ScalarLane<TNumber> a, ScalarLane<TNumber> b)

Parameters

a ScalarLane<TNumber>

The first lane value.

b ScalarLane<TNumber>

The second lane value.

Returns

ScalarLane<TNumber>

The mask representing the equality comparison result.

Equals(ScalarLane<TNumber>)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(ScalarLane<TNumber> other)

Parameters

other ScalarLane<TNumber>

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

Exp(ScalarLane<TNumber>)

Computes the exponential of each lane element.

public static ScalarLane<TNumber> Exp(ScalarLane<TNumber> value)

Parameters

value ScalarLane<TNumber>

The source lane value.

Returns

ScalarLane<TNumber>

The exponential of each lane element.

Remarks

Float and double implementations typically call into vectorized exp intrinsics; other types may fall back to scalar paths.

Exp2(ScalarLane<TNumber>)

Computes 2 raised to each lane element.

public static ScalarLane<TNumber> Exp2(ScalarLane<TNumber> value)

Parameters

value ScalarLane<TNumber>

The source lane value.

Returns

ScalarLane<TNumber>

The base-2 exponential of each lane element.

Remarks

This can be implemented via Exp(TSelf) when no dedicated base-2 intrinsic exists.

Floor(ScalarLane<TNumber>)

Computes the floor of the lane value element-wise.

public static ScalarLane<TNumber> Floor(ScalarLane<TNumber> value)

Parameters

value ScalarLane<TNumber>

Returns

ScalarLane<TNumber>

The lane value with each element rounded toward negative infinity.

Frac(ScalarLane<TNumber>)

Computes the fractional part of the lane value element-wise.

public static ScalarLane<TNumber> Frac(ScalarLane<TNumber> value)

Parameters

value ScalarLane<TNumber>

Returns

ScalarLane<TNumber>

The fractional lane value.

Gather(TNumber*, ScalarLane<TNumber>, byte)

Gathers lane values from the specified base address and indices, returning a lane value where each lane is loaded from the address computed by adding the corresponding index (multiplied by the scale) to the base address.

public static ScalarLane<TNumber> Gather(TNumber* pData, ScalarLane<TNumber> indices, byte scale)

Parameters

pData TNumber*

The base address from which to gather values.

indices ScalarLane<TNumber>

The indices of the values to gather.

scale byte

The scale factor for the indices.

Returns

ScalarLane<TNumber>

The gathered lane value.

Gather(TNumber*, int*, byte)

Gathers lane values from the specified base address and indices, returning a lane value where each lane is loaded from the address computed by adding the corresponding index (multiplied by the scale) to the base address.

public static ScalarLane<TNumber> Gather(TNumber* pData, int* pIndices, byte scale)

Parameters

pData TNumber*

The base address from which to gather values.

pIndices int*

The pointer to the indices of the values to gather.

scale byte

The scale factor for the indices.

Returns

ScalarLane<TNumber>

The gathered lane value.

Gather(ref TNumber, ScalarLane<TNumber>, byte)

Gathers lane values from the specified base address and indices, returning a lane value where each lane is loaded from the address computed by adding the corresponding index (multiplied by the scale) to the base address.

public static ScalarLane<TNumber> Gather(ref TNumber baseAddress, ScalarLane<TNumber> indices, byte scale)

Parameters

baseAddress TNumber

The base address from which to gather values.

indices ScalarLane<TNumber>

The indices of the values to gather.

scale byte

The scale factor for the indices.

Returns

ScalarLane<TNumber>

The gathered lane value.

Gather(ref TNumber, ref int, byte)

Gathers lane values from the specified base address and indices, returning a lane value where each lane is loaded from the address computed by adding the corresponding index (multiplied by the scale) to the base address.

public static ScalarLane<TNumber> Gather(ref TNumber baseAddress, ref int baseIndex, byte scale)

Parameters

baseAddress TNumber

The base address from which to gather values.

baseIndex int

The reference to the base index.

scale byte

The scale factor for the indices.

Returns

ScalarLane<TNumber>

The gathered lane value.

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

GetUnsafePtr()

Gets an pointer to the lane's underlying data.

public TNumber* GetUnsafePtr()

Returns

TNumber*

An pointer to the lane's underlying data.

GreaterThan(ScalarLane<TNumber>, ScalarLane<TNumber>)

Compares two lane values for greater than element-wise.

public static ScalarLane<TNumber> GreaterThan(ScalarLane<TNumber> a, ScalarLane<TNumber> b)

Parameters

a ScalarLane<TNumber>

The first lane value.

b ScalarLane<TNumber>

The second lane value.

Returns

ScalarLane<TNumber>

The mask representing the greater than comparison result.

GreaterThanOrEqual(ScalarLane<TNumber>, ScalarLane<TNumber>)

Compares two lane values for greater than or equal element-wise.

public static ScalarLane<TNumber> GreaterThanOrEqual(ScalarLane<TNumber> a, ScalarLane<TNumber> b)

Parameters

a ScalarLane<TNumber>

The first lane value.

b ScalarLane<TNumber>

The second lane value.

Returns

ScalarLane<TNumber>

The mask representing the greater than or equal comparison result.

Lerp(ScalarLane<TNumber>, ScalarLane<TNumber>, ScalarLane<TNumber>)

Performs linear interpolation between two lane values.

public static ScalarLane<TNumber> Lerp(ScalarLane<TNumber> a, ScalarLane<TNumber> b, ScalarLane<TNumber> t)

Parameters

a ScalarLane<TNumber>

The start lane value.

b ScalarLane<TNumber>

The end lane value.

t ScalarLane<TNumber>

The interpolation factor.

Returns

ScalarLane<TNumber>

The interpolated lane value.

LessThan(ScalarLane<TNumber>, ScalarLane<TNumber>)

Compares two lane values for less than element-wise.

public static ScalarLane<TNumber> LessThan(ScalarLane<TNumber> a, ScalarLane<TNumber> b)

Parameters

a ScalarLane<TNumber>

The first lane value.

b ScalarLane<TNumber>

The second lane value.

Returns

ScalarLane<TNumber>

The mask representing the less than comparison result.

LessThanOrEqual(ScalarLane<TNumber>, ScalarLane<TNumber>)

Compares two lane values for less than or equal element-wise.

public static ScalarLane<TNumber> LessThanOrEqual(ScalarLane<TNumber> a, ScalarLane<TNumber> b)

Parameters

a ScalarLane<TNumber>

The first lane value.

b ScalarLane<TNumber>

The second lane value.

Returns

ScalarLane<TNumber>

The mask representing the less than or equal comparison result.

Load(TNumber*)

Loads a lane value from the specified pointer.

public static ScalarLane<TNumber> Load(TNumber* pValue)

Parameters

pValue TNumber*

The pointer to load from.

Returns

ScalarLane<TNumber>

The loaded lane value.

Remarks

Unsafe pointer overloads are provided for scenarios where sequential lane data is already contiguous in memory.

Load(ref TNumber)

Loads a lane value from the specified reference.

public static ScalarLane<TNumber> Load(ref TNumber value)

Parameters

value TNumber

The reference to load from.

Returns

ScalarLane<TNumber>

The loaded lane value.

Log(ScalarLane<TNumber>)

Computes the natural logarithm of each lane element.

public static ScalarLane<TNumber> Log(ScalarLane<TNumber> value)

Parameters

value ScalarLane<TNumber>

The source lane value.

Returns

ScalarLane<TNumber>

The natural logarithm of each lane element.

Remarks

Vectorized logarithm instructions may only exist for floating-point types; other types should mimic the scalar behavior.

Log2(ScalarLane<TNumber>)

Computes the base-2 logarithm of each lane element.

public static ScalarLane<TNumber> Log2(ScalarLane<TNumber> value)

Parameters

value ScalarLane<TNumber>

The source lane value.

Returns

ScalarLane<TNumber>

The base-2 logarithm of each lane element.

Remarks

If a dedicated base-2 intrinsic is unavailable, the implementation may compute Log(value)/Log(2).

MaskGather(TNumber*, ScalarLane<TNumber>, ScalarLane<TNumber>, byte)

Gathers lane values from the specified base address and indices, returning a lane value where each lane is loaded from the address computed by adding the corresponding index (multiplied by the scale) to the base address, but only for lanes where the corresponding mask bit is set; other lanes are set to zero.

public static ScalarLane<TNumber> MaskGather(TNumber* pData, ScalarLane<TNumber> indices, ScalarLane<TNumber> mask, byte scale)

Parameters

pData TNumber*

The base address from which to gather values.

indices ScalarLane<TNumber>

The indices of the values to gather.

mask ScalarLane<TNumber>

The mask value that determines which elements are included in the gathering operation.

scale byte

The scale factor for the indices.

Returns

ScalarLane<TNumber>

The gathered lane value.

MaskGather(TNumber*, int*, ScalarLane<TNumber>, byte)

Gathers lane values from the specified base address and indices, returning a lane value where each lane is loaded from the address computed by adding the corresponding index (multiplied by the scale) to the base address, but only for lanes where the corresponding mask bit is set; other lanes are set to zero.

public static ScalarLane<TNumber> MaskGather(TNumber* pData, int* pIndices, ScalarLane<TNumber> mask, byte scale)

Parameters

pData TNumber*

The base address from which to gather values.

pIndices int*

The pointer to the indices of the values to gather.

mask ScalarLane<TNumber>

The mask value that determines which elements are included in the gathering operation.

scale byte

The scale factor for the indices.

Returns

ScalarLane<TNumber>

The gathered lane value.

MaskLoad(TNumber*, ScalarLane<TNumber>)

Uses the specified mask to conditionally load lane values from the given pointer, returning a lane value where masked lanes are loaded and unmasked lanes are set to zero.

public static ScalarLane<TNumber> MaskLoad(TNumber* pValue, ScalarLane<TNumber> mask)

Parameters

pValue TNumber*

The pointer to load from.

mask ScalarLane<TNumber>

The mask to use for conditional loading.

Returns

ScalarLane<TNumber>

The loaded lane value.

MaskLoad(ref TNumber, ScalarLane<TNumber>)

Uses the specified mask to conditionally load lane values from the given reference, returning a lane value where masked lanes are loaded and unmasked lanes are set to zero.

public static ScalarLane<TNumber> MaskLoad(ref TNumber value, ScalarLane<TNumber> mask)

Parameters

value TNumber

The reference to load from.

mask ScalarLane<TNumber>

The mask to use for conditional loading.

Returns

ScalarLane<TNumber>

The loaded lane value.

MaskScatter(TNumber*, ScalarLane<TNumber>, ScalarLane<TNumber>)

Masks the lane value with the specified mask and scatters the result to the given base address and indices, where masked lanes are stored to the address computed by adding the corresponding index (multiplied by the scale) to the base address, and unmasked lanes are left unchanged in the destination.

public void MaskScatter(TNumber* pDst, ScalarLane<TNumber> indices, ScalarLane<TNumber> mask)

Parameters

pDst TNumber*

A pointer to the base address where the data will be scattered.

indices ScalarLane<TNumber>

A vector of indices that determine the destinations of each lane.

mask ScalarLane<TNumber>

A vector of boolean values that determine which lanes to scatter.

MaskScatter(TNumber*, int*, ScalarLane<TNumber>)

Masks the lane value with the specified mask and scatters the result to the given base address and indices, where masked lanes are stored to the address computed by adding the corresponding index (multiplied by the scale) to the base address, and unmasked lanes are left unchanged in the destination.

public void MaskScatter(TNumber* pDst, int* pIndices, ScalarLane<TNumber> mask)

Parameters

pDst TNumber*

A pointer to the base address where the data will be scattered.

pIndices int*

A pointer to the array of indices that determine the destinations of each lane.

mask ScalarLane<TNumber>

A vector of boolean values that determine which lanes to scatter.

MaskScatter(ref TNumber, ScalarLane<TNumber>, ScalarLane<TNumber>)

Masks the lane value with the specified mask and scatters the result to the given base address and indices, where masked lanes are stored to the address computed by adding the corresponding index (multiplied by the scale) to the base address, and unmasked lanes are left unchanged in the destination.

public void MaskScatter(ref TNumber destination, ScalarLane<TNumber> indices, ScalarLane<TNumber> mask)

Parameters

destination TNumber

A reference to the variable where the scattered data will be stored.

indices ScalarLane<TNumber>

A vector of indices that determine the destinations of each lane.

mask ScalarLane<TNumber>

A vector of boolean values that determine which lanes to scatter.

MaskScatter(ref TNumber, int*, ScalarLane<TNumber>)

Masks the lane value with the specified mask and scatters the result to the given base address and indices, where masked lanes are stored to the address computed by adding the corresponding index (multiplied by the scale) to the base address, and unmasked lanes are left unchanged in the destination.

public void MaskScatter(ref TNumber destination, int* pIndices, ScalarLane<TNumber> mask)

Parameters

destination TNumber

A reference to the variable where the scattered data will be stored.

pIndices int*

A pointer to the array of indices that determine the destinations of each lane.

mask ScalarLane<TNumber>

A vector of boolean values that determine which lanes to scatter.

MaskStore(TNumber*, ScalarLane<TNumber>)

Masks the lane value with the specified mask and stores the result to the given reference, where masked lanes are stored and unmasked lanes are left unchanged in the destination.

public void MaskStore(TNumber* pDestination, ScalarLane<TNumber> mask)

Parameters

pDestination TNumber*

A pointer to the variable where the masked data will be stored.

mask ScalarLane<TNumber>

A mask value that determines which elements are included in the masking operation.

MaskStore(ref TNumber, ScalarLane<TNumber>)

Masks the lane value with the specified mask and stores the result to the given reference, where masked lanes are stored and unmasked lanes are left unchanged in the destination.

public void MaskStore(ref TNumber destination, ScalarLane<TNumber> mask)

Parameters

destination TNumber

A reference to the variable where the masked data will be stored.

mask ScalarLane<TNumber>

A mask value that determines which elements are included in the masking operation.

Max(ScalarLane<TNumber>, ScalarLane<TNumber>)

Returns the maximum of the two lane values element-wise.

public static ScalarLane<TNumber> Max(ScalarLane<TNumber> a, ScalarLane<TNumber> b)

Parameters

a ScalarLane<TNumber>

The first lane value.

b ScalarLane<TNumber>

The second lane value.

Returns

ScalarLane<TNumber>

The lane value containing the maximum of each element.

Min(ScalarLane<TNumber>, ScalarLane<TNumber>)

Returns the minimum of the two lane values element-wise.

public static ScalarLane<TNumber> Min(ScalarLane<TNumber> a, ScalarLane<TNumber> b)

Parameters

a ScalarLane<TNumber>

The first lane value.

b ScalarLane<TNumber>

The second lane value.

Returns

ScalarLane<TNumber>

The lane value containing the minimum of each element.

MultiplyAdd(ScalarLane<TNumber>, ScalarLane<TNumber>, ScalarLane<TNumber>)

Computes a * b + c element-wise.

public static ScalarLane<TNumber> MultiplyAdd(ScalarLane<TNumber> a, ScalarLane<TNumber> b, ScalarLane<TNumber> c)

Parameters

a ScalarLane<TNumber>

The first multiplier.

b ScalarLane<TNumber>

The second multiplier.

c ScalarLane<TNumber>

The addend.

Returns

ScalarLane<TNumber>

The result of the fused multiply-add operation.

Remarks

Float and double implementations should use fused multiply-add instructions when available for both accuracy and performance.

None(ScalarLane<TNumber>)

Checks if no lanes in the mask are true.

public static bool None(ScalarLane<TNumber> mask)

Parameters

mask ScalarLane<TNumber>

The mask to check.

Returns

bool

True if no lanes are true; otherwise, false.

Pow(ScalarLane<TNumber>, ScalarLane<TNumber>)

Raises each lane element to the specified power.

public static ScalarLane<TNumber> Pow(ScalarLane<TNumber> x, ScalarLane<TNumber> y)

Parameters

x ScalarLane<TNumber>

The base lane value.

y ScalarLane<TNumber>

The exponent lane value. Cannot be negative.

Returns

ScalarLane<TNumber>

The power result for each lane.

Rcp(ScalarLane<TNumber>)

Computes the reciprocal of each lane element.

public static ScalarLane<TNumber> Rcp(ScalarLane<TNumber> value)

Parameters

value ScalarLane<TNumber>

Returns

ScalarLane<TNumber>

The reciprocal lane value.

Remarks

Fast paths may use Sse.Reciprocal or Avx.Reciprocal when TNumber is float.

ReduceAdd(ScalarLane<TNumber>)

Reduces the lane value to a single scalar by adding all lanes together.

public static TNumber ReduceAdd(ScalarLane<TNumber> value)

Parameters

value ScalarLane<TNumber>

The lane value to reduce.

Returns

TNumber

The reduced scalar value.

ReduceMax(ScalarLane<TNumber>)

Reduces the lane value to a single scalar by finding the maximum element.

public static TNumber ReduceMax(ScalarLane<TNumber> value)

Parameters

value ScalarLane<TNumber>

The lane value to reduce.

Returns

TNumber

The reduced scalar value.

ReduceMin(ScalarLane<TNumber>)

Reduces the lane value to a single scalar by finding the minimum element.

public static TNumber ReduceMin(ScalarLane<TNumber> value)

Parameters

value ScalarLane<TNumber>

The lane value to reduce.

Returns

TNumber

The reduced scalar value.

Round(ScalarLane<TNumber>)

Rounds each lane element to the nearest integer value.

public static ScalarLane<TNumber> Round(ScalarLane<TNumber> value)

Parameters

value ScalarLane<TNumber>

Returns

ScalarLane<TNumber>

The rounded lane value.

Remarks

Implementations should prefer vectorized round intrinsics for floating-point implementations.

Rsqrt(ScalarLane<TNumber>)

Computes the reciprocal square root of each lane element.

public static ScalarLane<TNumber> Rsqrt(ScalarLane<TNumber> value)

Parameters

value ScalarLane<TNumber>

Returns

ScalarLane<TNumber>

The reciprocal square root lane value.

Remarks

Float implementations may prefer hardware reciprocal-sqrt intrinsics and fallback to Create(TNumber.One)/Sqrt(x) otherwise.

Saturate(ScalarLane<TNumber>)

Saturates each element in the lane value to the 0..1 range.

public static ScalarLane<TNumber> Saturate(ScalarLane<TNumber> value)

Parameters

value ScalarLane<TNumber>

The lane value to saturate.

Returns

ScalarLane<TNumber>

The saturated lane value.

Scatter(TNumber*, ScalarLane<TNumber>)

Scatters the lane value to the specified base address and indices, where each lane is stored to the address computed by adding the corresponding index (multiplied by the scale) to the base address.

public void Scatter(TNumber* pDst, ScalarLane<TNumber> indices)

Parameters

pDst TNumber*

A pointer to the base address where the data will be scattered.

indices ScalarLane<TNumber>

A vector of indices that determine the destinations of each lane.

Scatter(TNumber*, int*)

Scatters the lane value to the specified base address and indices, where each lane is stored to the address computed by adding the corresponding index (multiplied by the scale) to the base address.

public void Scatter(TNumber* pDst, int* pIndices)

Parameters

pDst TNumber*

A pointer to the base address where the data will be scattered.

pIndices int*

A pointer to the array of indices that determine the destinations of each lane.

Scatter(ref TNumber, ScalarLane<TNumber>)

Scatters the lane value to the specified base address and indices, where each lane is stored to the address computed by adding the corresponding index (multiplied by the scale) to the base address.

public void Scatter(ref TNumber destination, ScalarLane<TNumber> indices)

Parameters

destination TNumber

A reference to the variable where the scattered data will be stored.

indices ScalarLane<TNumber>

A vector of indices that determine the destinations of each lane.

Scatter(ref TNumber, int*)

Scatters the lane value to the specified base address and indices, where each lane is stored to the address computed by adding the corresponding index (multiplied by the scale) to the base address.

public void Scatter(ref TNumber destination, int* pIndices)

Parameters

destination TNumber

A reference to the variable where the scattered data will be stored.

pIndices int*

A pointer to the array of indices that determine the destinations of each lane.

Select(ScalarLane<TNumber>, ScalarLane<TNumber>, ScalarLane<TNumber>)

Selects values from two lane values based on a condition mask.

public static ScalarLane<TNumber> Select(ScalarLane<TNumber> conditionMask, ScalarLane<TNumber> ifTrue, ScalarLane<TNumber> ifFalse)

Parameters

conditionMask ScalarLane<TNumber>

The condition mask.

ifTrue ScalarLane<TNumber>

The value to select if true.

ifFalse ScalarLane<TNumber>

The value to select if false.

Returns

ScalarLane<TNumber>

The selected lane value.

Sequence(TNumber, TNumber)

Creates a lane value with a sequence starting from the specified value with the given step.

public static ScalarLane<TNumber> Sequence(TNumber start, TNumber step)

Parameters

start TNumber

The starting value.

step TNumber

The step value for the sequence.

Returns

ScalarLane<TNumber>

The lane value containing the arithmetic sequence.

Remarks

Implementations may rely on vector creation helpers and assume that the resulting sequence length matches LaneWidth.

Sign(ScalarLane<TNumber>)

Returns the sign of each lane element.

public static ScalarLane<TNumber> Sign(ScalarLane<TNumber> value)

Parameters

value ScalarLane<TNumber>

Returns

ScalarLane<TNumber>

-1, 0, or 1 per lane.

Sin(ScalarLane<TNumber>)

Computes the sine of each lane element.

public static ScalarLane<TNumber> Sin(ScalarLane<TNumber> value)

Parameters

value ScalarLane<TNumber>

The source lane value.

Returns

ScalarLane<TNumber>

The sine of each lane element.

Remarks

Implementations may rely on vectorized math intrinsics for float/double and approximate values for other types.

SinCos(ScalarLane<TNumber>, out ScalarLane<TNumber>, out ScalarLane<TNumber>)

Computes both sine and cosine of each lane element.

public static void SinCos(ScalarLane<TNumber> value, out ScalarLane<TNumber> sin, out ScalarLane<TNumber> cos)

Parameters

value ScalarLane<TNumber>

The source lane value.

sin ScalarLane<TNumber>
cos ScalarLane<TNumber>

Remarks

Implementations returning both sin and cos simultaneously can reuse intermediate values for better performance.

Sqrt(ScalarLane<TNumber>)

Computes the square root of the lane value element-wise.

public static ScalarLane<TNumber> Sqrt(ScalarLane<TNumber> value)

Parameters

value ScalarLane<TNumber>

Returns

ScalarLane<TNumber>

The square root lane value.

Store(TNumber*)

Stores the lane value to the specified pointer.

public void Store(TNumber* pDestination)

Parameters

pDestination TNumber*

The pointer to store to.

Store(ref TNumber)

Stores the lane value to the specified reference.

public void Store(ref TNumber destination)

Parameters

destination TNumber

The reference to store to.

Tan(ScalarLane<TNumber>)

Computes the tangent of each lane element.

public static ScalarLane<TNumber> Tan(ScalarLane<TNumber> value)

Parameters

value ScalarLane<TNumber>

The source lane value.

Returns

ScalarLane<TNumber>

The tangent of each lane element.

Remarks

Many implementations use polynomial approximations and assume the input is reduced to [-pi/4, pi/4] for accuracy.

ToString()

Returns the fully qualified type name of this instance.

public override string ToString()

Returns

string

The fully qualified type name.

Trunc(ScalarLane<TNumber>)

Truncates each lane element toward zero.

public static ScalarLane<TNumber> Trunc(ScalarLane<TNumber> value)

Parameters

value ScalarLane<TNumber>

Returns

ScalarLane<TNumber>

The truncated lane value.

Operators

operator +(ScalarLane<TNumber>, ScalarLane<TNumber>)

Adds two lane values element-wise.

public static ScalarLane<TNumber> operator +(ScalarLane<TNumber> a, ScalarLane<TNumber> b)

Parameters

a ScalarLane<TNumber>

The first lane value.

b ScalarLane<TNumber>

The second lane value.

Returns

ScalarLane<TNumber>

The lane-wise sum.

operator &(ScalarLane<TNumber>, ScalarLane<TNumber>)

Computes the bitwise AND of two lane values element-wise.

public static ScalarLane<TNumber> operator &(ScalarLane<TNumber> a, ScalarLane<TNumber> b)

Parameters

a ScalarLane<TNumber>

The first lane value.

b ScalarLane<TNumber>

The second lane value.

Returns

ScalarLane<TNumber>

The result of the bitwise AND.

operator |(ScalarLane<TNumber>, ScalarLane<TNumber>)

Computes the bitwise OR of two lane values element-wise.

public static ScalarLane<TNumber> operator |(ScalarLane<TNumber> a, ScalarLane<TNumber> b)

Parameters

a ScalarLane<TNumber>

The first lane value.

b ScalarLane<TNumber>

The second lane value.

Returns

ScalarLane<TNumber>

The result of the bitwise OR.

operator /(ScalarLane<TNumber>, ScalarLane<TNumber>)

Divides two lane values element-wise.

public static ScalarLane<TNumber> operator /(ScalarLane<TNumber> a, ScalarLane<TNumber> b)

Parameters

a ScalarLane<TNumber>

The first lane value.

b ScalarLane<TNumber>

The second lane value.

Returns

ScalarLane<TNumber>

The lane-wise quotient.

operator ==(ScalarLane<TNumber>, ScalarLane<TNumber>)

Determines whether two instances of the type are equal component-wise.

public static ScalarLane<TNumber> operator ==(ScalarLane<TNumber> a, ScalarLane<TNumber> b)

Parameters

a ScalarLane<TNumber>

The first value to compare.

b ScalarLane<TNumber>

The second value to compare.

Returns

ScalarLane<TNumber>

All bits set where the elements are equal; otherwise, all bits cleared.

operator ^(ScalarLane<TNumber>, ScalarLane<TNumber>)

Computes the bitwise XOR of two lane values element-wise.

public static ScalarLane<TNumber> operator ^(ScalarLane<TNumber> a, ScalarLane<TNumber> b)

Parameters

a ScalarLane<TNumber>

The first lane value.

b ScalarLane<TNumber>

The second lane value.

Returns

ScalarLane<TNumber>

The result of the bitwise XOR.

operator >(ScalarLane<TNumber>, ScalarLane<TNumber>)

Determines whether one instance of the type is greater than another instance component-wise.

public static ScalarLane<TNumber> operator >(ScalarLane<TNumber> a, ScalarLane<TNumber> b)

Parameters

a ScalarLane<TNumber>

The first value to compare.

b ScalarLane<TNumber>

The second value to compare.

Returns

ScalarLane<TNumber>

A value indicating whether the first parameter is greater than the second parameter.

operator >=(ScalarLane<TNumber>, ScalarLane<TNumber>)

Determines whether the first operand is greater than or equal to the second operand component-wise.

public static ScalarLane<TNumber> operator >=(ScalarLane<TNumber> a, ScalarLane<TNumber> b)

Parameters

a ScalarLane<TNumber>

The first value to compare.

b ScalarLane<TNumber>

The second value to compare.

Returns

ScalarLane<TNumber>

All bits set where the first parameter is greater than or equal to the second parameter; otherwise, all bits cleared.

implicit operator ScalarLane<TNumber>(TNumber)

Implicitly converts a scalar numeric value to a lane value where all lanes are set to that value.

public static implicit operator ScalarLane<TNumber>(TNumber value)

Parameters

value TNumber

The scalar numeric value to convert.

Returns

ScalarLane<TNumber>

operator !=(ScalarLane<TNumber>, ScalarLane<TNumber>)

Determines whether two instances of the type are not equal component-wise.

public static ScalarLane<TNumber> operator !=(ScalarLane<TNumber> a, ScalarLane<TNumber> b)

Parameters

a ScalarLane<TNumber>

The first value to compare.

b ScalarLane<TNumber>

The second value to compare.

Returns

ScalarLane<TNumber>

All bits set where the elements are not equal; otherwise, all bits cleared.

operator <(ScalarLane<TNumber>, ScalarLane<TNumber>)

Determines whether one instance of the type is less than another instance component-wise.

public static ScalarLane<TNumber> operator <(ScalarLane<TNumber> a, ScalarLane<TNumber> b)

Parameters

a ScalarLane<TNumber>

The first value to compare.

b ScalarLane<TNumber>

The second value to compare.

Returns

ScalarLane<TNumber>

All bits set where the first parameter is less than the second parameter; otherwise, all bits cleared.

operator <=(ScalarLane<TNumber>, ScalarLane<TNumber>)

Determines whether the first operand is less than or equal to the second operand component-wise.

public static ScalarLane<TNumber> operator <=(ScalarLane<TNumber> a, ScalarLane<TNumber> b)

Parameters

a ScalarLane<TNumber>

The first value to compare.

b ScalarLane<TNumber>

The second value to compare.

Returns

ScalarLane<TNumber>

All bits set where the first parameter is less than or equal to the second parameter; otherwise, all bits cleared.

operator %(ScalarLane<TNumber>, ScalarLane<TNumber>)

Computes the modulus of two lane values element-wise.

public static ScalarLane<TNumber> operator %(ScalarLane<TNumber> a, ScalarLane<TNumber> b)

Parameters

a ScalarLane<TNumber>

The first lane value.

b ScalarLane<TNumber>

The second lane value.

Returns

ScalarLane<TNumber>

The lane-wise modulus.

operator *(ScalarLane<TNumber>, ScalarLane<TNumber>)

Multiplies two lane values element-wise.

public static ScalarLane<TNumber> operator *(ScalarLane<TNumber> a, ScalarLane<TNumber> b)

Parameters

a ScalarLane<TNumber>

The first lane value.

b ScalarLane<TNumber>

The second lane value.

Returns

ScalarLane<TNumber>

The lane-wise product.

operator ~(ScalarLane<TNumber>)

Computes the bitwise NOT of a lane value element-wise.

public static ScalarLane<TNumber> operator ~(ScalarLane<TNumber> a)

Parameters

a ScalarLane<TNumber>

The lane value.

Returns

ScalarLane<TNumber>

The bitwise complement of the lane value.

operator -(ScalarLane<TNumber>, ScalarLane<TNumber>)

Subtracts two lane values element-wise.

public static ScalarLane<TNumber> operator -(ScalarLane<TNumber> a, ScalarLane<TNumber> b)

Parameters

a ScalarLane<TNumber>

The first lane value.

b ScalarLane<TNumber>

The second lane value.

Returns

ScalarLane<TNumber>

The lane-wise difference.

operator -(ScalarLane<TNumber>)

Negates the lane value element-wise.

public static ScalarLane<TNumber> operator -(ScalarLane<TNumber> a)

Parameters

a ScalarLane<TNumber>

The lane value to negate.

Returns

ScalarLane<TNumber>

The negated lane value.