No reply?
So how do other people find the bottlenecks in their code if they don't
use jpm?
I know the query wasn't very specific. Sorry.
Thanks,
Mike
On 08/04/2021 18:55, Michael Day wrote:
Not really about this beta, but Henry had promised a repair of
something wrong with
jmf in beta-g.
(Spoiler alert - the function is attempting to solve Euler Project
Problem 754! FWIW, function
"A" is considerably slower than Pari GP for smallish problems, but is
5-6 times faster than GP at
N=100000 ! Probably wrong approach as it looks like taking ~10 hours
on this laptop for the
required problem size, N = 1e8. )
I've been getting this sort of trouble with jmf for some years, so
it's unlikely to be the fault of
J903 beta-h as such. I doubt if the exact specification of "A" is
necessary - this happens for me
when I'm trying to catch bottlenecks in functions that need to be
speeded up. I can provide the
auxiliary functions if required.
NB. trying to find bottlenecks in "A":
start_jpm_ 1000000000
17857142
timer'<.A 10000'
+---------+---------+
|3.7741699|517055464|
+---------+---------+
showdetail_jpm_ 'A'
recorded all lines
used and max record count: 3,389,287 17,857,142
|index error: getdetail1
| lns=.sort(len#replno) {~(;repsno)i.stm
NB. Listing of A in terminal session - I've added NB.s for this message
A NB. left argument is a modulus if non-zero
3 : 0 NB. y is the problem-size
M A y
:
NB. echo =. [
if. m =. x do.
to =. m mvpower NB. define ^ * + % for modular arithemtic
by =. m mtimes
add =. m madd
div =. m mdivide
else.
to =. <.@^ NB. or use standard ^ * + % if not finite
by =. *
add =. +
div =. %
end.
N =. y
mutab =. mu i. >: N NB. table of moebius function results e. _1 0 or 1
NB. echo
facs =. 0 fpc N, m NB. calculate a table of factorials, modulo m
if need
NB. echo
dtod =. 0, d to"0 d =. >:i.N NB. precalc d^d, modulo m if needed
NB. echo
facs =. facs div"0 dtod
if. m do.
invf =. facs mvpowerv m - 0 2
else.
invf =. %facs
end.
facs =. facs,: invf NB. 2-row table of (!d)*d^d and its inverse
NB. echo x: facs
if. 100000 <: N do.
smoutput 'done setting up tables'
end.
tn =. t =. 1
for_n. 2}.i.N+1 do.
d =. }. /:~ allfactors n NB. Roger Hui's idiom
tn =. n to 5 p: n NB. n^phi(n), using totient/Euler's phi
mud =. mutab {~ n <.@% d
ok =. 1 = | mud
d =. ok#d
mud =. 0 0 1 {~ ok#mud
tn =. tn by by/ facs{~ mud,each d NB. tn **/ ((!d)/d^d)^mu(n\d)
NB. echo n; x:tn
t =. t by tn
end.
t
)
Thanks again,
Mike
--
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm