campo-sirio/gfm/mgmn.c
alex ba237a9d91 Patch level : no patch
Files correlati     :
Ricompilazione Demo : [ ]
Commento            :
Aggiunti i sorgenti per Greenleaf Math Library (gfm.dll)


git-svn-id: svn://10.65.10.50/trunk@10079 c028cbd2-c16b-5b4b-a496-9718f37d4682
2002-02-26 12:19:02 +00:00

86 lines
1.8 KiB
C
Executable File

/* void _MulUnsArrByUnsArr(src1,src2,dst,m,n,tmp1)
*
* ARGUMENT
* unsigned src1[m], src2[n], dst[10];
* unsigned n,m; m<=5 n<=5
* int tmp1 where tmp1 is used as a temp multiplier for each loop
*
* DESCRIPTION
* Multiplies multiplier by multiplicand giving dst. Src1 and Src2
* are 80bit x 80bit is computed to 160bit. As each int is multiplied
* to obtain the partial product, it is added to the dst and any
* carries are added to succeeding coloumn location in the dst array.
*
* SIDE EFFECTS
* Neither src1 and src2 can have the MSB of the high-order int set
*
* RETURNS
* None.
*
* AUTHOR
* Brugnoli Giugno 1992
*
* MODIFICATIONS
*
*/
#include <stdio.h>
#include <math.h>
#include "gm.h"
#include "gmsystem.h"
extern double pow(double, double);
void _MulUnsArrByUnsArr(src1, src2, dst, m, n, tmp1)
unsigned SHORT src1[], src2[], dst[];
int n,m,tmp1;
{
int i,j;
unsigned long apdst[10];
unsigned long pdst,maxunsint;
tmp1=0;
#ifdef SH_LIB
maxunsint=1;
for (i=1;i<=BITSPERUI;i++) maxunsint*=2;
maxunsint--;
#else
maxunsint=(unsigned long)pow(2.,(double)BITSPERUI)-1;
#endif
for(i=0;i<10;i++)
{
apdst[i]=0;
}
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
pdst=(unsigned long)src1[j]*(unsigned long)src2[i];
if (pdst>maxunsint)
{
apdst[i+j+1]+=(unsigned long)(pdst>>BITSPERUI);
apdst[i+j]+=(unsigned long)(pdst&maxunsint);
}
else
{
apdst[i+j]+=(unsigned long)pdst;
}
}
}
for(i=0;i<10;i++)
{
if (apdst[i]>maxunsint)
{
apdst[i+1]+=(unsigned long)(apdst[i]>>BITSPERUI);
apdst[i]=(unsigned long)(apdst[i]&maxunsint);
}
}
for(i=0;i<10;i++)
{
dst[i]=(unsigned SHORT)apdst[i];
}
}