Faster _fmpz_vec_scalar_divexact_ui #2371
                
     Merged
            
            
          
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Speed up
_fmpz_vec_scalar_divexact_si,_fmpz_vec_scalar_divexact_uiand small-divisor_fmpz_vec_scalar_divexact_fmpzby precomputing an inverse mod2^FLINT_BITS. Also special case powers of two.This probably will not make a measurable difference on any macrobenchmarks, because the standard use case is to divide out a GCD which was more expensive to compute in the first place. However, I thought I'd put this code in as a template for doing divexact with precomputed inverses; other functions like
fmpz_mat_ffluand_fmpz_poly_interpolate_exact_newtoncould use the same trick in the future.Multi-limb preinverted divexact should also be done some day but it's a lot more work.
Profile code output: