lpnorm
Functions
-
int main(int argc, char *argv[])
lpnorm [ option ] [ infile ]
-l int
length of vector
-m int
order of vector
-p double or str
order of norm
infile str
double-type vector sequence
stdout
double-type normalized vector sequence
The below example calculates L2-normalized vector sequence:
echo 3 4 | x2x +ad | lpnorm -l 2 -p 2 | x2x +da # 0.6 0.8
- Parameters:
argc – [in] Number of arguments.
argv – [in] Argument vector.
- Returns:
0 on success, 1 on failure.
-
class LpNormCalculation
Calculate Lp-norm.
The input is the \(M\)-th order vector:
\[ \begin{array}{cccc} x(0), & x(1), & \ldots, & x(M), \end{array} \]The output is the Lp-norm represented as\[ \begin{array}{cccc} \|x\|_p = \left(\displaystyle\sum_{m=0}^M |x(m)|^p\right)^{\frac{1}{p}}. \end{array} \]Public Functions
-
LpNormCalculation(int num_order, double p)
- Parameters:
num_order – [in] Order of input, \(M\).
p – [in] Power, \(p\).
-
inline bool IsValid() const
- Returns:
True if this object is valid.
-
bool Run(const std::vector<double> &data, double *norm) const
- Parameters:
data – [in] \(M\)-th order vector.
norm – [out] Lp-norm.
- Returns:
True on success, false on failure.
-
LpNormCalculation(int num_order, double p)