Lines Matching refs:used
92 #define MP_ISZERO(a) (((a)->used == 0) ? MP_YES : MP_NO)
119 a->used = 0;
168 if (a->alloc < a->used + b) {
169 if ((res = mp_grow(a, a->used + b)) != MP_OKAY) {
174 /* increment the used by the shift amount then copy upwards */
175 a->used += b;
178 top = a->dp + a->used - 1;
181 bottom = a->dp + a->used - 1 - b;
187 for (x = a->used - 1; x >= b; x--) {
198 * This is used to ensure that leading zero digits are
199 * trimmed and the leading "used" digit will be non-zero
206 /* decrease used while the most significant digit is
209 while (a->used > 0 && a->dp[a->used - 1] == 0) {
210 a->used -= 1;
212 /* reset the sign flag if used == 0 */
213 if (a->used == 0) {
233 if (b->alloc < a->used) {
234 if ((res = mp_grow(b, a->used)) != MP_OKAY) {
239 memcpy(b->dp, a->dp, a->used * sizeof(*b->dp));
240 if (b->used > a->used) {
241 memset(&b->dp[a->used], 0x0, (b->used - a->used) * sizeof(*b->dp));
244 /* copy used count and sign */
245 b->used = a->used;
264 if (c->alloc < (int)(c->used + b/DIGIT_BIT + 1)) {
265 if ((res = mp_grow(c, c->used + b / DIGIT_BIT + 1)) != MP_OKAY) {
294 for (x = 0; x < c->used; x++) {
308 c->dp[c->used++] = carry;
338 a->used += 1;
352 if (a->used == 0) {
357 r = (a->used - 1) * DIGIT_BIT;
360 for (q = a->dp[a->used - 1]; q > ((mp_digit) 0) ; r++) {
374 if (a->used > b->used) {
378 if (a->used < b->used) {
383 tmpa = a->dp + (a->used - 1);
386 tmpb = b->dp + (a->used - 1);
389 for (n = 0; n < a->used; ++n, --tmpa, --tmpb) {
434 /* set the used to zero, allocated digits to the default precision
436 a->used = 0;
449 memset(a->dp, 0x0, a->used * sizeof(*a->dp));
456 a->alloc = a->used = 0;
512 a->used = 0;
543 if (a->used > b->used) {
544 min = b->used;
545 max = a->used;
548 min = a->used;
549 max = b->used;
560 /* get old used digit count and set new one */
561 olduse = c->used;
562 c->used = max + 1;
612 if (olduse > c->used) {
613 memset(tmpc, 0x0, (olduse - c->used) * sizeof(*c->dp));
628 min = b->used;
629 max = a->used;
637 olduse = c->used;
638 c->used = max;
678 /* clear digits above used (since we may not have grown result above) */
679 if (olduse > c->used) {
680 memset(tmpc, 0x0, (olduse - c->used) * sizeof(*a->dp));
734 /* if b > used then simply zero it and return */
735 if (a->used <= b) {
750 memmove(a->dp, &a->dp[b], (a->used - b) * sizeof(*a->dp));
751 memset(&a->dp[a->used - b], 0x0, b * sizeof(*a->dp));
754 a->used -= b;
767 if (c->alloc < a->used + 1) {
768 if ((res = mp_grow(c, a->used + 1)) != MP_OKAY) {
773 /* get the original destinations used count */
774 olduse = c->used;
789 for (ix = 0; ix < a->used; ix++) {
807 /* set used count */
808 c->used = a->used + 1;
872 if (b >= (int) (a->used * DIGIT_BIT)) {
883 for (x = (b / DIGIT_BIT) + ((b % DIGIT_BIT) == 0 ? 0 : 1); x < c->used; x++) {
946 tmpc = c->dp + (c->used - 1);
950 for (x = c->used - 1; x >= 0; x--) {
1007 if ((res = mp_init_size(&q, a->used + 2)) != MP_OKAY) {
1010 q.used = a->used + 2;
1046 /* note hac does 0 based, so if used==5 then its 0,1,2,3,4, e.g. use 4 */
1047 n = x.used - 1;
1048 t = y.used - 1;
1067 if (i > x.used) {
1098 t1.used = 2;
1107 t2.used = 3;
1144 x.sign = x.used == 0 ? MP_ZPOS : a->sign;
1205 a->used = (a->dp[0] != 0) ? 1 : 0;
1215 if (b->alloc < a->used) {
1216 if ((res = mp_grow(b, a->used)) != MP_OKAY) {
1221 oldused = b->used;
1222 b->used = a->used;
1227 tmpa = a->dp + b->used - 1;
1230 tmpb = b->dp + b->used - 1;
1234 for (x = b->used - 1; x >= 0; x--) {
1246 tmpb = b->dp + b->used;
1247 for (x = b->used; x < oldused; x++) {
1266 if (a->used > 1) {
1616 /* determines if reduce_2k_l can be used */
1622 if (a->used == 0) {
1624 } else if (a->used == 1) {
1626 } else if (a->used > 1) {
1628 for (iy = ix = 0; ix < a->used; ix++) {
1633 return (iy >= (a->used/2)) ? MP_YES : MP_NO;
1657 /* set the used count of where the bit will go */
1658 a->used = b / DIGIT_BIT + 1;
1674 if ((res = mp_2expt(a, b->used * 2 * DIGIT_BIT)) != MP_OKAY) {
1687 if (b->alloc < a->used + 1) {
1688 if ((res = mp_grow(b, a->used + 1)) != MP_OKAY) {
1693 oldused = b->used;
1694 b->used = a->used;
1707 for (x = 0; x < a->used; x++) {
1727 ++(b->used);
1733 tmpb = b->dp + b->used;
1734 for (x = b->used; x < oldused; x++) {
1754 if ((res = mp_init_size(&q, a->used)) != MP_OKAY) {
1758 q.used = a->used;
1761 for (ix = a->used - 1; ix >= 0; ix--) {
1820 B = MIN(a->used, b->used) / 3;
2078 * Note that a1b1 and a0b0 are used twice and only need to be
2105 B = MIN(a->used, b->used);
2114 if (mp_init_size(&x1, a->used - B) != MP_OKAY) {
2120 if (mp_init_size(&y1, b->used - B) != MP_OKAY) {
2134 x0.used = y0.used = B;
2135 x1.used = a->used - B;
2136 y1.used = b->used - B;
2156 for (x = B; x < a->used; x++) {
2161 for (x = B; x < b->used; x++) {
2263 pa = MIN(digs, a->used + b->used);
2273 ty = MIN(b->used-1, ix);
2281 while (tx++ < a->used
2283 iy = MIN(a->used-tx, ty+1);
2299 olduse = c->used;
2300 c->used = pa;
2321 * The fast multiplier can be used if the output will
2326 can_use_fast_column_array(int ndigits, int used)
2329 used < (1 << (unsigned)((CHAR_BIT * sizeof(mp_word)) - (2 * DIGIT_BIT))));
2351 if (can_use_fast_column_array(digs, MIN(a->used, b->used))) {
2358 t.used = digs;
2361 pa = a->used;
2367 pb = MIN(b->used, digs - ix);
2370 /* copy of the digit from a used within the nested loop */
2417 if (MIN(a->used, b->used) >= TOOM_MUL_CUTOFF) {
2419 } else if (MIN(a->used, b->used) >= KARATSUBA_MUL_CUTOFF) {
2424 int digs = a->used + b->used + 1;
2426 if (can_use_fast_column_array(digs, MIN(a->used, b->used))) {
2429 res = basic_multiply_partial_lower(a, b, c, (a)->used + (b)->used + 1);
2432 c->sign = (c->used > 0) ? neg : MP_ZPOS;
2440 * This is used in the Barrett reduction since for one of the multiplications
2453 pa = a->used + b->used;
2461 pa = a->used + b->used;
2468 ty = MIN(b->used-1, ix);
2476 while (tx++ < a->used && ty-- >= 0) { ... }
2478 iy = MIN(a->used-tx, ty+1);
2493 olduse = c->used;
2494 c->used = pa;
2531 if (can_use_fast_column_array(a->used + b->used + 1, MIN(a->used, b->used))) {
2535 if ((res = mp_init_size(&t, a->used + b->used + 1)) != MP_OKAY) {
2538 t.used = a->used + b->used + 1;
2540 pa = a->used;
2541 pb = b->used;
2587 int res, um = m->used;
2736 B = a->used / 3;
2948 B = a->used;
2957 if (mp_init_size(&x1, a->used - B) != MP_OKAY) {
2961 if (mp_init_size(&t1, a->used * 2) != MP_OKAY) {
2964 if (mp_init_size(&t2, a->used * 2) != MP_OKAY) {
2970 if (mp_init_size(&x1x1, (a->used - B) * 2) != MP_OKAY) {
2975 memcpy(x1.dp, &a->dp[B], (a->used - B) * sizeof(*x1.dp));
2977 x0.used = B;
2978 x1.used = a->used - B;
3056 pa = a->used + a->used;
3074 ty = MIN(a->used-1, ix);
3082 while (tx++ < a->used && ty-- >= 0) { ... }
3084 iy = MIN(a->used-tx, ty+1);
3113 olduse = b->used;
3114 b->used = a->used+a->used;
3145 pa = a->used;
3150 /* default used is maximum possible size */
3151 t.used = 2*pa + 1;
3214 if (a->used >= TOOM_SQR_CUTOFF) {
3217 } else if (a->used >= KARATSUBA_SQR_CUTOFF) {
3221 if (can_use_fast_column_array(a->used + a->used + 1, a->used)) {
3274 /* create mu, used for Barrett reduction */
3345 digidx = X->used - 1;
3368 * does lower the # of trivial squaring/reductions used
3461 if (a->used < 2) {
3468 for (ix = 1; ix < a->used; ix++) {
3480 /* determines if mp_reduce_2k can be used */
3487 if (a->used == 0) {
3490 if (a->used == 1) {
3493 if (a->used > 1) {
3595 /* get old used count */
3596 olduse = x->used;
3599 if (x->alloc < n->used + 1) {
3600 if ((res = mp_grow(x, n->used + 1)) != MP_OKAY) {
3618 /* copy the digits of a into W[0..a->used-1] */
3619 for (ix = 0; ix < x->used; ix++) {
3623 /* zero the high words of W[a->used..m->used*2] */
3624 for (; ix < n->used * 2 + 1; ix++) {
3632 for (ix = 0; ix < n->used; ix++) {
3654 * first m->used words of W[] have the carries fixed
3668 for (iy = 0; iy < n->used; iy++) {
3693 for (; ix <= n->used * 2 + 1; ix++) {
3708 _W = W + n->used;
3710 for (ix = 0; ix < n->used + 1; ix++) {
3715 * m->used+1 we'll have to clear the digits
3722 /* set the max used and clamp */
3723 x->used = n->used + 1;
3744 /* can the fast reduction [comba] method be used?
3750 digs = n->used * 2 + 1;
3751 if (can_use_fast_column_array(digs, n->used)) {
3761 x->used = digs;
3763 for (ix = 0; ix < n->used; ix++) {
3790 for (iy = 0; iy < n->used; iy++) {
3813 /* at this point the n.used'th least
3816 * right by n.used digits and the
3820 /* x = x/b**n.used */
3822 rshift_digits(x, n->used);
3873 m = n->used;
3907 for (i = m + 1; i < x->used; i++) {
4017 if (b->used > 1) {
4018 if ((res = mp_2expt(a, (b->used - 1) * DIGIT_BIT + bits - 1)) != MP_OKAY) {
4096 if (can_use_fast_column_array(P->used + P->used + 1, P->used)) {
4171 digidx = X->used - 1;
4194 * does lower the # of trivial squaring/reductions used
4268 /* fixup result if Montgomery reduction is used
4362 /* reverse an array, used for radix code */
4437 if ((res = mp_init_size(&q, a->used)) != MP_OKAY) {
4441 q.used = a->used;
4444 for (ix = a->used - 1; ix >= 0; ix--) {
4545 if (c->alloc < a->used + 1) {
4546 if ((res = mp_grow(c, a->used + 1)) != MP_OKAY) {
4552 if (a->sign == MP_NEG && (a->used > 1 || a->dp[0] >= b)) {
4568 /* old number of used digits in c */
4569 oldused = c->used;
4590 for (ix = 1; ix < a->used; ix++) {
4600 c->used = a->used + 1;
4603 c->used = 1;
4606 if (a->used == 1) {
4635 if (c->alloc < a->used + 1) {
4636 if ((res = mp_grow(c, a->used + 1)) != MP_OKAY) {
4656 oldused = c->used;
4661 if ((a->used == 1 && a->dp[0] <= b) || a->used == 0) {
4662 if (a->used == 1) {
4671 c->used = 1;
4675 c->used = a->used;
4683 for (ix = 1; ix < a->used; ix++) {
4715 for (x = 0; x < a->used && a->dp[x] == 0; x++) {
5407 ndigits = a->used;
5410 ndigits = b->used;
5413 ad = (i > a->used) ? 0 : a->dp[i];
5414 bd = (i > b->used) ? 0 : b->dp[i];
5630 rnd->used += 1;
5633 rnd->dp[rnd->used - 1] |= (((mp_digit)1)<<((mp_digit)DIGIT_BIT));
5636 rnd->dp[rnd->used - 1] |= (((mp_digit)1)<<((mp_digit)DIGIT_BIT));
5637 rnd->dp[rnd->used - 1] |= (((mp_digit)1)<<((mp_digit)(DIGIT_BIT - 1)));
5710 if (a == NULL || n < 0 || n >= a->used * DIGIT_BIT) {