toqito.matrix_props.kp_norm¶
Computes the Kp-norm for matrices or vectors.
Module Contents¶
- toqito.matrix_props.kp_norm.kp_norm(mat, k, p)[source]¶
Compute the kp_norm of vector or matrix.
Calculate the p-norm of a vector or the k-largest singular values of a matrix.
Examples
To compute the p-norm of a vector
```python exec=”1” source=”above” import numpy as np from toqito.states import bell from toqito.matrix_props import kp_norm
print(np.around(kp_norm(bell(0), 1, np.inf), decimals=2)) ```
To compute the k-largest singular values of a matrix:
```python exec=”1” source=”above” import numpy as np from toqito.matrix_props import kp_norm from toqito.rand import random_unitary
print(np.around(kp_norm(random_unitary(5), 5, 2), decimals=2)) ```
- Parameters:
mat (numpy.ndarray) – 2D numpy ndarray
k (int) – The number of singular values to take.
p (int) – The order of the norm.
- Returns:
The kp-norm of a matrix.
- Return type:
float | numpy.floating