Norm
Return matrix or vector norm.
double vector::Norm(
|
Parameters
norm
[in] Norm order
Return Value
Matrix or vector norm.
Note
- VECTOR_NORM_INF is the maximum absolute value among vector elements.
- VECTOR_NORM_MINUS_INF is the minimum absolute value of a vector.
- VECTOR_NORM_P is the P-norm of the vector. If norm_p=0, then this is the number of non-zero vector elements. norm_p=1 is the sum of absolute values of vector elements. norm_p=2 is the square root of the sum of squares of vector element values. The value of the norm_p parameter can be negative.
- MATRIX_NORM_FROBENIUS is the square root of the sum of the squares of the matrix element values. The Frobenius norm and the vector P2-norm are consistent.
- MATRIX_NORM_SPECTRAL is the maximum value of the matrix spectrum.
- MATRIX_NORM_NUCLEAR is the sum of the singular values of the matrix.
- MATRIX_NORM_INF is the maximum vector p1-norm among the vertical vectors of the matrix. The matrix inf-norm and the vector inf-norm are consistent.
- MATRIX_NORM_MINUS_INF is the minimum vector p1-norm among the vertical vectors of the matrix.
- MATRIX_NORM_P1 is the maximum vector p1-norm among horizontal matrix vectors.
- MATRIX_NORM_MINUS_P1 is the minimum vector p1-norm among horizontal matrix vectors.
- MATRIX_NORM_P2 is the highest singular value of the matrix.
- MATRIX_NORM_MINUS_P2 is the lowest singular value of a matrix.
A simple algorithm for calculating the P-norm of a vector in MQL5:
double VectorNormP(const vector& v,int norm_value)
|
MQL5 example:
matrix a= {{0, 1, 2, 3, 4, 5, 6, 7, 8}};
|
Python example:
import numpy as np
|