linear combinations

SYNOPSIS

#include "matrix.h"
VEC  *v_lincomb(int n, VEC *v_list[], double a_list[],
                VEC *out)
VEC  *v_linlist(VEC *out, VEC *v1, double a1,
                          VEC *v2, double a2, ..., VNULL)
#include "zmatrix.h"
ZVEC *zv_lincomb(int n, ZVEC *v_list[], complex a_list[],
                   ZVEC *out)
ZVEC *zv_linlist(ZVEC *out, ZVEC *v1, complex a1,
                        ZVEC *v2, complex a2, ..., ZVNULL)

DESCRIPTION

The routines v_lincomb() and zv_lincomb() compute the linear combination $\sum_{i=0}^{n-1}a_iv_i$ where $v_i$ is identified with v_list[i] and $a_i$ is identified with a_list[i]. The result is stored in out, which is created or resized as necessary. Note that n is the length\/ of the lists. An E_INSITU error will be raised if out == v_list[i] for any i other than i == 0. The routines v_linlist() and zv_linlist() are variants of the above which do not require setting up an array before hand. This returns $\sum_i a_iv_i$ where the sum is over $i=1,2,\dots$ until a VNULL is reached, which should take the place of one of the vk's. An E_INSITU error will be raised if out == v2, v3, v4,....

EXAMPLE

VEC    *x[10], *v1, *v2, *v3, *v4, *out;
Real    a[10], h;
  ......
for ( i = 0; i < 10; i++ )
{   x[i] = ...;  a[i] = ...;   }
out = v_lincomb(10,x,a,VNULL)
/* for Runge--Kutta code:
      out = h/6*(v1+2*v2+2*v3+v4) */
v_zero(out);
out = v_linlist(out, v1, h/6.0, v2, h/3.0,
                     v3, h/3.0, v4, h/6.0,
                     VNULL);

SEE ALSO: sv_mlt(), v_mltadd(), zv_mlt(), zv_mltadd()

BUGS

SOURCE FILE: vecop.c, zvecop.c