l2normalize

Modifies the argument to be unit length, dividing by its l2-norm. IllegalArgumentException is thrown for zero vectors.

Return

the input array after normalization


fun l2normalize(v: FloatArray, throwOnZero: Boolean): FloatArray

Modifies the argument to be unit length, dividing by its l2-norm.

Return

the input array after normalization

Parameters

v

the vector to normalize

throwOnZero

whether to throw an exception when v has all zeros

Throws

when the vector is all zero and throwOnZero is true