In J80x, there's no deriv_jcalculus_ because deriv_jcalculus_ is a replacement for the d. primitive. So, in J807, you can just use that primitive.
I think the idea was that by making it a library routine instead of a primitive it would be easier for motivated J programmers to enhance it with additional functionality. (But these things take time, and thought...) Thanks, -- Raul On Mon, May 24, 2021 at 10:11 PM Thomas McGuire <tmcguir...@gmail.com> wrote: > > For those interested in Benchmarks I have split my original benchmark routine > into 2 scripts. One the Kernighan/Van Wyk benchmarks and an advanced > benchmarks script. The advanced benchmarks were taken from some of the > functionality that the Scheme language benchmarks for which I found J > implementations. > > The deriv benchmark uses Raul’s suggestion with the polynomial taken from the > data from the Scheme implementation. Itwon’t be a direct comparison to Scheme > since Scheme does a full symbolic differentiation allowing undefined variable > coefficients. In this respect the Scheme benchmark tests parsing nested > S-expressions. > > I added a QR decomposition benchmark from the QR essay and compare it to the > foreign 128!:0. I also include a Schwarz-Rutishauser QR decamp > implementation. This is translated from python code and uses for loops so on > large matrices it is very slow. I comment out the test in the test harness. > > Finally I added a matrix multiplication test given the recent discussion on > Matrix multiplication on the programming forum. The test takes the Q and R > matrices and multiplies them for timing. I added a match check on the > original matrix since the data is randomly produced. > > The scripts are available at: > https://github.com/tmcguirefl/JBenchmarks > > J902 on MacBook Pro Intel I7 quad core 2.9GHz > ADVbmarks '' > tak: 0.045548 17344 > fibN: 1e_6 13376 > rsum: 0.005007 5.02125e6 > mbrot: 0.875056 199360 > deriv: 2.7e_5 9728 > fftw: 0.000489 1.5751e6 > ifftw: 0.000717 2.09894e6 > ft: 3.4e_5 6528 > fftws: 1.8e_5 5696 > QRdata size: 700 400 > QRrec: 0.079073 3.62602e7 > QRfor: 0.090745 6.08386e7 > MMult: 0.176499 3.3557e7 > Match: 1 (not a timing, checks orig matrix matches the mult. QxR) > > Of note to the matrix multiply discussion is that a 700x400 matrix takes less > than a second on macOS 64 bit in J902. Granted the R matrix is upper > triangular but if optimizations are taking place it is under the covers, > since this is a straight J +/ . * implementation. > > On J807 I took out the deriv and the rsum due to errors (my 806 doesn’t have > the calculus lib and rsum had a stack error I assume 902 has improved > recursion) and the results: > ADVbmarks '' > tak: 0.069502 36032 > fibN: 2e_6 8512 > mbrot: 1.02267 200192 > fftw: 0.000867 1.57523e6 > ifftw: 0.000806 2.09907e6 > ft: 5e_5 6848 > fftws: 3.2e_5 7104 > QRdata size: 700 400 > QRrec: 0.08946 4.45858e7 > QRfor: 0.100718 6.13482e7 > MMult: 0.167292 4.29949e7 > Match: 1 (not a timing, checks orig matrix matches the mult. QxR) > > There appears to be an across the board speed up from 806 to 902 in > everything but matrix multiplication. That may be due to differences in the > random matrix generated for each test. > > > On May 19, 2021, at 5:22 AM, Raul Miller <rauldmil...@gmail.com> wrote: > > > > deriv_jcalculus_ does symbolic differentiation on tacit expressions. > > For example: > > > > load'math/calculus' > > (3+*:) deriv_jcalculus_ 1 > > 0"0 + +: > > 3 0 1&p. deriv_jcalculus_ 1 > > 0 2&p. > > (3+*:) deriv_jcalculus_ 1 i. 5 > > 0 2 4 6 8 > > 3 0 1&p. deriv_jcalculus_ 1 i. 5 > > 0 2 4 6 8 > > > > (The right argument to deriv_jcalculus_ is how many times to take the > > derivative, a negative argument does symbolic integration instead, > > with an integration constant of 0. But integration is a bit fussier > > than derivation, so it has less support for variant expressions.) > > > > FYI, > > > > -- > > Raul > > > > On Wed, May 19, 2021 at 4:17 AM Thomas McGuire <tmcguir...@gmail.com > > <mailto:tmcguir...@gmail.com>> wrote: > >> > >> Thanks Raul, > >> I added your ‘tail' implementation to the code and it works without issue. > >> The KJV text is listed in reverse line order in the output file. > >> > >> benchmarks '' > >> sumloop: 0.227858 8.39149e6 > >> sumj: 0.000171 1.04986e6 > >> ack: 2e_6 721472 > >> array1: 5.6e_5 1.05107e6 > >> array1t: 4.8e_5 1.05107e6 > >> string1: 0.003969 2.88634e6 > >> cat: 0.01474 2.51685e7 > >> wc: 0.295076 1.58152e8 > >> tail: 0.065197 3.77133e7 > >> sum1: 0.12709 4.04989e7 > >> sum1j: 0.000547 1.18086e6 > >> > >> I have placed the code on GitHub: > >> https://github.com/tmcguirefl/JBenchmarks > >> > >> The scheme folks have put together a large set of benchmarks at: > >> https://www.ccs.neu.edu/home/will/Twobit/benchmarksAboutR6.html > >> > >> When time permits I will go through them and implement the ones that would > >> be J appropriate (some do symbolic differentiation which would be > >> nontrivial for me to code into J). > >> > >> Tom McGuire > >> > >>> On May 18, 2021, at 9:04 PM, Raul Miller <rauldmil...@gmail.com> wrote: > >>> > >>> Here's the tail benchmark written in J: > >>> > >>> tail=: 4 : 0 > >>> (;|.<;.2 freads x) fwrites y > >>> ) > >>> > >>> This is based on my reading of the C implementation of the tail > >>> benchmark vs the cat benchmark, and on the cat benchmark in this J > >>> implementation, except that I have failed to reproduce a bug in the C > >>> implementation which shows up when the file contains very long lines > >>> and instead I have assumed that the file ends in a newline (which is a > >>> valid assumption for the gutenberg kjv bible). > >>> > >>> Let me know if you think I have made a mistake here. > >>> > >>> Thanks, > >>> > >>> -- > >>> Raul > >>> > >>> On Tue, May 18, 2021 at 7:02 PM Thomas McGuire <tmcguir...@gmail.com > >>> <mailto:tmcguir...@gmail.com><mailto:tmcguir...@gmail.com > >>> <mailto:tmcguir...@gmail.com>>> wrote: > >>>> > >>>> I was going over Devon McCormick's notes from the latest NYCJUG meeting. > >>>> There was a discussion about Benchmarks with an example of the > >>>> Kernighan/Van Wyk benchmarks in LISP/Scheme. Devon had made the comment > >>>> that for most things people use J for that correctness overshadowed > >>>> performance. > >>>> > >>>> The K/VW benchmarks were originally made for C and seem to test looping > >>>> controls and memory allocation which at a time of low memory > >>>> minicomputers and PCs, coupled with multiple available C compilers, made > >>>> the benchmarks a nice way of comparing compiler implementations as well > >>>> as new processor speed. > >>>> > >>>> However it seemed like a simple project to exercise my J programming > >>>> skills with so I have attached the program to this email. > >>>> > >>>> Note: you will need to download the King James Version of the Bible from > >>>> project Guttenburg (not included with the attachment) to run the full > >>>> benchmarks. I also created my own file of floating point numbers to sum > >>>> (routine to create a file of random floats is included). I have added > >>>> some routines to accomplish similar functionality in the way I would do > >>>> it in J (at least for my mere mortal understanding of J). > >>>> > >>>> Running on my mac book pro (2016 with 2.9 Ghz Quad core I7) the results > >>>> are: > >>>> > >>>> benchmarks '' > >>>> sumloop: 0.214383 8.39149e6 > >>>> sumj: 0.000162 1.04986e6 > >>>> ack: 4e_6 721472 > >>>> array1: 0.000578 1.05107e6 > >>>> array1t: 2.5e_5 1.05107e6 > >>>> string1: 0.003237 2.88634e6 > >>>> cat: 0.014234 2.51685e7 > >>>> wc: 0.302383 1.58152e8 > >>>> sum1: 0.124006 4.04989e7 > >>>> sum1j: 0.000956 1.18086e6 > >>>> > >>>> thought I would share > >>>> > >>>> Tom McGuire > >>>> ---------------------------------------------------------------------- > >>>> For information about J forums see http://www.jsoftware.com/forums.htm > >>>> <http://www.jsoftware.com/forums.htm><http://www.jsoftware.com/forums.htm > >>>> <http://www.jsoftware.com/forums.htm>> > >>> ---------------------------------------------------------------------- > >>> For information about J forums see http://www.jsoftware.com/forums.htm > >>> <http://www.jsoftware.com/forums.htm><http://www.jsoftware.com/forums.htm > >>> <http://www.jsoftware.com/forums.htm>> > >> ---------------------------------------------------------------------- > >> For information about J forums see http://www.jsoftware.com/forums.htm > >> <http://www.jsoftware.com/forums.htm> > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > > <http://www.jsoftware.com/forums.htm> > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm