PNormalized function

Warning

This documentation refers to the Classic QDK, which has been replaced by the Modern QDK.

Please see https://aka.ms/qdk.api for the API documentation for the Modern QDK.

Namespace: Microsoft.Quantum.Math

Package: Microsoft.Quantum.Standard

Normalizes a vector of real numbers according to the p-norm for a given p.

function PNormalized (p : Double, array : Double[]) : Double[]

Description

That is, given an array $x$ of type Double[], this returns an array where all elements are divided by the $p$-norm $|x|_p$.

Input

p : Double

The exponent $p$ in the $p$-norm.

array : Double[]

The vector $x$ to be normalized.

Output : Double[]

The array $x$ normalized by the $p$-norm $|x|_p$.

Remarks

This function defines a norm only when p >= 1.0 or Length(array) is either 0 or 1. In the more general case, this function fails the triangle inequality.

See Also