PNorm 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

Returns the p-norm of a vector of real numbers.

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

Description

Given an array $x$, this returns the $p$-norm $|x|_p= (\sum_{j}|x_j|^{p})^{1/p}$.

Input

p : Double

A positive number representing the exponent $p$ in the $p$-norm.

array : Double[]

The vector $x$ of real numbers whose $p$-norm is to be returned.

Output : Double

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