Home > @josh-brown/vector > pNorm
Calculates the P-Norm of a vector v
Signature:
export declare function pNorm<S>(v: Vector<S>, p: number): number;
Parameter | Type | Description |
---|---|---|
v | Vector<S> | The vector for which to calculate the norm |
p | number | The power used to calculate the norm |
Returns:
number
const v = vec([3, 4]);
const norm1 = pNorm(v, 1); // 7
const norm2 = pNorm(v, 2); // 5
const norm3 = pNorm(v, 3); // 4.49794...