Re: [Jprogramming] arrayfire addon updated

2022-01-27 Thread 'Pascal Jasmin' via Programming
thank you Eric, I see the point that making dyads would lose access to options.  Its a matter of opinion as to whether the options are useful enough to "need them".  My opinion is that they are not, and we/users who need to optimize calls with options could "easily" make a "linear cover

Re: [Jprogramming] arrayfire addon updated

2022-01-27 Thread 'Pascal Jasmin' via Programming
instructions in   man_jaf_ 'bench' mptime 600 gets faster results on    init_jaf_ 'cpu'  and    init_jaf_ 'cuda' on my system.  But that is full round trip to J execution. If you are keeping results on gpu for further processing, then its faster for all matrix sizes as arrayfire structures. 

[Jprogramming] Arrayfire addon

2022-01-27 Thread Mike Powell
This looks really interesting. My first look at this was mp_bench.ijs example. This produces (on my iMac): ┌┬┐ │ step │ millis │ ├┼┤ │mp │3260│ ├┼┤ │acreate │708 │ ├┼┤ │bcreate │474 │ ├┼┤ │matmul

Re: [Jprogramming] arrayfire addon updated

2022-01-27 Thread Ric Sherlock
Thanks Eric - this looks very promising! I managed to get it installed & running on WSL although I needed to amend the instructions on the arrayfire website somewhat so I could write to /etc/ld.so.conf.d/ Any thoughts on where the switchover point is at which Arrayfire is compelling relative to

Re: [Jprogramming] arrayfire addon updated

2022-01-27 Thread bill lam
I think af addon doesn't need include or lib files to run. If dll files only are mandatory, can these windows dll be downloaded from j software website and put into a folder under the af addon? On Fri, 28 Jan 2022 at 5:08 AM Eric Iverson wrote: > arrayfire addon updated > > * improved init > >

Re: [Jprogramming] arrayfire addon updated

2022-01-27 Thread 'Mike Day' via Programming
I did manage to install it eventually! Other Windows users might wish to know that I found I needed to load J as an administrator to avoid failure. Thanks, Mike Sent from my iPad > On 27 Jan 2022, at 21:07, Eric Iverson wrote: > > arrayfire addon updated > > * improved init > > * support

[Jprogramming] arrayfire addon updated

2022-01-27 Thread Eric Iverson
arrayfire addon updated * improved init * support for apple m1 * Pascal's idea that integer lists are better than boxed lists this required changes in several of the tutorial examples for example, q=. af_matmul_jaf_ af1;af2 was changed to q=. af_matmul_jaf_ af1,af2 * J like dyad

Re: [Jprogramming] ArrayFire addon

2022-01-27 Thread Eric Iverson
Bill's change will be pushed to addons later today. I will post when the new version is available. On Thu, Jan 27, 2022 at 1:11 PM Andreas Lagerås wrote: > Hi, > > May I ask how you updated it to work with the homebrew arrayfire, or will > that be fixed in a future version? > > Best regards, >

Re: [Jprogramming] Find nth duplicate in vector

2022-01-27 Thread Raul Miller
Well, ... the implementation posted by xash is very nice, but in http://jsoftware.com/pipermail/programming/2022-January/059790.html Pawel Jakubas specified that the value appears first, and the index appears second, and that the indices start with 1 for the first value. Also, somewhere along the

Re: [Jprogramming] ArrayFire addon

2022-01-27 Thread Andreas Lagerås
Hi, May I ask how you updated it to work with the homebrew arrayfire, or will that be fixed in a future version? Best regards, /Andreas Den tors 27 jan. 2022 kl 15:23 skrev bill lam : > I have made a minor update to the addon to allow use arrayfire installed > via homebrew. > > on apple m1 >

Re: [Jprogramming] Find nth duplicate in vector

2022-01-27 Thread Hauke Rehr
I wonder why there’s still so much traffic on this thread (okay, I’m to blame for quite some of it) I thought xash published the best correct solution. Am I wrong? Am 27.01.22 um 18:42 schrieb 'Mike Day' via Programming: Pawel Jakubas has moved on to something else in his correspondence,

Re: [Jprogramming] Find nth duplicate in vector

2022-01-27 Thread 'Mike Day' via Programming
Pawel Jakubas has moved on to something else in his correspondence, presumably related to this topic. Anyway, I think we need his adjudication, as I don't think Raul Miller's f is doing what PJ asked for. Hauke Rehr's proposal is hrf =: {{ (,~ {) {. I. (>: x) e."1 +/\ =/~ y }} My latest

Re: [Jprogramming] repeat n function

2022-01-27 Thread Hauke Rehr
Thanks Julian, this is Good Advice™ My cloumsy answer was meant to say “that’s not the J way” without actually spelling that out. But maybe it didn’t come across. Sometimes the best answer to “how?” is just “don’t!” Am 27.01.22 um 15:44 schrieb Julian Fondren: J doesn't have lexical scope so

Re: [Jprogramming] ArrayFire addon

2022-01-27 Thread Eric Iverson
Jan-Pieter, Thanks for your feedback. Your fixes will be in the next version. I have not tested with opencl and will get to that shortly. I thought of this as primarily a way to use nvidia gpus. But the cpu support works well and so probably does opencl. Not sure where this leads. Probably not

Re: [Jprogramming] ArrayFire addon

2022-01-27 Thread Eric Iverson
Jan-Pieter, ArrayFire uses a modified CSR from the wikipedia documentation. Instead of just counts it has +/\ counts. It also has a leading 0 and a trailing value. On Thu, Jan 27, 2022 at 3:50 AM Jan-Pieter Jacobs < janpieter.jac...@gmail.com> wrote: > Thanks for the explanation Hauke. > I guess

Re: [Jprogramming] repeat n function

2022-01-27 Thread Julian Fondren
J doesn't have lexical scope so you're cutting against the grain of the language to want internal definitions like this. Those internal verbs are also defined every single time the function is called. The entire APL family of languages have their own ways of achieving readability and

Re: [Jprogramming] repeat n function

2022-01-27 Thread 'Pascal Jasmin' via Programming
and the last expression as a "parameterized function" that is adverb instead of dyad 2 (,^:)~ 1 2 3 1 2 3 1 2 3 1 2 3 On Thursday, January 27, 2022, 09:11:22 a.m. EST, 'Pascal Jasmin' via Programming wrote: J has a repeat conjunction ^:    A repeat adverb that repeats n times is

Re: [Jprogramming] repeat n function

2022-01-27 Thread Hauke Rehr
Is something like this what you want? repeat =: 4 : 0 rshowx =. 'This is x inside repeat:',LF, ": x rshowy =. 'This is y inside repeat:',LF, ": y f =. [;@#{.@] d =. y rshowf =. 'These are x and y for f; and its result:',LF,,LF,.":x (;;f) d;d rshowx,LF,rshowy,LF,rshowf ) 3

Re: [Jprogramming] ArrayFire addon

2022-01-27 Thread bill lam
I have made a minor update to the addon to allow use arrayfire installed via homebrew. on apple m1 init_jaf_ 'cpu' and 'opencl' are available but 'opencl' doesn't support double precision > On 27 Jan 2022, at 12:42 AM, Eric Iverson wrote: > > Apologies for the rough start. The development

Re: [Jprogramming] repeat n function

2022-01-27 Thread 'Pascal Jasmin' via Programming
J has a repeat conjunction ^:    A repeat adverb that repeats n times is (^:n) or to use x instead of n (^:[) this won't behave as your original function, but produces the square of x copies of y.  ie. each function call changes/expands y such that the next call is on the larger y 2 ,~@]^:[

[Jprogramming] repeat n function

2022-01-27 Thread Pawel Jakubas
I am wondering how to embed definition of `f` inside `repeat`. so I would call `x repeat d` and inside this function `x f (d;d)` would be called. On both levels, repeat and f, we have names x and y.And I wonder what are the techniques to (a) reuse them at both `repeat` and `f` level, (b) separate

Re: [Jprogramming] repeat n function

2022-01-27 Thread Henry Rich
1. To debug a sentence, use Dissect. 2. To print expressions during execution, a quick way is load'printf'  NB. just once per session qprintf'x ' qprintf'x $y ' The last character of the argument is the delimiter between expressions. Henry Rich On 1/27/2022 8:23 AM, Pawel Jakubas wrote:

Re: [Jprogramming] repeat n function

2022-01-27 Thread 'Pascal Jasmin' via Programming
'only x less than 10 is accepted' assert 0 |only x less than 10 is accepted: assert | 'only x less than 10 is accepted' assert 0 3 (] $~ [ * $@]) 1 2 3 1 2 3 1 2 3 1 2 3 13 'only x less than 10 accepted'"_`(] $~ [ * $@])@.(10 > [) 1 2 3 only x less than 10 accepted builtin assert

Re: [Jprogramming] repeat n function

2022-01-27 Thread Julian Fondren
You can box y, repeat it with dyadic #, and then raze the boxes: 3 ([: ; [#<@]) 'hi' hihihi 3 ([: ; [#<@]) 1 2 3 1 2 3 1 2 3 1 2 3 3 {{ ; x # wrote: > Dear J enthusiasts, > > I am defining `x repeat y` function, that is appending y to itself x times. > > And defined something like

Re: [Jprogramming] repeat n function

2022-01-27 Thread Hauke Rehr
One way to get the simple repeat function is this: ] d =: >: i.3 1 2 3 f =: [ ;@# {.@] 1 f d;d 1 2 3 2 f d;d 1 2 3 1 2 3 3 f d;d 1 2 3 1 2 3 1 2 3 If you don’t call f with d;d but simply with d, then you can just define f =: ;@# which I consider an answer to your question 3.

Re: [Jprogramming] repeat n function

2022-01-27 Thread Hauke Rehr
2. you could try echo 'this' and smoutput 'that' 3. look up the definition of dyadic # (and $) (or just try it) 4. I don’t know exactly which behavior you want could you give some example in- and output of the more general function you’re after? Am 27.01.22 um 14:23 schrieb Pawel Jakubas: Dear

[Jprogramming] repeat n function

2022-01-27 Thread Pawel Jakubas
Dear J enthusiasts, I am defining `x repeat y` function, that is appending y to itself x times. And defined something like below (on intention like that to ask a couple of questions). f=: 4 : 0 assert (x < 10) segment=.>0{y if. (x = 1) do. (>1{y) else. (x-1) f (segment;( (>1{y),segment) )

Re: [Jprogramming] Find nth duplicate in vector

2022-01-27 Thread Raul Miller
Here's how I would modify my implementation to produce an empty result when a non-duplicate is referenced. d=: 1 _1 2 3 4 2 5 6 3 8 10 3 2 f=: {{y ({~,]) I. wrote: > > Perhaps I should point out that my verb, h (see below), uses a lot of space > for a large list, especially if there are

Re: [Jprogramming] Find nth duplicate in vector

2022-01-27 Thread 'Mike Day' via Programming
Perhaps I should point out that my verb, h (see below), uses a lot of space for a large list, especially if there are few repeats, as it’s using an outer product. I later produced an even more verbose effort which runs in less space on a 10^6 long vector, but takes 3-4x the space & time

Re: [Jprogramming] ArrayFire addon

2022-01-27 Thread 'Mike Day' via Programming
I’m away from home, with only a mobile router, so I attempted the downloads at our son’s house. TalkTalk, my service provider, won’t let me send email from my laptop using his router, so perhaps it’s stopping the validation, but only after using up a GB or two of his service! Virus-checker

Re: [Jprogramming] ArrayFire addon

2022-01-27 Thread Jan-Pieter Jacobs
Thanks for the explanation Hauke. I guess that shows that I never studied computer science. I expected rows and cols to just be indices of the non-zero items, as 4&$. returns for J's sparse arrays. Anyone else wondering can refer to https://en.m.wikipedia.org/wiki/Sparse_matrix where the CRS