Table of Contents

NAME

QccVectorIntAlloc, QccVectorIntFree, QccVectorIntZero, QccVectorIntResize, QccVectorIntMean, QccVectorIntVariance, QccVectorIntAdd, QccVectorIntSubtract, QccVectorIntScalarMult, QccVectorIntCopy, QccVectorIntNorm, QccVectorIntDotProduct, QccVectorIntSquareDistance, QccVectorIntSumComponents, QccVectorIntMaxValue, QccVectorIntMinValue, QccVectorIntPrint - miscellaneous integer-vector routines

SYNOPSIS

#include "libQccPack.h"

QccVectorInt QccVectorIntAlloc(int vector_dimension);

void QccVectorIntFree(QccVectorInt vector);

int QccVectorIntZero(QccVectorInt vector, int vector_dimension);

QccVectorInt QccVectorIntResize(QccVectorInt vector, int vector_dimension, int new_vector_dimension);

double QccVectorIntMean(const QccVectorInt vector, int vector_dimension);

double QccVectorIntVariance(const QccVectorInt vector, int vector_dimension);

int QccVectorIntAdd(QccVectorInt vector1, const QccVectorInt vector2, int vector_dimension);

int QccVectorIntSubtract(QccVectorInt vector1, const QccVectorInt vector2, int vector_dimension);

int QccVectorIntScalarMult(QccVectorInt vector, int s, int vector_dimension);

int QccVectorIntCopy(QccVectorInt vector1, const QccVectorInt vector2, int vector_dimension);

double QccVectorIntNorm(const QccVectorInt vector, int vector_dimension);

int QccVectorIntDotProduct(const QccVectorInt vector1, const QccVectorInt vector2, int vector_dimension);

int QccVectorIntSquareDistance(const QccVectorInt vector1, const QccVectorInt vector2, int vector_dimension);

int QccVectorIntSumComponents(const QccVectorInt vector, int vector_dimension);

int QccVectorIntMaxValue(const QccVectorInt vector, int vector_dimension, int *winner);

int QccVectorIntMinValue(const QccVectorInt vector, int vector_dimension, int *winner);

int QccVectorIntPrint(const QccVectorInt vector, int vector_dimension);

DESCRIPTION

The QccPack library routines use a one-dimensional integer-vector type defined as follows:

typedef int *QccVectorInt;

QccVectorIntAlloc() allocates space for a QccVectorInt of dimension vector_dimension. QccVectorIntAlloc() returns a NULL pointer if the allocation fails.

QccVectorIntFree() frees the space previously allocated via QccVectorIntAlloc()

QccVectorIntZero() makes each component of vector zero. QccVectorIntZero() returns 0 on success, 1 on failure.

QccVectorIntResize() changes the dimension of vector from vector_dimension to new_vector_dimension by calling realloc(3) . Upon success, the new vector is returned; a NULL pointer is returned if realloc(3) fails. If vector is NULL, QccVectorIntAlloc() is called. In any case, all elements added to vector are zero.

QccVectorIntMean() returns the mean value of all the components of vector. In the case that vector is NULL, QccVectorIntMean() returns 0.0.

QccVectorIntVariance() returns the variance of the components of vector. In the case that vector is NULL, QccVectorIntVariance() returns 0.0.

QccVectorIntSum() returns the sum of all the components of vector. In the case that vector is NULL, QccVectorIntSum() returns 0.

QccVectorIntAdd() adds each component of vector1 to the corresponding component of vector2 (vector addition). The resulting integer vector is returned in vector1. Both vector1 and vector2 must have the same vector dimension, vector_dimension. QccVectorIntAdd() returns 0 on success, 1 on failure.

QccVectorIntSubtract() subtracts each component of vector2 from the corresponding component of vector1. The resulting integer vector is returned in vector1. Both vector1 and vector2 must have the same vector dimension, vector_dimension. QccVectorIntSubtract() returns 0 on success, 1 on failure.

QccVectorIntScalarMult() multiplies vector by the scalar s; that is, each component of vector is multiplied by the int s, and the resulting integer vector is returned in vector. QccVectorIntScalarMult() returns 0 on success, 1 on failure.

QccVectorIntCopy() copies vector2 to vector1. QccVectorIntCopy() returns 0 on success, 1 on failure.

QccVectorIntNorm() calculates the norm (square root of dot product) of vector. If vector is NULL, 0.0 is returned.

QccVectorIntDotProduct() calculates and returns the dot product of integer vectors vector1 and vector2. Both vector1 and vector2 must have the same vector dimension, vector_dimension. If either vector1 or vector2 is NULL, 0 is returned.

QccVectorIntSquareDistance() calculates the squared Euclidean distance between integer vectors vector1 and vector2. That is, vector2 is subtracted from vector1 and the dot product of the difference vector is returned. Both vector1 and vector2 must have the same vector dimension, vector_dimension. If either vector1 or vector2 is NULL, 0 is returned.

QccVectorIntSumComponents() adds all the components of vector together and returns the sum.

QccVectorIntMaxValue() returns the value of the largest component of vector. If winner is not a NULL pointer, the index (0 through vector_dimension - 1) of the maximum component is returned in the int pointed to by winner.

QccVectorIntMinValue() returns the value of the smallest component of vector. If winner is not a NULL pointer, the index (0 through vector_dimension - 1) of the minimum component is returned in the int pointed to by winner.

QccVectorIntPrint() prints the components of vector to stdout.

SEE ALSO

QccPack(3)

NOTES

Except as noted above, these integer-vector routines accept NULL integer-vector pointers, in which case these routines return immediately without generating an error or performing any operations.

AUTHOR

Copyright (C) 1997-2021 James E. Fowler


Table of Contents



Get QccPack at SourceForge.net. Fast, secure and Free Open Source software downloads