next up previous contents
Next: Rescaling a general size Up: General size vectors Previous: General size vector addition   Contents

General size vector subtraction

The routines for vector subtraction follow the scheme of those for vector addition, leading to the options
      Gan_Vector vx, vy, vz; /* declare vectors x, y and z */
      Gan_Vector *pvz; /* declare vector z alternatively as pointer */

      /* ... create and fill vx & vy, create vz ... */
      gan_vec_sub_q ( &vx, &vy, &vz ); /* compute z = x - y */
      pvz = gan_vec_sub_s ( &vx, &vy ); /* compute z = x - y */
      gan_vec_sub_i1 ( &vx, &vy ); /* replace x = x - y */
      gan_vec_sub_i2 ( &vx, &vy ); /* replace y = x - y */
      gan_vec_decrement ( &vx, &vy ); /* replace x = x - y */

Error detection: NULL is returned and the Gandalf error handler invoked if the vector subtraction fails. The most likely failure modes are failing to create/set the result vector, or size incompatibility between the input vectors.



2006-03-17