This approach, from my A-level Maths perhaps, seems far too simple compared
to that of the article, but works, on this iPad running J701 (no, it can’t run
Ian’s J902!), including when dbho or dblo throws a domain error for, eg,
dividing order 50 by order 30. I haven’t tried in J903 on the l
Just checked on the laptop running J903:
Performance not too bad for largish orders, even with extended type,
albeit only
binomial coefficients:
ts'1000 diva&binc 20' NB. presumably overflow in binc
|NaN error: diva
| d=.(ly{.x) -&}.r*y
ts'1000x diva&binc 20x'
0.2399954 1570560
Very nice, thank you.
This took my code from me using jbreak during a division because I was
tired of starting at the hourglass to having that operation complete
nearly instantly.
Thanks again,
--
Raul
On Sun, Feb 20, 2022 at 6:31 AM 'Mike Day' via Programming
wrote:
>
> This approach, from
On my machine, I get
100 timespacex '1000x binc 500x'
0.101916 957376
100 timespacex '1, */\ 1000x (- % >:@]) i.500x'
0.00247977 680320
Am 20.02.22 um 13:30 schrieb 'Michael Day' via Programming:
ts'1000x div&binc 500x'
2.1598005 4815264
--
--
mail written using
Bear in mind my later comments about performance on this laptop.
Either extended arithmetic or other tricks to deal with high exponents
are necessary in some cases. And, of course, I didn't deal with edge
effects. I've dealt with one such, introducing assert. , ie
assert. 2 <: n =. 2 + x -&
For some reason, when I was searching for jsoftware.com content on
polynomial division, the search did not turn up Pascal Jasmin's
article. It looks like Jasmin was focusing on speeding up extended
precision arithmetic, but I'll have to spend some time studying what
he wrote there.
Meanwhile, I'm
I wrote binc as a monad, just as a quick way of conjuring up
sets of binomial coefficients:
binc 5
1 5 10 10 5 1
3 binc 5 NB. does work, but not as intended!
1 3 3 1 0 0
NB. as does its commute:
5 binc 3
1 5 10 10
... but again, not as I intended.
div is what does the division; div&b
Pas grand' chose - the writer evidently meant to enter
E =. 1 5 10 10 4 7
]q =. E dbho c
1 3 3 1
]r =. E - c t q
0 0 0 0 2 3
- or perhaps with capital Q & R rather than q & r -
... but it's clear enough with a bit of insight!
Cheers,
Mike
On 20/02/2022 16:15, Raul Miller wrote:
For
For what it's worth, here's what I was focusing on:
http://rosettacode.org/wiki/Cyclotomic_polynomial#J
As you can see, I altered your polynomial division algorithm --
there's enough zeros in the polynomials I was working with, there,
that iterating through them seemed unwise.
If there's any oth
Oh, yes... thanks... a line got lost, at least in my translation,
among other things.
Thanks again,
--
Raul
On Sun, Feb 20, 2022 at 11:34 AM 'Michael Day' via Programming
wrote:
>
> Pas grand' chose - the writer evidently meant to enter
>
> E =. 1 5 10 10 4 7
> ]q =. E dbho c
> 1 3 3
I suppose dyad |. !0 is better than dyad }. by keeping the result in
place.
Anyway, although I agree that it seems attractive to ignore those zeros,
your get-around doesn't seem to apply!!! - unless I'm missing something.
I embedded an echo:
...
if. 0={.y do. j=. j-i=. 0 i.~ 0=y
echo '0=
Oh, bleah... of course.
y does not change. So that should be a test on {.x -- and that reveals
that I was using the wrong values throughout that section of code.
Here's a fixed version:
pDiv=: {{
q=. $j=. 2 + x - y
'x y'=. x,:y
while. j=. j-1 do.
if. 0={.x do. j=. j-<:i=. 0 i.~ 0=x
12 matches
Mail list logo