scalar--vector multiplication and addition

SYNOPSIS

#include "matrix.h"
VEC     *sv_mlt(double s, VEC *x, VEC *out)
VEC     *v_add(VEC *v1, VEC *v2, VEC *out)
VEC     *v_mltadd(VEC *v1, VEC *v2, double s, VEC *out)
VEC     *v_sub(VEC *v1, VEC *v2, VEC *out)
#include "zmatrix.h"
ZVEC    *zv_mlt(complex s, ZVEC *x, ZVEC *out)
ZVEC    *zv_add(ZVEC *v1, ZVEC *v2, ZVEC *out)
ZVEC    *zv_mltadd(ZVEC *v1, ZVEC *v2, complex s, ZVEC *out)
ZVEC    *zv_sub(ZVEC *v1, ZVEC *v2, ZVEC *out)

DESCRIPTION

The routines sv_mlt() and zv_mlt() perform the scalar multiplication of the scalar s and the vector x and the results are placed in out. The routines v_add() and zv_add() adds the vectors v1 and v2, and the result is returned in out. The routines v_mltadd() and zv_mltadd() set out to be the linear combination v1+s.v2. The routines v_sub() and zv_sub() subtract v2 from v1, and the result is returned in out. For all of the above routines, if out is NULL, then a new vector of the appropriate size is created. For all routines the result (whether newly allocated or not) is returned. All these operations may be performed in situ. Errors are raised if v1 or v2 are NULL, or if v1 and v2 have different dimensions.

EXAMPLE

VEC    *x, *y, *z, *tmp;
ZVEC   *v, *w;
Real   alpha;
complex beta;
  ......
tmp = v_get(x->dim);
z = v_get(x->dim);
printf("# 2-Norm of x - y = 
       v_norm2(v_sub(x,y,tmp)));
/* z = x + alpha.y */
v_mltadd(x,y,alpha,z);
/* ...or equivalently */
sv_mlt(alpha,y,z);
v_add(x,z,z);
zv_mltadd(v,w,beta,v);

SOURCE FILE: vecop.c, zvecop.c