next up previous contents
Next: Creating and accessing fixed Up: Fixed size matrices and Previous: Fixed size matrices and   Contents


Fixed size vectors

Vectors of sizes two, three and four are represented by specific structures in Gandalf. The structure and function definitions are nearly identical, so we shall only describe the workings of 3-vectors. To use 3-vectors include the header file
      #include <gandalf/linalg/3vector.h>
for double precision, or
      #include <gandalf/linalg/3vectorf.h>
for single precision 3-vectors. A double precision 3-vector is defined as
      typedef struct Gan_Vector3
      {
         double x, y, z;
      } Gan_Vector3, Gan_Vector3_d
and a single precision 3-vector as
      typedef struct Gan_Vector3_f
      {
         float x, y, z;
      } Gan_Vector3_f;

Most of the routines below return a pointer to the result vector/matrix. This may be used as an argument to another routine, although care must be taken with macros as regards multiple evaluation. The routines are very safe, because everything using fixed size vectors & matrices can be written to involve only automatic variables with no dynamic allocation, and the only failure modes are arithmetic overflow (Gandalf does not check for this). The few exceptions are noted in the text.



Subsections

2006-03-17