vector norms

SYNOPSIS

#include "matrix.h"
double  v_norm1(VEC *x)
double  v_norm2(VEC *x)
double  v_norm_inf(VEC *x)
double _v_norm1(VEC *x, VEC *scale)
double _v_norm2(VEC *x, VEC *scale)
double _v_norm_inf(VEC *x, VEC *scale)
#include "zmatrix.h"
double  zv_norm1(ZVEC *x)
double  zv_norm2(ZVEC *x)
double  zv_norm_inf(ZVEC *x)
double _zv_norm1(ZVEC *x, VEC *scale)
double _zv_norm2(ZVEC *x, VEC *scale)
double _zv_norm_inf(ZVEC *x, VEC *scale)

DESCRIPTION

These functions compute vector norms. In particular, v_norm1() and zv_norm1() give the 1--norm, v_norm2() and zv_norm2() give the 2--norm or Euclidean norm, and v_norm_inf() and zv_norm_inf() compute the $\infty$--norm. These are defined by the following formulae: \begin{align} \|x\|_1={}&\sum_i|x_i|\\ \|x\|_\infty={}&\max_i|x_i|\\ \|x\|_2={}&\sqrt{\sum_i|x_i|^2}. \end{align} There are also scaled\/ versions of these vector norms: _v_norm1(), _v_norm2() and _v_norm_inf(), and _zv_norm1(), _zv_norm2() and _zv_norm_inf(). These take a vector x whose norm is to be computed, and a scaling vector. Each component of the x vector is divided by the corresponding component of the scale vector, and the norm is computed for the ``scaled'' version of x. Note that the scale vector is a (real) VEC since only the magnitudes are important. If the corresponding component of scale is zero for that component of x, or if scale is NULL, then no scaling is done. (In fact, v_norm1(x) is a macro that expands to _v_norm1(x,VNULL).) For example, _v_norm1(x,scale) returns \[\sum_i|x_i/\textscale_i|\] provided scale is not NULL, and no element of scale is zero. The behaviour of _v_norm2() and _v_norm_inf() is similar.

EXAMPLE

VEC    *x, *scale;
  ......
printf("# 2-Norm of x = 
printf("# Scaled 2-norm of x = 
       _v_norm2(x,scale));

SEE ALSO: m_norm1(), m_norm_inf(), zm_norm1(), zm_norm_inf().

BUGS

There is the possibility that v_norm2() may overflow if x has components with size of order $\sqrt{\text{HUGE}}$.

SOURCE FILE: norm.c