Beispiel #1
0
int main(void)
{
DSP_WORD *dsp_prog;
FILE * fp;
long prog_size;
int abil;
MATRIX c;
long c1[N][N*2];
int i,j;

	if (Dsp_Lock())
		{
			printf("DSP already in use\n");
			return 10;
		}
	
	if (Dsp_Reserve(0x40+N*N,0x1000+N*N*3))
		{
			printf("Can't reserve enough DSP RAM\n");
			Dsp_Unlock();
			return 10;
		}

/* Now open the DSP file */
	fp=fopen(DSP_CODE_FILE,"rb");
	if (fp==NULL)
		{
			printf("Can't open file " DSP_CODE_FILE "\n");
			Dsp_Unlock();
			return 10;
		}
	
/* Now read the DSP file into dsp_prog with the size in dsp words in prog_size */	
	fseek(fp,0,SEEK_END);
	prog_size=ftell(fp)/sizeof(DSP_WORD);
	fseek(fp,0,SEEK_SET);
	dsp_prog=malloc(prog_size*sizeof(DSP_WORD));
	fread(dsp_prog,sizeof(DSP_WORD),prog_size,fp);
	fclose(fp);

	abil=Dsp_RequestUniqueAbility();
	Dsp_ExecProg(dsp_prog,prog_size,abil);
	Dsp_BlkUnpacked(0,0,&(c1[0][0]),N*N*2);

	for	(i=0;i<N;i++)
		for	(j=0;j<N;j++)
			c[i][j]=c1[i][j*2]+(float)(c1[i][j*2+1])/0x800000;
	
	showmat(c);
	Dsp_Unlock();
	return	0;
}
Beispiel #2
0
int main(void)
{
MATRIX a,b,c;
int i,j;

for	(i=0;i<N;i++)
		for	(j=0;j<N;j++)
			{
				a[i][j]=  (float)(rand())/(RAND_MAX+1);
				b[i][j]=  (float)(rand())/(RAND_MAX+1);
			}

	showmat(a);
	showmat(b);

	if(mult(a,b,c)) 
		{
			printf("multiply failed\n");
			return 10;
		}
	
	showmat(c);
	return 0;	
}
Beispiel #3
0
/** Display a square matrix as follows:
 * M=[   +nnn.nnnnnn,   +nnn.nnnnnn,   ...,   +nnn.nnnnnn,
 *       +nnn.nnnnnn,   +nnn.nnnnnn,   ...,   +nnn.nnnnnn,
 *            ...           ...                   ...
 *       +nnn.nnnnnn,   +nnn.nnnnnn,   ...,   +nnn.nnnnnn];
 */
void ssm(size_t order, double *M) {
	showmat(order, order, M);
}
Beispiel #4
0
/** Display a matrix and a description as follows:
 *
 * <description>:
 *
 * M=[   +nnn.nnnnnn,   +nnn.nnnnnn,   ...,   +nnn.nnnnnn,
 *       +nnn.nnnnnn,   +nnn.nnnnnn,   ...,   +nnn.nnnnnn,
 *       +nnn.nnnnnn,   +nnn.nnnnnn,   ...,   +nnn.nnnnnn,
 *       +nnn.nnnnnn,   +nnn.nnnnnn,   ...,   +nnn.nnnnnn,
 *            ...           ...                   ...
 *       +nnn.nnnnnn,   +nnn.nnnnnn,   ...,   +nnn.nnnnnn];
 */
void smd(const char *description, size_t nrows, size_t ncols, double *M) {
	printf("\n%s:\n\n", description);
	showmat(nrows, ncols, M);
}
Beispiel #5
0
/** Display a row vector as follows:
 * M=[   +nnn.nnnnnn,   +nnn.nnnnnn,   ...,   +nnn.nnnnnn];
 */
void srv(size_t length, double *v) {
	showmat(1, length, v);
}