SYNOPSIS
#include <agar/core.h> #include <agar/gui.h> #include <agar/math/m.h>
DESCRIPTION
The
M_VectorZ functions implement basic operations on signed-integer-valued
n dimensional vectors.
VECTORS IN Z^N
The following routines operate on dynamically-allocated vectors in Z^n.
Vectors entries are directly accessible through the
v array.
The
M_VectorZ structure is defined as:
typedef struct m_vector { Uint n; /* Size */ Uint32 _pad; int *_Nonnull v; /* Elements */ } M_VectorZ;
VECTORS IN Z^N: INITIALIZATION
M_VectorZ * M_VectorNewZ (Uint m)
void M_VectorFreeZ (M_VectorZ *v)
int M_VectorResizeZ (M_VectorZ *v, Uint m)
The M_VectorNewZ() function allocates a new vector in Z^n. M_VectorFreeZ() releases all resources allocated for the specified vector.
M_VectorResizeZ() resizes the vector v to m. Existing entries are preserved, but new entries are left uninitialized. If insufficient memory is available, -1 is returned and an error message is set. On success, the function returns 0.
VECTORS IN Z^N: BASIC OPERATIONS
void M_VectorCopyZ (const M_VectorZ *vDst, const M_VectorZ *vSrc)
M_VectorZ * M_VectorScaleZv (const M_VectorZ *v, M_Real c)
void M_VectorAddZv (M_VectorZ *a, const M_VectorZ *b)
void M_VectorSubZv (M_VectorZ *a, const M_VectorZ *b)
M_VectorCopyZ() copies the contents of vector vSrc into vDst. Both vectors must have the same size.
M_VectorScaleZv() scales each component of vector v by a scaling factor c.
M_VectorAddZv() returns the sum of vectors a and b into a. Both vectors must be of the same size.
M_VectorSubZv() returns the difference of vectors a and b into a. Both vectors must be of the same size.
SEE ALSO
HISTORY
The
M_VectorZ interface appeared in
Agar 1.3.4.
It was first documented in
Agar 1.7.1.