/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
staticdouble
mod(double x, double oneoverm, double m)
{ return x - m * floor(x * oneoverm);
}
#endif
staticvoid
cleanup(double *dt, int from, int tlen)
{ int i; double tmp, tmp1, x, x1;
tmp = tmp1 = Zero; /* original code ** for(i=2*from;i<2*tlen-2;i++) { x=dt[i]; dt[i]=lower32(x,Zero)+tmp1; tmp1=tmp; tmp=upper32(x); } dt[tlen-2]+=tmp1; dt[tlen-1]+=tmp;
**end original code ***/ /* new code ***/ for (i = 2 * from; i < 2 * tlen; i += 2) {
x = dt[i];
x1 = dt[i + 1];
dt[i] = lower32(x, Zero) + tmp;
dt[i + 1] = lower32(x1, Zero) + tmp1;
tmp = upper32(x);
tmp1 = upper32(x1);
} /** end new code **/
}
void
conv_d16_to_i32(unsignedint *i32, double *d16, longlong *tmp, int ilen)
{ int i; longlong t, t1, a, b, c, d;
t1 = 0;
a = (longlong)d16[0];
b = (longlong)d16[1]; for (i = 0; i < ilen - 1; i++) {
c = (longlong)d16[2 * i + 2];
t1 += (unsignedint)a;
t = (a >> 32);
d = (longlong)d16[2 * i + 3];
t1 += (b & 0xffff) << 16;
t += (b >> 16) + (t1 >> 32);
i32[i] = (unsignedint)t1;
t1 = t;
a = c;
b = d;
}
t1 += (unsignedint)a;
t = (a >> 32);
t1 += (b & 0xffff) << 16;
i32[i] = (unsignedint)t1;
}
void
conv_i32_to_d32(double *d32, unsignedint *i32, int len)
{ int i;
#pragma pipeloop(0) for (i = 0; i < len; i++)
d32[i] = (double)(i32[i]);
}
void
conv_i32_to_d16(double *d16, unsignedint *i32, int len)
{ int i; unsignedint a;
#pragma pipeloop(0) for (i = 0; i < len; i++) {
a = i32[i];
d16[2 * i] = (double)(a & 0xffff);
d16[2 * i + 1] = (double)(a >> 16);
}
}
void
conv_i32_to_d32_and_d16(double *d32, double *d16, unsignedint *i32, int len)
{ int i = 0; unsignedint a;
#pragma pipeloop(0) #ifdef RF_INLINE_MACROS for (; i < len - 3; i += 4) {
i16_to_d16_and_d32x4(&TwoToMinus16, &TwoTo16, &Zero,
&(d16[2 * i]), &(d32[i]), (float *)(&(i32[i])));
} #endif for (; i < len; i++) {
a = i32[i];
d32[i] = (double)(i32[i]);
d16[2 * i] = (double)(a & 0xffff);
d16[2 * i + 1] = (double)(a >> 16);
}
}
void
adjust_montf_result(unsignedint *i32, unsignedint *nint, int len)
{ longlong acc; int i;
if (i32[len] > 0)
i = -1; else { for (i = len - 1; i >= 0; i--) { if (i32[i] != nint[i]) break;
}
} if ((i < 0) || (i32[i] > nint[i])) {
acc = 0; for (i = 0; i < len; i++) {
acc = acc + (unsignedlonglong)(i32[i]) - (unsignedlonglong)(nint[i]);
i32[i] = (unsignedint)acc;
acc = acc >> 32;
}
}
}
/* ** the lengths of the input arrays should be at least the following: ** result[nlen+1], dm1[nlen], dm2[2*nlen+1], dt[4*nlen+2], dn[nlen], nint[nlen] ** all of them should be different from one another **
*/ void
mont_mulf_noconv(unsignedint *result, double *dm1, double *dm2, double *dt, double *dn, unsignedint *nint, int nlen, double dn0)
{ int i, j, jj; int tmp; double digit, m2j, nextm2j, a, b; double *dptmp, *pdm1, *pdm2, *pdn, *pdtj, pdn_0, pdm1_0;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.