GRASS Programmer's Manual  6.4.2(2012)
mult.c
Go to the documentation of this file.
00001 /* Author: Bill Hoff,2-114C,8645,3563478 (hoff) at uicsl */
00002 
00022 int
00023 mult(double *v1[2], int size1, double *v2[2], int size2, double *v3[2],
00024      int size3)
00025 {
00026     int i, n;
00027 
00028     n = (size1 < size2 ? size1 : size2);        /* get the smaller size */
00029     for (i = 0; i < n; i++) {
00030         *(v3[0] + i) =
00031             *(v1[0] + i) * *(v2[0] + i) - *(v1[1] + i) * *(v2[1] + i);
00032         *(v3[1] + i) =
00033             *(v1[0] + i) * *(v2[1] + i) + *(v2[0] + i) * *(v1[1] + i);
00034     }
00035 
00036     /* if unequal size, zero out remaining elements of larger vector */
00037     if (size1 != size2)
00038         for (i = n; i < size3; i++) {
00039             *(v3[0] + i) = 0.0;
00040             *(v3[1] + i) = 0.0;
00041         }
00042 
00043     return 0;
00044 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines