/*-------------------------------------------------------------*/
/* Cut this and save to mult.c				       */
/* Program by Gregory F. Shay  1988			*/
#include <stdio.h>
#include <math.h>
#define MAXN 2048

main(argc,argv)
	int argc;
	char *argv[];
{
	int i,j,k,mn,cc;
	char dtype,dtype2;
	int LOGN,LOGN2,N,N2,size,avenum;
	float x1r,x1i,x2r,x2i;
	float temp;
	FILE *fopen();
	FILE *fp;

cc = 0;
if ((fp = fopen(argv[1],"r")) == NULL)
	{
	fprintf(stderr,"Mult: file not found\n");
	exit(0);
	}
/* input size of array */
scanf("%c\n",&dtype);
fscanf(fp,"%c\n",&dtype2);
if (((dtype != 'c')&&(dtype != 'r'))||((dtype2 != 'c')&&(dtype2 != 'r')))
	{
	fprintf(stderr,"Incompatible data file type.\n");
	exit(0);
	}
if ((dtype == 'r')&&(dtype2=='r'))
	printf("%c \n",'r');
else
	printf("%c \n",'c');

scanf("%d \n",&LOGN);
fscanf(fp,"%d \n",&LOGN2);
if ((LOGN<2) || (LOGN>14) ||(LOGN2<2)||(LOGN2>14))
	{
	fprintf(stderr,"Error, size of array, %d, out of range.\n",LOGN);
	exit(0);
	}

N = 1 << LOGN;
N2 = 1<< LOGN2;
if ((N>MAXN) ||(N2>MAXN))
	{
	fprintf(stderr,"Error, maximum size of array is set to %d\n",MAXN);
	exit(0);
	}
mn = N;
if (N2 < mn)
	{
	mn = N2;
	printf("%d \n",LOGN2);
	}
else
	printf("%d \n",LOGN);

/* Read in data */
for(i=0;i<mn;i++)
	{
	scanf("%f ",&x1r);
	if (dtype == 'c')
		scanf("%f ",&x1i);
	else 
		x1i=0.;
	fscanf(fp,"%f ",&x2r);
	if (dtype2 == 'c')
		scanf("%f ",&x2i);
	else 
		x2i=0.;

	printf("%f ",x1r*x2r-x1i*x2i);
	cc++;
	if ( (dtype != 'r')||(dtype2!='r'))
		{
		printf("%f ",x1r*x2i+x1i*x2r);
		cc++;
		}
	if (cc >= 8)
		{
		printf("\n");
		cc = 0;
		}
	}
} /* End of main */
