Gan_Vector vx, vy, vz; /* declare vectors x, y and z */ /* ... create and fill vx & vy, create vz ... */ gan_vec_add_q ( &vx, &vy, &vz ); /* compute z = x + y */Again vector
Gan_Vector *pvz; /* declare vector z as pointer */ /* ... create and fill vx & vy ... */ pvz = gan_vec_add_s ( &vx, &vy ); /* compute z = x + y */Another way of computing vector addition is to replace one of the input vector
gan_vec_add_i1 ( &vx, &vy ); /* replace x = x + y */ gan_vec_add_i2 ( &vx, &vy ); /* replace y = x + y */An alternative to gan_vec_add_i1() is the more explicit routine
gan_vec_increment ( &vx, &vy ); /* replace x = x + y */
Error detection: NULL is returned and the Gandalf error handler invoked if the vector addition fails. The most likely failure modes are failing to create/set the result vector, or size incompatibility between the input vectors.