/************************************************************************
*									*
*                     Matrix Operation (C Version)                      *
*									*
************************************************************************/

/*  Authors:  Saeid Nooshabadi and John Zaitseff
    Date:     8th March, 2003
    Version:  1.2

    This program calculates the following matrix (more properly called
    vector) operation:

        C[i] = A[i] / 2  +  2 * B[i]

    The main point to note about this program is how pointers are used in
    C to access arrays.  In particular, *(a + i) is the same as a[i].
*/


int main (void)
{
    int a[4] = {-1, 2,	3, 4};
    int b[4] = { 5, 6, -7, 8};
    int c[4];
    int i;

    for (i = 0; i <= 3; i++) {
	*(c + i) = (*(a + i) >> 1) + (*(b + i) << 1);
	    /* Note that this line is the same as:
		 c[i] = (a[i] >> 1) + (b[i] << 1)
	       which is essentially the same as:
		 c[i] = (a[i] / 2)  + (b[i] * 2)  */
    }

    return 0;
}

