wvMatrixGlobal(3) USC Math Department
Back to wvlib matrix function index
wvMatrixGlobal(3)

Name

wvMatrixClear, wvMatrixForEachElt - operate on all elements of a matrix

Synopsis

#include <wv/matrix.h>

void wvMatrixClear(WVmatrix *matrix);

void wvMatrixForEachElt(WVmatrix *matrix, WVbinaryOpFunc op, WVdata op2);

Description

wvMatrixClear sets each element of matrix to zero.

wvMatrixForEachElt performs the binary operation op on each element of matrix.

WVbinaryOpFunc is a pointer to a function which has a prototype matching the following:

WVdata func(WVdata op1, WVdata op2);

The function will be passed an element of matrix as op1 and the op2 from the wvMatrixForEachElt call will be passed to the function as op2.

Example

#include <wv/matrix.h>
  
    .
    .
    .
WVdata alphaMultiply(WVdata op1, WVdata op2)
{
    return op1 * op2;
}
  
    .
    .
    .

{
    WVindexVector *size;
    WVmatrix *mat;

    size = wvVaNewIndexVector(2, 256, 512);
    mat  = wvNewMatrix(size);

    .
    .
    .

    /* multiply mat by alpha=2 */
    wvMatrixForEachElt(mat, alphaMultiply, 2);
    .
    .
    .

    wvDestroyMatrix(mat);
    wvDestroyIndexVector(size);
}

See Also

wvMatrixElt(3), wvNewMatrix(3)

Back to wvlib matrix function index Last Updated: 28 January 1998