Skip to content

Latest commit

 

History

History
36 lines (22 loc) · 778 Bytes

vector.pnorm.md

File metadata and controls

36 lines (22 loc) · 778 Bytes

Home > @josh-brown/vector > pNorm

pNorm() function

Calculates the P-Norm of a vector v

Signature:

export declare function pNorm<S>(v: Vector<S>, p: number): number;

Parameters

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

Example

const v = vec([3, 4]);
const norm1 = pNorm(v, 1); // 7
const norm2 = pNorm(v, 2); // 5
const norm3 = pNorm(v, 3); // 4.49794...