next up previous contents
Next: Complex numbers Up: The Common Package Previous: Memory allocation   Contents

Array fill/copy

      #include <gandalf/common/array.h>
There are two sets of functions in this module, one set dealing with filling an array of numbers or pointers with a constant value, the other dealing with copying an array into another array. To fill an array of floats with the value five, for instance, use
      float afArray[100];

      gan_fill_array_f ( afArray, 100, 1, 5.0F );
The third stride argument will be one for filling a simple contiguous array. A different value indicates the number of elements of the array to skip when filling each value. A value of three, for instance, indicates that only every third element of the array is to be filled.

To copy one array into another, each having arbitrary stride, use

      float afArray1[100], float afArray2[100];

      /* fill array afArray1 with values */

      gan_copy_array_f ( afArray1, 1, 100, afArray2, 1 );
This copies array afArray1 into afArray2.