27 unsigned int mask = 0x00000001;
28 for(
int i=31;
i>=0;
i--)
30 unsigned int m =
mask <<
i;
50 unsigned int mask = 0x7f800000;
56 unsigned int mask = 0x007fffff;
65 unsigned int mask=0x7F800000;
84 short int biasArray[6] = {116,120,118,116,116,102};
87 double T[5]={0.2,0.5,100.0,100.0,20000.0};
176 double L[5][5],C0[5][5],
C[5][5];
186 C[j][
i]=C0[
i][j]=C0[j][
i]=
C[
i][j];
190 memset(&L[0][0],0,
sizeof(L));
199 memset(&
S[0][0],0,
sizeof(
S));
201 for(j=0;j<=
i;j++)
S[
i][j]=L[
i][j];
203 std::vector<FloatRep> vecFR;
211 char sign=(
S[
i][j]<0)?1:0;
217 std::vector<unsigned short> vShorts;
226 unsigned int buffer = 0x00000000;
253 double L[5][5],
C[5][5];
257 std::vector<FloatRep> vecFR;
260 std::vector<unsigned short> vShorts;
264 for (
unsigned int ii :
src) {
265 unsigned short s1,
s2;
267 s1 = (
unsigned short)((0xFFFF0000 & ii) >> 16);
268 s2 = (
unsigned short)(0x0000FFFF & ii);
269 vShorts.push_back(
s1);
271 vShorts.push_back(
s2);
274 if(!
restoreFR(vShorts,vecFR))
return false;
277 memset(&
S[0][0],0,
sizeof(
S));
281 if(fIt==vecFR.end())
break;
282 S[
i][j]=(*fIt).restore();
286 memset(&L[0][0],0,
sizeof(L));
288 for(j=0;j<=
i;j++) L[
i][j]=
S[
i][j];
294 C[
i][j]+=L[
i][
k]*L[j][
k];
303 for(
i=0;
i<5;
i++)
for(j=0;j<=
i;j++)
dest.push_back(
C[
i][j]);
310 unsigned short buf=0x0000;
315 std::cout<<
"Requested mantissa reduction is too large: 23->"<<nMantLength<<std::endl;
318 std::vector<FloatRep>::const_iterator fIt;
332 unsigned short int ex=(*fIt).exponent();
333 unsigned int mant=(*fIt).mantissa();
345 if((ex!=0)&&(mant!=0))
347 if((ex<bias)||(ex-bias>
limit))
362 i2[0]=(*trIt).m_nd1;i2[1]=(*trIt).m_nd2;
368 buf = buf | ((
e<<12) & 0xF000);
369 if((
src[i2[0]].exponent()==0)&&(
src[i2[0]].mantissa()==0))
371 e=
src[i2[0]].exponent();
380 buf = buf | ((
e<<6) & 0x07C0);
381 if((
src[i2[1]].exponent()==0)&&(
src[i2[1]].mantissa()==0))
384 e=
src[i2[1]].exponent();
392 buf = buf | (
e & 0x001F);
399 unsigned int nPacked=0;
400 int nFreeBits=0,nBitsToStore=0,nBufferLength=0;
401 unsigned int srcBuffer=0x00000000;
403 while (nPacked<=
src.size()+1)
420 if(fIt==
src.end())
break;
422 srcBuffer=((*fIt).mantissa()<<9);
424 nBitsToStore=nMantLength;
426 int Np=(nBitsToStore>nFreeBits)?nFreeBits:nBitsToStore;
429 slice = (
slice >> (32-nFreeBits)) & 0x0000FFFF;
433 srcBuffer = srcBuffer << Np;
446 int i,nRestored,nFreeBits,nBitsToStore;
447 unsigned short buf=0x0000;
448 unsigned int destBuffer=0x00000000;
449 std::vector<unsigned short>::const_iterator uIt(
src.begin());
458 for(;uIt!=
src.end();++uIt)
464 char s=((buf & 0x0800)==0)?0:1;
466 s=((buf & 0x0020)==0)?0:1;
468 unsigned short e = ((buf & 0xF000) >> 12);
470 e = ((buf & 0x07C0) >> 6);
477 if(
i<5)
return false;
491 dest[nRestored-1].mantissa(destBuffer);
494 destBuffer=0x00000000;
495 nFreeBits=nMantLength;
499 if(uIt==
src.end())
break;
506 nBitsToStore=16;buf=(*uIt);
508 int Np=(nFreeBits>nBitsToStore) ? nBitsToStore : nFreeBits;
509 unsigned int tmp = buf;
511 buf = (
unsigned int)((buf << Np) & 0x0000FFFF);
515 destBuffer = destBuffer << Np;
517 destBuffer = destBuffer |
tmp;