avx512/src/f11_260.c
// Reduce to mostly unique representative.
// All coefficients are reduced to 0 <= xi <= t
// Unique up to carries (xi == t) => (xi = 0; x[i+1] += 1);
// This is sufficient to determine if x is even or odd.
// Still pretty expensive. Used in point compression.
Reduce to mostly unique representative.
Reduce to mostly unique representative .
void narrow_partial_complete(
  residue_narrow_reduced_t *result, const residue_narrow_t * __restrict w) {
  residue_narrow_t temp;
  for (int i = 0; i < NLIMBS; ++i) {
    temp.limbs[i] = w->limbs[i] - w->limbs[10];
  }
  reduce_step_narrow(&temp, &temp);
  int gt_mask = 0;
  int lt_mask = 0;
  for (int i = 0; i < NLIMBS; ++i) {
    temp.limbs[i] = temp.limbs[i] - temp.limbs[10];
    temp.limbs[i] += 1 & gt_mask;
    temp.limbs[i] -= 1 & lt_mask;
    gt_mask = -(temp.limbs[i] > T);
    lt_mask = -(temp.limbs[i] < 0);
    temp.limbs[i] -= (T & gt_mask);
    temp.limbs[i] += (T & lt_mask);
  }
  for (int i = 0; i < NLIMBS - 1; ++i) {
    temp.limbs[i] -= temp.limbs[10];
  }
  gt_mask = 0;
  lt_mask = 0;
  for (int i = 0; i < NLIMBS_REDUCED; ++i) {
    temp.limbs[i] += 1 & gt_mask;
    temp.limbs[i] -= 1 & lt_mask;
    gt_mask = -(temp.limbs[i] > T);
    lt_mask = -(temp.limbs[i] < 0);
    temp.limbs[i] -= (T & gt_mask);
    temp.limbs[i] += (T & lt_mask);
    result->limbs[i] = temp.limbs[i];
  }
}
void narrow_partial_complete ( residue_narrow_reduced_t * result , const residue_narrow_t * __restrict w ) { residue_narrow_t temp ; for ( int i = 0 ; i < NLIMBS ; ++ i ) { temp . limbs [ i ] = w -> limbs [ i ] - w -> limbs [ 10 ] ; } reduce_step_narrow ( & temp , & temp ) ; int gt_mask = 0 ; int lt_mask = 0 ; for ( int i = 0 ; i < NLIMBS ; ++ i ) { temp . limbs [ i ] = temp . limbs [ i ] - temp . limbs [ 10 ] ; temp . limbs [ i ] += 1 & gt_mask ; temp . limbs [ i ] -= 1 & lt_mask ; gt_mask = - ( temp . limbs [ i ] > T ) ; lt_mask = - ( temp . limbs [ i ] < 0 ) ; temp . limbs [ i ] -= ( T & gt_mask ) ; temp . limbs [ i ] += ( T & lt_mask ) ; } for ( int i = 0 ; i < NLIMBS - 1 ; ++ i ) { temp . limbs [ i ] -= temp . limbs [ 10 ] ; } gt_mask = 0 ; lt_mask = 0 ; for ( int i = 0 ; i < NLIMBS_REDUCED ; ++ i ) { temp . limbs [ i ] += 1 & gt_mask ; temp . limbs [ i ] -= 1 & lt_mask ; gt_mask = - ( temp . limbs [ i ] > T ) ; lt_mask = - ( temp . limbs [ i ] < 0 ) ; temp . limbs [ i ] -= ( T & gt_mask ) ; temp . limbs [ i ] += ( T & lt_mask ) ; result -> limbs [ i ] = temp . limbs [ i ] ; } }
Reduce to mostly unique representative.
Reduce to mostly unique representative .
// This may be combined with the final reduction from a multiply.