/*-------------------------------------------------------------*/
/* Cut this and save to magonly.c			       */
/* Program by Gregory F. Shay  1988			*/

#include <stdio.h>
#include <math.h>
#define MAXN 2048

main()
{
	int i,j,k,flag;
	char dtype;
	float xinr[MAXN],xini[MAXN];
	int LOGN,N,size,avenum;
	float temp;
flag = 0;
/* input size of array */
scanf("%c\n",&dtype);
if (dtype != 'c')
	{
	fprintf(stderr,"Incompatible input data file, Magnitude expects complex\n");
	flag = 1;
	}
scanf("%d \n",&LOGN);
if ((LOGN<2) || (LOGN>14) )
	{
	flag = 1;
	fprintf(stderr,"Error, size of array, %d, out of range.\n",LOGN);
	}
N = 1 << LOGN;
if (N>MAXN) 
	{
	fprintf(stderr,"Error, maximum size of array is set to %d\n",MAXN);
	flag = 1;
	}
if (flag == 0)
  {
/* Read in data */
for(i=0;i<N;i++)
	{
	scanf("%f ",&xinr[i]);
	scanf("%f ",&xini[i]);
	}
/* convert to magnitude and phase angle */
for(i=0;i<N;i++)
	{
	xinr[i]= sqrt(xinr[i]*xinr[i]+xini[i]*xini[i]);
	}
printf("%c\n",'r');
printf("%d\n",LOGN);

for(i=0;i<N/8;i++)
	{
	for(j=0;j<8;j++)
		printf("%g   ",xinr[j+i*8]);
	printf("\n");
	}

 } /* End of no error if */
} /* end of main */
