Skip to content

< Back


SpanNormalizationExtensions

Namespace: LLama.Extensions

Extensions to span which apply in-place normalization

1
public static class SpanNormalizationExtensions

Inheritance ObjectSpanNormalizationExtensions
Attributes ExtensionAttribute

Methods

MaxAbsoluteNormalization(Single[])

In-place multiple every element by 32760 and divide every element in the span by the max absolute value in the span

1
public static Single[] MaxAbsoluteNormalization(Single[] vector)

Parameters

vector Single[]

Returns

Single[]
The same array

MaxAbsoluteNormalization(Span<Single>)

In-place multiple every element by 32760 and divide every element in the span by the max absolute value in the span

1
public static Span<float> MaxAbsoluteNormalization(Span<float> vector)

Parameters

vector Span<Single>

Returns

Span<Single>
The same span

TaxicabNormalization(Single[])

In-place divide every element in the array by the sum of absolute values in the array

1
public static Single[] TaxicabNormalization(Single[] vector)

Parameters

vector Single[]

Returns

Single[]
The same array

Remarks:

Also known as "Manhattan normalization".

TaxicabNormalization(Span<Single>)

In-place divide every element in the span by the sum of absolute values in the span

1
public static Span<float> TaxicabNormalization(Span<float> vector)

Parameters

vector Span<Single>

Returns

Span<Single>
The same span

Remarks:

Also known as "Manhattan normalization".

EuclideanNormalization(Single[])

In-place divide every element by the euclidean length of the vector

1
public static Single[] EuclideanNormalization(Single[] vector)

Parameters

vector Single[]

Returns

Single[]
The same array

Remarks:

Also known as "L2 normalization".

EuclideanNormalization(Span<Single>)

In-place divide every element by the euclidean length of the vector

1
public static Span<float> EuclideanNormalization(Span<float> vector)

Parameters

vector Span<Single>

Returns

Span<Single>
The same span

Remarks:

Also known as "L2 normalization".

EuclideanNormalization(ReadOnlySpan<Single>)

Creates a new array containing an L2 normalization of the input vector.

1
public static Single[] EuclideanNormalization(ReadOnlySpan<float> vector)

Parameters

vector ReadOnlySpan<Single>

Returns

Single[]
The same span

PNormalization(Single[], Int32)

In-place apply p-normalization. https://en.wikipedia.org/wiki/Norm_(mathematics)#p-norm

-

-

1
public static Single[] PNormalization(Single[] vector, int p)

Parameters

vector Single[]

p Int32

Returns

Single[]
The same array

PNormalization(Span<Single>, Int32)

In-place apply p-normalization. https://en.wikipedia.org/wiki/Norm_(mathematics)#p-norm

-

-

1
public static Span<float> PNormalization(Span<float> vector, int p)

Parameters

vector Span<Single>

p Int32

Returns

Span<Single>
The same span


< Back