view test/bug-53579.tst @ 31107:bbb59cc6698c stable

factor.m: Performance tweak to avoid division in certain cases factor.m: For large numbers where only one factor lies outside the fast first round of divisions, check if it is prime before calling primes () trying to factorize it. This is up to 8000X faster for such numbers, and for an "average" input it gives a 22% to 40% speedup over a large number of trials.
author Arun Giridhar <arungiridhar@gmail.com>
date Sat, 25 Jun 2022 16:40:36 -0400
parents 34617dd78f02
children 332a6ccac881
line wrap: on
line source

%!function [raa, rbb, igaa, igbb] = sub1 (aa, bb)
%!  global aa bb
%!  aa = 1;
%!  raa = aa;
%!  rbb = bb;
%!  igaa = isglobal ("aa");
%!  igbb = isglobal ("bb");
%!endfunction

%!test <*53579>
%! global aa bb
%! assert (isglobal ("aa"));
%! assert (isglobal ("bb"));
%! aa = 3;
%! xx = 5;
%! [raa, rbb, igaa, igbb] = sub1 (aa, xx);
%! assert (raa, 1);
%! assert (rbb, []);
%! assert (igaa);
%! assert (igbb);
%! assert (xx, 5);
%! clear -global aa bb;  # cleanup after test