Re: [Jprogramming] How well does OpenGL work with J903?
Hi Bob, Thanks! Will do... lots to learn in this fascinating language! Kind regards, Stan On 2022-01-25 21:34, 'robert therriault' via Programming wrote: Hi Stan, If you have looked at the shader demo in Jqt Help | Studio | Qt demos... there is a source button that will show the source that is generating the window with the rotating cube. I have often take such an existing source and then made changes to it to get a sense of how an application works. Cheers, bob On Jan 25, 2022, at 18:35, Stan Blank wrote: Thank you, Raul! The issue I'm having with the freeglut addon is that the addon seems to load properly (no errors), but I am unable to create a window of any kind. However, I'm aware that my lack of J knowledge is most likely the culprit and I have some homework to do first. I purchased Henry Rich's "J for C" text and am currently slogging my way through. When I know enough to ask more intelligent questions... Again, thanks and best wishes, Stan I do not have much experience with GLUT. I was never able to find documentation on it which I felt I adequately understood and which was relevant to the kinds of things I have wanted to do. But, also, there's a lot of problems that can lead to blank screens, so one of the first things I try to do is make sure I can update the background color. If I can do that, the next thing is to see if I can get any geometry to render in front of the "camera". It's the little things that get you... That said, if you have code that you want us to see if we can sort out (hopefully not too complicated, at the beginning -- small problems are easier to isolate than big problems), post it somewhere and we can try to take a look at it. Thanks, -- Raul On Tue, Jan 25, 2022 at 1:07 PM Stan Blank wrote: Thanks to Bob, Raul, Bill, Elijah for the help in getting me started with OpenGL and J. I'm a complete beginner (albeit a retired math/physics teacher) and I have my work cut out for me. The language is very interesting to me and will hopefully help delay the onset of senility as I try to learn something new. Well, I can hope... :-) I looked at the OpenGL examples in J6.02 (great!) and have now installed J9.03. I have the shader demo working in Windows and I'll try the Mac (and also linux) this evening if time permits. Fascinating stuff! Question: I have installed the freeglut addon and it appears to load properly (no errors), but I can not generate a window or graphic. I have some experience with OpenGL/GLUT using C, Python, Fortran, and various flavors of Basic. I'll do my best to not be a pest... it's time for me to dig in! Cheers... and again, thanks! Stan It now works for me. Thanks, -- Raul On Tue, Jan 25, 2022 at 10:09 AM bill lam wrote: I fixed the qtdemo addons. Shader should work on macos now. Please >> update and test again. On 24 Jan 2022, at 12:02 PM, bill lam wrote: Thank you for this report. I also encountered the same issue on >> > apple m1. Norman Drinkwater reported that it worked in vm (a rotating >> > cube) but not on physical machine. I'll investigate further. On Mon, Jan 24, 2022, 11:47 AM Raul Miller wrote: That's an improvement. After changing the minwh line to specify opengl version 4.1, I get text (keys... scale... angle... matrix...) on the opengl screen (previously it was just black). And, the text is updating - if I recall correctly, though, I believe I should also be seeing a >> > rotating cube. And, I am not seeing any geometry being rendered -- only text. For reference, with this change, here's what the shader demo dumps into the jqt session: GL_VERSION: 4.1 ATI-2.11.20 GL_VENDOR: ATI Technologies Inc. GL_RENDERER: AMD Radeon Pro 560 OpenGL Engine GL_SHADING_LANGUAGE_VERSION: 4.10 #version 410 core in vec3 vertex; in vec3 color; out vec4 v_color; uniform mat4 mvp; void main(void) { gl_Position = mvp * vec4(vertex,1.0); v_color = vec4(color,1.0); } #version 410 core in vec4 v_color; out vec4 fragColor; void main(void) { fragColor = v_color; } Also: glGetError_jgles_ '' ┌─┐ │0│ └─┘ I am not sure what else I should be checking. (If something went >> > wrong setting up the shader, I imagine there would have been a non-zero error value.) Thanks, -- Raul On Sun, Jan 23, 2022 at 10:01 PM bill lam >> > wrote: Another reference https://www.khronos.org/opengl/wiki/Programming_OpenGL_on_macOS you can try edit the file shader.ijs in addons/demos/qtdemo around line 11 from minwh 300 300;cc g opengl flush; to minwh 300 300;cc g opengl version 4.1 flush; the version of GLSL is different from the version of OpenGL On 24 Jan 2022, at 10:22 AM, Raul Miller wrote: On Sun, Jan 23, 2022 at 9:14 PM Elijah Stone >> > > > wrote: On Sun, 23 Jan 2022, Raul Miller wrote: But that demo does not work on my OSX (Mojave) machine (which >> > > >>> has OpenGL 1.2). For whatever reasons (possibly including availability of good documentation), Apple has been slow to adopt newer versions o
Re: [Jprogramming] ArrayFire addon
An interface suggestion would be to transform all verbs that currently take 2 boxed arguments into unboxed dyad arguments. this can be done by adding the adverb (@:;) for the dop class verbs. and (@:;~) for the reduce class verbs such that the operating axis is the x term. The reduce class could have the additional adverb (0&$: : ) to make supplying the axis an optional parameter. The explicitly constructed functions in arrayfire.ijs that take 2 boxed y parameters (matmul) can also be decorated with (@: ;) These changes would more naturally leverage J's processing/modifier capabilities, and processing list of arrayfire array handles. Arrayfire sparse support seems to be limited to rank 2 arrays. J could circumvent these limitations by shaping multiple arrayfire handles managing the nesting logic in J instead. There are many uses of arrayfire that are made easier with a list of array handles. On Tuesday, January 25, 2022, 04:39:36 p.m. EST, Eric Iverson wrote: Pascal, Thanks for the feedback. Coming from you, it means a lot to me. There are some rough edges for windows and mac (I work mostly in linux) that I will fix tomorrow morning. On Tue, Jan 25, 2022 at 3:52 PM 'Pascal Jasmin' via Programming < programm...@jsoftware.com> wrote: > looks good. A small bug: > > if you define > > reduce_z_ =: ]: NB. adverb > > prior to loading arrayfire.ijs > > load will fail. > > The reason is the families.ijs file creates a bunch of forks with their > middle verbs defined after the forks are created. > > An easy fix is to define all of the explicit verbs used in families.ijs > above the line that "require families.ijs" > > > fixed it for me. > > > > On Tuesday, January 25, 2022, 10:56:54 a.m. EST, Eric Iverson < > eric.b.iver...@gmail.com> wrote: > > > > > > ~addons/math/arrayfire is a new addon for J903 and later. > > The addon allows high performance computing of matrix product > and many other mathematical array operations. Multiple cpu > cores and hardware such as Nvidia gpus are used as appropriate. > > Browse https://arrayfire.org for more info. > > The addon will prompt you for the ArrayFire software install if > it is not already installed. > > Use pacman to install the addon. For example, > load'pacman' > 'install' jpkg 'math/arrayfire' > > Get started: > load '~addons/math/arrayfire/arrayfire.ijs' > man_jaf_ 'intro' > ... > init_jaf_ 'cpu' > tut_jaf_ 'basic' NB. run basic tutorial > ... > man_jaf_ 'credits' NB. credit to some J-ArrayFire pioneers > ... > > *** preliminary version > We think this is an important step for J in high performance computing. > If this proves to be the case, Jsoftware will actively pursue further > development in this area. > > *** from the addon description > cd bindings and utilities for ArrayFire shared library > > https://arrayfire.org > > "ArrayFire is a high performance software library for > parallel computing with an easy-to-use API. Its array based > function set makes parallel programming more accessible." > > J-ArrayFire cd bindings make it easy to have > high performance computing for things like matrix multiply > with cpu cores, Nvidia gpus, and opencl. > *** > -- > For information about J forums see 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 -- For information about J forums see http://www.jsoftware.com/forums.htm
[Jprogramming] ArrayFire addon
Apologies for the rough start. The development was done in linux with arrayfire installed and not enough attention was paid to other platforms or new users. The addon has been updated. Raul: You were on macOS, which had not been tested at all. It should work now if arrayfire is installed in folder /opt/arrayfire. Michail: You were on windows and it looks as if arrayfire was not installed. There is now a more informative failure for that case. It should work once arrayfire is installed. Pascal: The families.ijs bug has been fixed. Please update the addon and try again. -- For information about J forums see http://www.jsoftware.com/forums.htm
[Jprogramming] isidraw...?
http://www.rosettacode.org/wiki/Fractal_tree#J I had updated the fractal tree implementation to work with j903. (The previous code did not work with any implementation of J which I have installed on my mac -- apparently Apple's changes mean that j504 and j602 no longer function on this machine.) However, I noticed that the window is slow to come up, and I cannot resize it, So, I changed the implementation: require'gl2' L0=: 50 NB. initial length A0=: 1r8p1NB. initial angle: pi divided by 8 dL=: 0.9 NB. shrink factor for length dA=: 0.75 NB. shrink factor for angle N=: 14NB. number of branches L=: L0*dL^1+i.N NB. lengths of line segments NB. relative angles of successive line segments A=: A0*(dA^i.N) +/\@:*("1) _1 ^ #:i.2 ^ N NB. end points for each line segment P=: 0 0+/\@,"2 +.*.inv (L0,0),"2 L,"0"1 A wd {{)n pc P closeok; setp wh 480 640; cc C isidraw; pshow; }} glclear_jgl2_'' gllines_jgl2_ <.@(10 + ,/"2 P-"1<./,/P) But this version does not draw the fractal tree. Has anyone been able to get gllines to work in an isidraw? Thanks, -- Raul -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] isidraw...?
Try put an glpaint'' after the last gllines... Untested On Thu, 27 Jan 2022 at 12:59 AM Raul Miller wrote: > http://www.rosettacode.org/wiki/Fractal_tree#J > > I had updated the fractal tree implementation to work with j903. (The > previous code did not work with any implementation of J which I have > installed on my mac -- apparently Apple's changes mean that j504 and > j602 no longer function on this machine.) > > However, I noticed that the window is slow to come up, and I cannot resize > it, > > So, I changed the implementation: > > require'gl2' > > L0=: 50 NB. initial length > A0=: 1r8p1NB. initial angle: pi divided by 8 > dL=: 0.9 NB. shrink factor for length > dA=: 0.75 NB. shrink factor for angle > N=: 14NB. number of branches > > L=: L0*dL^1+i.N NB. lengths of line segments > > NB. relative angles of successive line segments > A=: A0*(dA^i.N) +/\@:*("1) _1 ^ #:i.2 ^ N > > NB. end points for each line segment > P=: 0 0+/\@,"2 +.*.inv (L0,0),"2 L,"0"1 A > > wd {{)n > pc P closeok; > setp wh 480 640; > cc C isidraw; > pshow; > }} > > glclear_jgl2_'' > gllines_jgl2_ <.@(10 + ,/"2 P-"1<./,/P) > > But this version does not draw the fractal tree. > > Has anyone been able to get gllines to work in an isidraw? > > Thanks, > > -- > Raul > -- > For information about J forums see http://www.jsoftware.com/forums.htm > -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] ArrayFire addon
Pascal, Interesting ideas on arrayfire args. I will probably resist the idea of making dop verbs dyadic. I think it better to stick closer to the arrayfire syntax. But it makes sense to avoid unnecessary boxing. af_add_jaf_ afad;afbd NB. works af_add_jaf_ afad,afbd NB. fails, but probably should work On Wed, Jan 26, 2022 at 10:03 AM 'Pascal Jasmin' via Programming < programm...@jsoftware.com> wrote: > An interface suggestion would be to transform all verbs that currently > take 2 boxed arguments into unboxed dyad arguments. > > this can be done by adding the adverb (@:;) for the dop class verbs. and > (@:;~) for the reduce class verbs such that the operating axis is the x > term. The reduce class could have the additional adverb (0&$: : ) to make > supplying the axis an optional parameter. The explicitly constructed > functions in arrayfire.ijs that take 2 boxed y parameters (matmul) can also > be decorated with (@: ;) > > These changes would more naturally leverage J's processing/modifier > capabilities, and processing list of arrayfire array handles. Arrayfire > sparse support seems to be limited to rank 2 arrays. J could circumvent > these limitations by shaping multiple arrayfire handles managing the > nesting logic in J instead. > > There are many uses of arrayfire that are made easier with a list of array > handles. > > > > > On Tuesday, January 25, 2022, 04:39:36 p.m. EST, Eric Iverson < > eric.b.iver...@gmail.com> wrote: > > > > > > Pascal, > > Thanks for the feedback. Coming from you, it means a lot to me. > > There are some rough edges for windows and mac (I work mostly in linux) > that I will fix tomorrow morning. > > On Tue, Jan 25, 2022 at 3:52 PM 'Pascal Jasmin' via Programming < > programm...@jsoftware.com> wrote: > > > looks good. A small bug: > > > > if you define > > > > reduce_z_ =: ]: NB. adverb > > > > prior to loading arrayfire.ijs > > > > load will fail. > > > > The reason is the families.ijs file creates a bunch of forks with their > > middle verbs defined after the forks are created. > > > > An easy fix is to define all of the explicit verbs used in families.ijs > > above the line that "require families.ijs" > > > > > > fixed it for me. > > > > > > > > On Tuesday, January 25, 2022, 10:56:54 a.m. EST, Eric Iverson < > > eric.b.iver...@gmail.com> wrote: > > > > > > > > > > > > ~addons/math/arrayfire is a new addon for J903 and later. > > > > The addon allows high performance computing of matrix product > > and many other mathematical array operations. Multiple cpu > > cores and hardware such as Nvidia gpus are used as appropriate. > > > > Browse https://arrayfire.org for more info. > > > > The addon will prompt you for the ArrayFire software install if > > it is not already installed. > > > > Use pacman to install the addon. For example, > > load'pacman' > > 'install' jpkg 'math/arrayfire' > > > > Get started: > > load '~addons/math/arrayfire/arrayfire.ijs' > > man_jaf_ 'intro' > > ... > > init_jaf_ 'cpu' > > tut_jaf_ 'basic' NB. run basic tutorial > > ... > > man_jaf_ 'credits' NB. credit to some J-ArrayFire pioneers > > ... > > > > *** preliminary version > > We think this is an important step for J in high performance computing. > > If this proves to be the case, Jsoftware will actively pursue further > > development in this area. > > > > *** from the addon description > > cd bindings and utilities for ArrayFire shared library > > > > https://arrayfire.org > > > > "ArrayFire is a high performance software library for > > parallel computing with an easy-to-use API. Its array based > > function set makes parallel programming more accessible." > > > > J-ArrayFire cd bindings make it easy to have > > high performance computing for things like matrix multiply > > with cpu cores, Nvidia gpus, and opencl. > > *** > > -- > > For information about J forums see 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 > -- > For information about J forums see http://www.jsoftware.com/forums.htm > -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] isidraw...?
Sadly, glpaint_jgl2_'' does not change anything. Does it work for you? (In other words, is this a problem specific to my machine, or my type of machine?) Thanks, -- Raul On Wed, Jan 26, 2022 at 12:04 PM bill lam wrote: > > Try put an glpaint'' after the last gllines... > > Untested > > On Thu, 27 Jan 2022 at 12:59 AM Raul Miller wrote: > > > http://www.rosettacode.org/wiki/Fractal_tree#J > > > > I had updated the fractal tree implementation to work with j903. (The > > previous code did not work with any implementation of J which I have > > installed on my mac -- apparently Apple's changes mean that j504 and > > j602 no longer function on this machine.) > > > > However, I noticed that the window is slow to come up, and I cannot resize > > it, > > > > So, I changed the implementation: > > > > require'gl2' > > > > L0=: 50 NB. initial length > > A0=: 1r8p1NB. initial angle: pi divided by 8 > > dL=: 0.9 NB. shrink factor for length > > dA=: 0.75 NB. shrink factor for angle > > N=: 14NB. number of branches > > > > L=: L0*dL^1+i.N NB. lengths of line segments > > > > NB. relative angles of successive line segments > > A=: A0*(dA^i.N) +/\@:*("1) _1 ^ #:i.2 ^ N > > > > NB. end points for each line segment > > P=: 0 0+/\@,"2 +.*.inv (L0,0),"2 L,"0"1 A > > > > wd {{)n > > pc P closeok; > > setp wh 480 640; > > cc C isidraw; > > pshow; > > }} > > > > glclear_jgl2_'' > > gllines_jgl2_ <.@(10 + ,/"2 P-"1<./,/P) > > > > But this version does not draw the fractal tree. > > > > Has anyone been able to get gllines to work in an isidraw? > > > > Thanks, > > > > -- > > Raul > > -- > > For information about J forums see 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
[Jprogramming] Find nth duplicate in vector
Dear J enthusiasts, I wonder how to elegantly implement dyad f that takes as x=1,2,3... and y vector and returns nth duplicate value with index of that occurence: d=: 1 _1 2 3 4 2 5 6 3 8 10 3 2 NB. the earliest first duplicate is for 2 and index 2 1 f d 2 2 NB. the earliest second duplicate is for 3 for index 11 2 f d 3 11 In Haskell for nth occurence I would just use accumulator as (Map with key being element and value the number of occurence of this element, current index count) and left fold that with starting accumulator (Map.empty, 0). Kindest regards, Pawel -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Find nth duplicate in vector
I don’t understand why it’s index 2 (first occurrence of 2) but 11 (third occurrence of 3) Am 26.01.22 um 19:37 schrieb Pawel Jakubas: Dear J enthusiasts, I wonder how to elegantly implement dyad f that takes as x=1,2,3... and y vector and returns nth duplicate value with index of that occurence: d=: 1 _1 2 3 4 2 5 6 3 8 10 3 2 NB. the earliest first duplicate is for 2 and index 2 1 f d 2 2 NB. the earliest second duplicate is for 3 for index 11 2 f d 3 11 In Haskell for nth occurence I would just use accumulator as (Map with key being element and value the number of occurence of this element, current index count) and left fold that with starting accumulator (Map.empty, 0). Kindest regards, Pawel -- For information about J forums see http://www.jsoftware.com/forums.htm -- -- mail written using NEO neo-layout.org -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Find nth duplicate in vector
Maybe this is what you want (but it’s not elegant) f =: {{ (,~ {&y) {. I. ( (>: x)&e."1) +/\ =/~ y }} 1 f d 2 5 2 f d 3 11 just a quick and dirty working solution (if 2 5 is the correct answer to 1 f d) Am 26.01.22 um 19:37 schrieb Pawel Jakubas: Dear J enthusiasts, I wonder how to elegantly implement dyad f that takes as x=1,2,3... and y vector and returns nth duplicate value with index of that occurence: d=: 1 _1 2 3 4 2 5 6 3 8 10 3 2 NB. the earliest first duplicate is for 2 and index 2 1 f d 2 2 NB. the earliest second duplicate is for 3 for index 11 2 f d 3 11 In Haskell for nth occurence I would just use accumulator as (Map with key being element and value the number of occurence of this element, current index count) and left fold that with starting accumulator (Map.empty, 0). Kindest regards, Pawel -- For information about J forums see http://www.jsoftware.com/forums.htm -- -- mail written using NEO neo-layout.org -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] isidraw...?
Dissect uses isidraw and gllines on Jqt. Henry Rich On 1/26/2022 11:58 AM, Raul Miller wrote: http://www.rosettacode.org/wiki/Fractal_tree#J I had updated the fractal tree implementation to work with j903. (The previous code did not work with any implementation of J which I have installed on my mac -- apparently Apple's changes mean that j504 and j602 no longer function on this machine.) However, I noticed that the window is slow to come up, and I cannot resize it, So, I changed the implementation: require'gl2' L0=: 50 NB. initial length A0=: 1r8p1NB. initial angle: pi divided by 8 dL=: 0.9 NB. shrink factor for length dA=: 0.75 NB. shrink factor for angle N=: 14NB. number of branches L=: L0*dL^1+i.N NB. lengths of line segments NB. relative angles of successive line segments A=: A0*(dA^i.N) +/\@:*("1) _1 ^ #:i.2 ^ N NB. end points for each line segment P=: 0 0+/\@,"2 +.*.inv (L0,0),"2 L,"0"1 A wd {{)n pc P closeok; setp wh 480 640; cc C isidraw; pshow; }} glclear_jgl2_'' gllines_jgl2_ <.@(10 + ,/"2 P-"1<./,/P) But this version does not draw the fractal tree. Has anyone been able to get gllines to work in an isidraw? Thanks, -- This email has been checked for viruses by AVG. https://www.avg.com -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Find nth duplicate in vector
Use the ideas in https://code.jsoftware.com/wiki/Essays/Progressive_Index-Of . Henry Rich On 1/26/2022 1:37 PM, Pawel Jakubas wrote: Dear J enthusiasts, I wonder how to elegantly implement dyad f that takes as x=1,2,3... and y vector and returns nth duplicate value with index of that occurence: d=: 1 _1 2 3 4 2 5 6 3 8 10 3 2 NB. the earliest first duplicate is for 2 and index 2 1 f d 2 2 NB. the earliest second duplicate is for 3 for index 11 2 f d 3 11 In Haskell for nth occurence I would just use accumulator as (Map with key being element and value the number of occurence of this element, current index count) and left fold that with starting accumulator (Map.empty, 0). Kindest regards, Pawel -- For information about J forums see http://www.jsoftware.com/forums.htm -- This email has been checked for viruses by AVG. https://www.avg.com -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] ArrayFire addon
The signature for af_add: af_add (af_array *out, const af_array lhs, const af_array rhs, const bool batch) with lhs and rhs as parameter names, I don't think J users would get lost if they called the "cover function" dyadically the same way they call + I'm not suggesting altering any existing code that does follow the "C spec" closely. Just adding adverbs on top of them to provide an intuitive J interface to the functions. consider the J function insert =: 1 : 'u/"x y' (_&$: :) it is "monadic only" version of /. With optional rank parameter as dyadic number + insert i.3 3 9 12 15 1 + insert i.3 3 3 12 21 J does not need such an adverb ("x is easy to type/add and "name context free"), but "lesser languages" do. Although when they do use such an implementation, they capture the full flexibility of ranked-modified insert. A more important flexibility than being able to turn insert into, a very different adverb, table. this insert adverb definition would work like a lesser language modifier like af_sum, af_product group. One of the reasons to make this consistency change is to simplify conversion to and from J<->arrayfire including the great matmul demonstration you have provided. On Wednesday, January 26, 2022, 12:23:52 p.m. EST, Eric Iverson wrote: Pascal, Interesting ideas on arrayfire args. I will probably resist the idea of making dop verbs dyadic. I think it better to stick closer to the arrayfire syntax. But it makes sense to avoid unnecessary boxing. af_add_jaf_ afad;afbd NB. works af_add_jaf_ afad,afbd NB. fails, but probably should work On Wed, Jan 26, 2022 at 10:03 AM 'Pascal Jasmin' via Programming < programm...@jsoftware.com> wrote: > An interface suggestion would be to transform all verbs that currently > take 2 boxed arguments into unboxed dyad arguments. > > this can be done by adding the adverb (@:;) for the dop class verbs. and > (@:;~) for the reduce class verbs such that the operating axis is the x > term. The reduce class could have the additional adverb (0&$: : ) to make > supplying the axis an optional parameter. The explicitly constructed > functions in arrayfire.ijs that take 2 boxed y parameters (matmul) can also > be decorated with (@: ;) > > These changes would more naturally leverage J's processing/modifier > capabilities, and processing list of arrayfire array handles. Arrayfire > sparse support seems to be limited to rank 2 arrays. J could circumvent > these limitations by shaping multiple arrayfire handles managing the > nesting logic in J instead. > > There are many uses of arrayfire that are made easier with a list of array > handles. > > > > > On Tuesday, January 25, 2022, 04:39:36 p.m. EST, Eric Iverson < > eric.b.iver...@gmail.com> wrote: > > > > > > Pascal, > > Thanks for the feedback. Coming from you, it means a lot to me. > > There are some rough edges for windows and mac (I work mostly in linux) > that I will fix tomorrow morning. > > On Tue, Jan 25, 2022 at 3:52 PM 'Pascal Jasmin' via Programming < > programm...@jsoftware.com> wrote: > > > looks good. A small bug: > > > > if you define > > > > reduce_z_ =: ]: NB. adverb > > > > prior to loading arrayfire.ijs > > > > load will fail. > > > > The reason is the families.ijs file creates a bunch of forks with their > > middle verbs defined after the forks are created. > > > > An easy fix is to define all of the explicit verbs used in families.ijs > > above the line that "require families.ijs" > > > > > > fixed it for me. > > > > > > > > On Tuesday, January 25, 2022, 10:56:54 a.m. EST, Eric Iverson < > > eric.b.iver...@gmail.com> wrote: > > > > > > > > > > > > ~addons/math/arrayfire is a new addon for J903 and later. > > > > The addon allows high performance computing of matrix product > > and many other mathematical array operations. Multiple cpu > > cores and hardware such as Nvidia gpus are used as appropriate. > > > > Browse https://arrayfire.org for more info. > > > > The addon will prompt you for the ArrayFire software install if > > it is not already installed. > > > > Use pacman to install the addon. For example, > > load'pacman' > > 'install' jpkg 'math/arrayfire' > > > > Get started: > > load '~addons/math/arrayfire/arrayfire.ijs' > > man_jaf_ 'intro' > > ... > > init_jaf_ 'cpu' > > tut_jaf_ 'basic' NB. run basic tutorial > > ... > > man_jaf_ 'credits' NB. credit to some J-ArrayFire pioneers > > ... > > > > *** preliminary version > > We think this is an important step for J in high performance computing. > > If this proves to be the case, Jsoftware will actively pursue further > > development in this area. > > > > *** from the addon description > > cd bindings and utilities for ArrayFire shared library > > > > https://arrayfire.org > > > > "ArrayFire is a high performance software library for > > parallel computing with an easy-to-use API. Its array based > > function set makes parallel programming more accessible." > > > > J-ArrayFire cd bin
Re: [Jprogramming] isidraw...?
Ok, so it's not that gllines on isidraw completely fails on my machine. That's good to know. Thanks, -- Raul On Wed, Jan 26, 2022 at 2:25 PM Henry Rich wrote: > > Dissect uses isidraw and gllines on Jqt. > > Henry Rich > > On 1/26/2022 11:58 AM, Raul Miller wrote: > > http://www.rosettacode.org/wiki/Fractal_tree#J > > > > I had updated the fractal tree implementation to work with j903. (The > > previous code did not work with any implementation of J which I have > > installed on my mac -- apparently Apple's changes mean that j504 and > > j602 no longer function on this machine.) > > > > However, I noticed that the window is slow to come up, and I cannot resize > > it, > > > > So, I changed the implementation: > > > > require'gl2' > > > > L0=: 50 NB. initial length > > A0=: 1r8p1NB. initial angle: pi divided by 8 > > dL=: 0.9 NB. shrink factor for length > > dA=: 0.75 NB. shrink factor for angle > > N=: 14NB. number of branches > > > > L=: L0*dL^1+i.N NB. lengths of line segments > > > > NB. relative angles of successive line segments > > A=: A0*(dA^i.N) +/\@:*("1) _1 ^ #:i.2 ^ N > > > > NB. end points for each line segment > > P=: 0 0+/\@,"2 +.*.inv (L0,0),"2 L,"0"1 A > > > > wd {{)n > > pc P closeok; > > setp wh 480 640; > > cc C isidraw; > > pshow; > > }} > > > > glclear_jgl2_'' > > gllines_jgl2_ <.@(10 + ,/"2 P-"1<./,/P) > > > > But this version does not draw the fractal tree. > > > > Has anyone been able to get gllines to work in an isidraw? > > > > Thanks, > > > > > -- > This email has been checked for viruses by AVG. > https://www.avg.com > > -- > For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] ArrayFire addon
Just about downloading ArrayFire for Windows 11... I tried downloading the two exe files, one for W11, which failed, and then W10, also a failure. The failures both reported inability to verify. My son has just commented that it’s a common M/S feature... Anyone else seen this behaviour? Thanks Mike Sent from my iPad > On 26 Jan 2022, at 19:45, 'Pascal Jasmin' via Programming > wrote: > > The signature for af_add: > > af_add (af_array *out, const af_array lhs, const af_array rhs, const bool > batch) > > with lhs and rhs as parameter names, I don't think J users would get lost if > they called the "cover function" dyadically the same way they call + > > I'm not suggesting altering any existing code that does follow the "C spec" > closely. Just adding adverbs on top of them to provide an intuitive J > interface to the functions. > > consider the J function > > insert =: 1 : 'u/"x y' (_&$: :) > > it is "monadic only" version of /. With optional rank parameter as dyadic > number > > + insert i.3 3 > > 9 12 15 > > 1 + insert i.3 3 > > 3 12 21 > > J does not need such an adverb ("x is easy to type/add and "name context > free"), but "lesser languages" do. Although when they do use such an > implementation, they capture the full flexibility of ranked-modified insert. > A more important flexibility than being able to turn insert into, a very > different adverb, table. > > this insert adverb definition would work like a lesser language modifier > > like af_sum, af_product group. > > One of the reasons to make this consistency change is to simplify conversion > to and from J<->arrayfire including the great matmul demonstration you have > provided. > > > > > > On Wednesday, January 26, 2022, 12:23:52 p.m. EST, Eric Iverson > wrote: > > > > > > Pascal, > > Interesting ideas on arrayfire args. > > I will probably resist the idea of making dop verbs dyadic. I think it > better to stick closer to the arrayfire syntax. > > But it makes sense to avoid unnecessary boxing. > > af_add_jaf_ afad;afbd NB. works > af_add_jaf_ afad,afbd NB. fails, but probably should work > > > > On Wed, Jan 26, 2022 at 10:03 AM 'Pascal Jasmin' via Programming < > programm...@jsoftware.com> wrote: > >> An interface suggestion would be to transform all verbs that currently >> take 2 boxed arguments into unboxed dyad arguments. >> >> this can be done by adding the adverb (@:;) for the dop class verbs. and >> (@:;~) for the reduce class verbs such that the operating axis is the x >> term. The reduce class could have the additional adverb (0&$: : ) to make >> supplying the axis an optional parameter. The explicitly constructed >> functions in arrayfire.ijs that take 2 boxed y parameters (matmul) can also >> be decorated with (@: ;) >> >> These changes would more naturally leverage J's processing/modifier >> capabilities, and processing list of arrayfire array handles. Arrayfire >> sparse support seems to be limited to rank 2 arrays. J could circumvent >> these limitations by shaping multiple arrayfire handles managing the >> nesting logic in J instead. >> >> There are many uses of arrayfire that are made easier with a list of array >> handles. >> >> >> >> >> On Tuesday, January 25, 2022, 04:39:36 p.m. EST, Eric Iverson < >> eric.b.iver...@gmail.com> wrote: >> >> >> >> >> >> Pascal, >> >> Thanks for the feedback. Coming from you, it means a lot to me. >> >> There are some rough edges for windows and mac (I work mostly in linux) >> that I will fix tomorrow morning. >> >> On Tue, Jan 25, 2022 at 3:52 PM 'Pascal Jasmin' via Programming < >> programm...@jsoftware.com> wrote: >> >>> looks good. A small bug: >>> >>> if you define >>> >>> reduce_z_ =: ]: NB. adverb >>> >>> prior to loading arrayfire.ijs >>> >>> load will fail. >>> >>> The reason is the families.ijs file creates a bunch of forks with their >>> middle verbs defined after the forks are created. >>> >>> An easy fix is to define all of the explicit verbs used in families.ijs >>> above the line that "require families.ijs" >>> >>> >>> fixed it for me. >>> >>> >>> >>> On Tuesday, January 25, 2022, 10:56:54 a.m. EST, Eric Iverson < >>> eric.b.iver...@gmail.com> wrote: >>> >>> >>> >>> >>> >>> ~addons/math/arrayfire is a new addon for J903 and later. >>> >>> The addon allows high performance computing of matrix product >>> and many other mathematical array operations. Multiple cpu >>> cores and hardware such as Nvidia gpus are used as appropriate. >>> >>> Browse https://arrayfire.org for more info. >>> >>> The addon will prompt you for the ArrayFire software install if >>> it is not already installed. >>> >>> Use pacman to install the addon. For example, >>> load'pacman' >>> 'install' jpkg 'math/arrayfire' >>> >>> Get started: >>> load '~addons/math/arrayfire/arrayfire.ijs' >>> man_jaf_ 'intro' >>> ... >>> init_jaf_ 'cpu' >>> tut_jaf_ 'basic' NB. run basic tutorial >>> ...
[Jprogramming] Find nth duplicate in vector
It should be of course 1 f d 2 5 Would be great if you could decompose your solution and the idea behind the solution. Many thanks. Cheers, Pawel -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Find nth duplicate in vector
Here's a variation that works: d=: 1 _1 2 3 4 2 5 6 3 8 10 3 2 f=: {{y ({~,]) x i.~ +/\(i.@#~:i.~)y }} 1 f d 2 5 2 f d 3 8 The phrase (i.@# ~: i.~) finds the locations of duplicates (i.@#~:i.~) 1 _1 2 3 4 2 5 6 3 8 10 3 2 0 0 0 0 0 1 0 0 1 0 0 1 1 And, +/\ computes a running sum +/\(i.@#~:i.~) d 0 0 0 0 0 1 1 1 2 2 2 3 4 With this, we can find the index of the first occurrence of a duplicate count number using x i.~ ... Once we have the index of a duplicate, we can return that index and the corresponding value from the list. -- Raul On Wed, Jan 26, 2022 at 3:49 PM Pawel Jakubas wrote: > > It should be of course > 1 f d > 2 5 > > Would be great if you could decompose your solution and the idea behind the > solution. Many thanks. > > Cheers, > Pawel > -- > For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Find nth duplicate in vector
As Henry pointed out, do take a look at [1] for how to approach this in J If you want to understand my solution, just try it step by step. I repeat it here, with a bit of litter removed: f =: {{ (,~ {&y) {. I. (>: x) e."1 +/\ =/~ y }} NB. where does each number occur? =/~ d 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 0 0 0 0 1 NB. cumulative sum of rows: NB. this number (column) already (row) occurred this often +/\ =/~ d 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 0 0 0 0 0 0 1 1 1 1 1 0 1 0 0 1 0 0 1 1 1 1 1 1 1 1 0 0 1 0 0 1 1 1 1 2 1 1 2 0 0 1 0 0 1 2 1 1 2 1 1 2 1 0 1 0 0 1 2 1 1 2 1 1 2 1 1 1 0 0 1 2 1 1 2 2 1 2 1 1 2 0 0 2 2 1 1 2 2 1 2 1 1 2 1 0 2 2 1 1 2 2 1 2 1 1 2 1 1 2 2 1 1 2 3 1 2 1 1 3 1 1 3 2 1 1 3 3 1 3 1 1 3 1 1 3 3 NB. the first row with a 2 {. I. 2 e."1 +/\ =/~ d 5 NB. index d with that value (,~ {&d) {. I. 2 e."1 +/\ =/~ d 2 5 NB. same with 3 (your x value 2) (,~ {&d) {. I. 3 e."1 +/\ =/~ d 3 11 In the meantime, Raul posted a solution which I guess will show a better approach. Hauke [1] https://code.jsoftware.com/wiki/Essays/Progressive_Index-Of Am 26.01.22 um 21:49 schrieb Pawel Jakubas: It should be of course 1 f d 2 5 Would be great if you could decompose your solution and the idea behind the solution. Many thanks. Cheers, Pawel -- For information about J forums see http://www.jsoftware.com/forums.htm -- -- mail written using NEO neo-layout.org -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Find nth duplicate in vector
-.@~: gets a mask of duplicates, I. then their indices. With them you can get a list of (index, value) pairs: ((],.{~) I.@:-.@~:) a 5 2 8 3 11 3 12 2 With 0 ({ (],.{~) I.@:-.@~:)) a you can 0-index into this list. If you are only interested into the first duplicate of a value, you could filter duplicate values: (#~ [:~: {:"1)@((],.{~) I.@:-.@~:) a 5 2 8 3 On Wed Jan 26, 2022 at 7:37 PM CET, Pawel Jakubas wrote: > Dear J enthusiasts, > > I wonder how to elegantly implement dyad f that takes as x=1,2,3... and > y > vector and returns nth duplicate value with index of that occurence: > > d=: 1 _1 2 3 4 2 5 6 3 8 10 3 2 > NB. the earliest first duplicate is for 2 and index 2 > 1 f d > 2 2 > NB. the earliest second duplicate is for 3 for index 11 > 2 f d > 3 11 > > In Haskell for nth occurence I would just use accumulator as > (Map with key being element and value the number of occurence of this > element, > current index count) > and left fold that with starting accumulator (Map.empty, 0). > > Kindest regards, > Pawel > -- > For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] ArrayFire addon
I did not have any problem installing on win10. It seems win11 is tightening the rules. You will need to take some extra step to override the security check. On Wed, Jan 26, 2022 at 3:35 PM 'Mike Day' via Programming < programm...@jsoftware.com> wrote: > Just about downloading ArrayFire for Windows 11... > > I tried downloading the two exe files, one for W11, which failed, and > then W10, also a failure. The failures both reported inability to verify. > > My son has just commented that it’s a common M/S feature... Anyone else > seen this behaviour? > > Thanks > > Mike > > Sent from my iPad > > > On 26 Jan 2022, at 19:45, 'Pascal Jasmin' via Programming < > programm...@jsoftware.com> wrote: > > > > The signature for af_add: > > > > af_add (af_array *out, const af_array lhs, const af_array rhs, const > bool batch) > > > > with lhs and rhs as parameter names, I don't think J users would get > lost if they called the "cover function" dyadically the same way they call + > > > > I'm not suggesting altering any existing code that does follow the "C > spec" closely. Just adding adverbs on top of them to provide an intuitive > J interface to the functions. > > > > consider the J function > > > > insert =: 1 : 'u/"x y' (_&$: :) > > > > it is "monadic only" version of /. With optional rank parameter as > dyadic number > > > > + insert i.3 3 > > > > 9 12 15 > > > > 1 + insert i.3 3 > > > > 3 12 21 > > > > J does not need such an adverb ("x is easy to type/add and "name context > free"), but "lesser languages" do. Although when they do use such an > implementation, they capture the full flexibility of ranked-modified > insert. A more important flexibility than being able to turn insert into, > a very different adverb, table. > > > > this insert adverb definition would work like a lesser language > modifier > > > > like af_sum, af_product group. > > > > One of the reasons to make this consistency change is to simplify > conversion to and from J<->arrayfire including the great matmul > demonstration you have provided. > > > > > > > > > > > > On Wednesday, January 26, 2022, 12:23:52 p.m. EST, Eric Iverson < > eric.b.iver...@gmail.com> wrote: > > > > > > > > > > > > Pascal, > > > > Interesting ideas on arrayfire args. > > > > I will probably resist the idea of making dop verbs dyadic. I think it > > better to stick closer to the arrayfire syntax. > > > > But it makes sense to avoid unnecessary boxing. > > > > af_add_jaf_ afad;afbd NB. works > > af_add_jaf_ afad,afbd NB. fails, but probably should work > > > > > > > > On Wed, Jan 26, 2022 at 10:03 AM 'Pascal Jasmin' via Programming < > > programm...@jsoftware.com> wrote: > > > >> An interface suggestion would be to transform all verbs that currently > >> take 2 boxed arguments into unboxed dyad arguments. > >> > >> this can be done by adding the adverb (@:;) for the dop class verbs. > and > >> (@:;~) for the reduce class verbs such that the operating axis is the x > >> term. The reduce class could have the additional adverb (0&$: : ) to > make > >> supplying the axis an optional parameter. The explicitly constructed > >> functions in arrayfire.ijs that take 2 boxed y parameters (matmul) can > also > >> be decorated with (@: ;) > >> > >> These changes would more naturally leverage J's processing/modifier > >> capabilities, and processing list of arrayfire array handles. Arrayfire > >> sparse support seems to be limited to rank 2 arrays. J could circumvent > >> these limitations by shaping multiple arrayfire handles managing the > >> nesting logic in J instead. > >> > >> There are many uses of arrayfire that are made easier with a list of > array > >> handles. > >> > >> > >> > >> > >> On Tuesday, January 25, 2022, 04:39:36 p.m. EST, Eric Iverson < > >> eric.b.iver...@gmail.com> wrote: > >> > >> > >> > >> > >> > >> Pascal, > >> > >> Thanks for the feedback. Coming from you, it means a lot to me. > >> > >> There are some rough edges for windows and mac (I work mostly in linux) > >> that I will fix tomorrow morning. > >> > >> On Tue, Jan 25, 2022 at 3:52 PM 'Pascal Jasmin' via Programming < > >> programm...@jsoftware.com> wrote: > >> > >>> looks good. A small bug: > >>> > >>> if you define > >>> > >>> reduce_z_ =: ]: NB. adverb > >>> > >>> prior to loading arrayfire.ijs > >>> > >>> load will fail. > >>> > >>> The reason is the families.ijs file creates a bunch of forks with their > >>> middle verbs defined after the forks are created. > >>> > >>> An easy fix is to define all of the explicit verbs used in families.ijs > >>> above the line that "require families.ijs" > >>> > >>> > >>> fixed it for me. > >>> > >>> > >>> > >>> On Tuesday, January 25, 2022, 10:56:54 a.m. EST, Eric Iverson < > >>> eric.b.iver...@gmail.com> wrote: > >>> > >>> > >>> > >>> > >>> > >>> ~addons/math/arrayfire is a new addon for J903 and later. > >>> > >>> The addon allows high performance computing of matrix product > >>> and many other mathematical array operations. Multiple cpu >
Re: [Jprogramming] isidraw...?
And.. a problem was that gllines was not executing. (gllines <.@(1 2 3 4) forms a verb, but does not execute gllines.) Also, there's an issue where the isidraw does not update when the jqt session window has focus,. FYI, -- Raul On Wed, Jan 26, 2022 at 2:55 PM Raul Miller wrote: > > Ok, so it's not that gllines on isidraw completely fails on my machine. > > That's good to know. > > Thanks, > > -- > Raul > > On Wed, Jan 26, 2022 at 2:25 PM Henry Rich wrote: > > > > Dissect uses isidraw and gllines on Jqt. > > > > Henry Rich > > > > On 1/26/2022 11:58 AM, Raul Miller wrote: > > > http://www.rosettacode.org/wiki/Fractal_tree#J > > > > > > I had updated the fractal tree implementation to work with j903. (The > > > previous code did not work with any implementation of J which I have > > > installed on my mac -- apparently Apple's changes mean that j504 and > > > j602 no longer function on this machine.) > > > > > > However, I noticed that the window is slow to come up, and I cannot > > > resize it, > > > > > > So, I changed the implementation: > > > > > > require'gl2' > > > > > > L0=: 50 NB. initial length > > > A0=: 1r8p1NB. initial angle: pi divided by 8 > > > dL=: 0.9 NB. shrink factor for length > > > dA=: 0.75 NB. shrink factor for angle > > > N=: 14NB. number of branches > > > > > > L=: L0*dL^1+i.N NB. lengths of line segments > > > > > > NB. relative angles of successive line segments > > > A=: A0*(dA^i.N) +/\@:*("1) _1 ^ #:i.2 ^ N > > > > > > NB. end points for each line segment > > > P=: 0 0+/\@,"2 +.*.inv (L0,0),"2 L,"0"1 A > > > > > > wd {{)n > > > pc P closeok; > > > setp wh 480 640; > > > cc C isidraw; > > > pshow; > > > }} > > > > > > glclear_jgl2_'' > > > gllines_jgl2_ <.@(10 + ,/"2 P-"1<./,/P) > > > > > > But this version does not draw the fractal tree. > > > > > > Has anyone been able to get gllines to work in an isidraw? > > > > > > Thanks, > > > > > > > > > -- > > This email has been checked for viruses by AVG. > > https://www.avg.com > > > > -- > > For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] isidraw...?
Help is on the way in the next beta, sequences that don't produce a noun will be flagged. Henry Rich On 1/26/2022 5:07 PM, Raul Miller wrote: And.. a problem was that gllines was not executing. (gllines <.@(1 2 3 4) forms a verb, but does not execute gllines.) Also, there's an issue where the isidraw does not update when the jqt session window has focus,. FYI, -- Raul On Wed, Jan 26, 2022 at 2:55 PM Raul Miller wrote: Ok, so it's not that gllines on isidraw completely fails on my machine. That's good to know. Thanks, -- Raul On Wed, Jan 26, 2022 at 2:25 PM Henry Rich wrote: Dissect uses isidraw and gllines on Jqt. Henry Rich On 1/26/2022 11:58 AM, Raul Miller wrote: http://www.rosettacode.org/wiki/Fractal_tree#J I had updated the fractal tree implementation to work with j903. (The previous code did not work with any implementation of J which I have installed on my mac -- apparently Apple's changes mean that j504 and j602 no longer function on this machine.) However, I noticed that the window is slow to come up, and I cannot resize it, So, I changed the implementation: require'gl2' L0=: 50 NB. initial length A0=: 1r8p1NB. initial angle: pi divided by 8 dL=: 0.9 NB. shrink factor for length dA=: 0.75 NB. shrink factor for angle N=: 14NB. number of branches L=: L0*dL^1+i.N NB. lengths of line segments NB. relative angles of successive line segments A=: A0*(dA^i.N) +/\@:*("1) _1 ^ #:i.2 ^ N NB. end points for each line segment P=: 0 0+/\@,"2 +.*.inv (L0,0),"2 L,"0"1 A wd {{)n pc P closeok; setp wh 480 640; cc C isidraw; pshow; }} glclear_jgl2_'' gllines_jgl2_ <.@(10 + ,/"2 P-"1<./,/P) But this version does not draw the fractal tree. Has anyone been able to get gllines to work in an isidraw? Thanks, -- This email has been checked for viruses by AVG. https://www.avg.com -- For information about J forums see 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
Re: [Jprogramming] isidraw...?
Colorized? That would be nice. Thanks, -- Raul On Wed, Jan 26, 2022 at 5:09 PM Henry Rich wrote: > > Help is on the way in the next beta, sequences that don't produce a > noun will be flagged. > > Henry Rich > > On 1/26/2022 5:07 PM, Raul Miller wrote: > > And.. a problem was that gllines was not executing. > > (gllines <.@(1 2 3 4) forms a verb, but does not execute gllines.) > > > > Also, there's an issue where the isidraw does not update when the jqt > > session window has focus,. > > > > FYI, > > > > > > -- > > Raul > > > > On Wed, Jan 26, 2022 at 2:55 PM Raul Miller wrote: > >> Ok, so it's not that gllines on isidraw completely fails on my machine. > >> > >> That's good to know. > >> > >> Thanks, > >> > >> -- > >> Raul > >> > >> On Wed, Jan 26, 2022 at 2:25 PM Henry Rich wrote: > >>> Dissect uses isidraw and gllines on Jqt. > >>> > >>> Henry Rich > >>> > >>> On 1/26/2022 11:58 AM, Raul Miller wrote: > http://www.rosettacode.org/wiki/Fractal_tree#J > > I had updated the fractal tree implementation to work with j903. (The > previous code did not work with any implementation of J which I have > installed on my mac -- apparently Apple's changes mean that j504 and > j602 no longer function on this machine.) > > However, I noticed that the window is slow to come up, and I cannot > resize it, > > So, I changed the implementation: > > require'gl2' > > L0=: 50 NB. initial length > A0=: 1r8p1NB. initial angle: pi divided by 8 > dL=: 0.9 NB. shrink factor for length > dA=: 0.75 NB. shrink factor for angle > N=: 14NB. number of branches > > L=: L0*dL^1+i.N NB. lengths of line segments > > NB. relative angles of successive line segments > A=: A0*(dA^i.N) +/\@:*("1) _1 ^ #:i.2 ^ N > > NB. end points for each line segment > P=: 0 0+/\@,"2 +.*.inv (L0,0),"2 L,"0"1 A > > wd {{)n > pc P closeok; > setp wh 480 640; > cc C isidraw; > pshow; > }} > > glclear_jgl2_'' > gllines_jgl2_ <.@(10 + ,/"2 P-"1<./,/P) > > But this version does not draw the fractal tree. > > Has anyone been able to get gllines to work in an isidraw? > > Thanks, > > >>> > >>> -- > >>> This email has been checked for viruses by AVG. > >>> https://www.avg.com > >>> > >>> -- > >>> For information about J forums see 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 -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] isidraw...?
No, it's an execution error. But colorizing would be a good idea. Henry Rich On 1/26/2022 5:13 PM, Raul Miller wrote: Colorized? That would be nice. Thanks, -- This email has been checked for viruses by AVG. https://www.avg.com -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] isidraw...?
Execution error sounds possibly overbearing. But I guess if it's limited to scripts, and lines which would produce a display result of a non-noun (the sort of thing influenced by 9!:3) if the line were executed outside of a script, that that would be ok. That said... I also kind of like the idea that the edit window for a script could subtly update to represent noun/verb/adverb/conjunction produced during the execution of that script (and reverting back to a default display when the script is edited). Getting that right would take some thought (and time), but code coverage feedback would reduce an entire class of errors. Thanks, -- Raul On Wed, Jan 26, 2022 at 5:15 PM Henry Rich wrote: > > No, it's an execution error. But colorizing would be a good idea. > > Henry Rich > > On 1/26/2022 5:13 PM, Raul Miller wrote: > > Colorized? That would be nice. > > > > Thanks, > > > > > -- > This email has been checked for viruses by AVG. > https://www.avg.com > > -- > For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Find nth duplicate in vector
Unfortunately, Pawel wants 2 f d to be 3 11. However, I find that 3 f d IS 3 11. Other results are a bit strange, too: 4 f d 2 12 8 f d |index error: f | y({~,])x i.~+/\(i.@#~:i.~)y I wasn’t going to post my effort, but it might interest Pawel. This version works on the slightly more intuitive (for me at least, here) origin 1 value of “x”: g =: ] ({~ , ]) (i.~ >./@:(+/\"1)@:(~. =/ ])) 2 g d 2 5 3 g d 3 11 4 g d. NB. also not error-checked, though! |index error: g | 4 g d This is a quick get-around to act as Pawel asks, and to give an empty result rather than an error if nothing satisfies the left argument: h =: (g~ >:)~ :: ‘’ 2 h d 3 11 5 h d #5 h d 0 FWIW, Mike Sent from my iPad > On 26 Jan 2022, at 21:00, Raul Miller wrote: > > Here's a variation that works: > > d=: 1 _1 2 3 4 2 5 6 3 8 10 3 2 > f=: {{y ({~,]) x i.~ +/\(i.@#~:i.~)y }} > 1 f d > 2 5 > 2 f d > 3 8 > > The phrase (i.@# ~: i.~) finds the locations of duplicates > > (i.@#~:i.~) 1 _1 2 3 4 2 5 6 3 8 10 3 2 > 0 0 0 0 0 1 0 0 1 0 0 1 1 > > And, +/\ computes a running sum > +/\(i.@#~:i.~) d > 0 0 0 0 0 1 1 1 2 2 2 3 4 > > With this, we can find the index of the first occurrence of a > duplicate count number using x i.~ ... > > Once we have the index of a duplicate, we can return that index and > the corresponding value from the list. > > -- > Raul > >> On Wed, Jan 26, 2022 at 3:49 PM Pawel Jakubas >> wrote: >> >> It should be of course >> 1 f d >> 2 5 >> >> Would be great if you could decompose your solution and the idea behind the >> solution. Many thanks. >> >> Cheers, >> Pawel >> -- >> For information about J forums see 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
Re: [Jprogramming] ArrayFire addon
Hi, I tried out the add-on, it looks very promising! After managing to install ArrayFire (apparently the logical "apt install" didn't work), I tried the basic tutorial and found the following line causes J to segfault when using the opencl backend: display_jaf_ afaiNB. get AF text display of afai data Using the cpu backend it works fine. I ran through the tutorials, and noted down the following: As a minor note, there's a typo in the basic lab "modadic" and there's a duplicate example for addition. In the gridxy tutorial, there is a 3 in the definition of gridxy that should be replaced with ' ,n, ' in order to make it work for arguments other than 3. There seems to be something off with the sparse example, I get the following: h,.r ┌┬──┐ │values │4 12 11 5 10 7 8 1 3 6 2 9│ ├┼──┤ │rows│0 2 3 5 5 5 6 9 9 10 12 │ ├┼──┤ │cols│8 9 1 0 2 9 3 5 6 4 6 9 │ ├┼──┤ │1 is CSR│1 │ ├┼──┤ │af type │2 │ ├┼──┤ │rank│2 │ ├┼──┤ │af shape│10 10 1 1 │ └┴──┘ data 0 0 0 0 0 0 0 0 4 12 0 11 0 0 0 0 0 0 0 0 5 0 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 0 0 0 8 0 1 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 0 0 0 0 0 0 0 0 0 0 0 2 0 0 9 in which the rows and columns returned by getsparse_jaf_ do not correspond to the data (in rows, there's a 10 and 12, which shouldn't be possible for a 10x10 matrix). Strangely enough, the assertion following those statements holds... I'm curious where this development is going to lead to, and how people are going to make use of it. Is it the idea to, at a certain point, introduce this in the core language? Or provide a sort of transpiler from (perhaps a subset of) J code to the ArrayFire version? Best regards, Jan-Pieter Op wo 26 jan. 2022 om 17:42 schreef Eric Iverson : > Apologies for the rough start. The development was done in linux with > arrayfire installed and not enough attention was paid to other platforms or > new users. The addon has been updated. > > Raul: You were on macOS, which had not been tested at all. It should work > now if arrayfire is installed in folder /opt/arrayfire. > > Michail: You were on windows and it looks as if arrayfire was not > installed. There is now a more informative failure for that case. It should > work once arrayfire is installed. > > Pascal: The families.ijs bug has been fixed. > > Please update the addon and try again. > -- > For information about J forums see http://www.jsoftware.com/forums.htm > -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] ArrayFire addon
rows says: the first entry in col x is the n-th entry in values row 0 0th (if any) row 1 2nd (if any) (so in row 0 we had 2 values) row 2 3rd (if any) (so in row 1 we had 1 value) row 3 5th (if any) (so in row 2 we had 2 values) row 4 5th (if any) (so in row 3 we had 0 values) etc. Am 26.01.22 um 23:37 schrieb Jan-Pieter Jacobs: Hi, I tried out the add-on, it looks very promising! After managing to install ArrayFire (apparently the logical "apt install" didn't work), I tried the basic tutorial and found the following line causes J to segfault when using the opencl backend: display_jaf_ afaiNB. get AF text display of afai data Using the cpu backend it works fine. I ran through the tutorials, and noted down the following: As a minor note, there's a typo in the basic lab "modadic" and there's a duplicate example for addition. In the gridxy tutorial, there is a 3 in the definition of gridxy that should be replaced with ' ,n, ' in order to make it work for arguments other than 3. There seems to be something off with the sparse example, I get the following: h,.r ┌┬──┐ │values │4 12 11 5 10 7 8 1 3 6 2 9│ ├┼──┤ │rows│0 2 3 5 5 5 6 9 9 10 12 │ ├┼──┤ │cols│8 9 1 0 2 9 3 5 6 4 6 9 │ ├┼──┤ │1 is CSR│1 │ ├┼──┤ │af type │2 │ ├┼──┤ │rank│2 │ ├┼──┤ │af shape│10 10 1 1 │ └┴──┘ data 0 0 0 0 0 0 0 0 4 12 0 11 0 0 0 0 0 0 0 0 5 0 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 0 0 0 8 0 1 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 0 0 0 0 0 0 0 0 0 0 0 2 0 0 9 in which the rows and columns returned by getsparse_jaf_ do not correspond to the data (in rows, there's a 10 and 12, which shouldn't be possible for a 10x10 matrix). Strangely enough, the assertion following those statements holds... I'm curious where this development is going to lead to, and how people are going to make use of it. Is it the idea to, at a certain point, introduce this in the core language? Or provide a sort of transpiler from (perhaps a subset of) J code to the ArrayFire version? Best regards, Jan-Pieter Op wo 26 jan. 2022 om 17:42 schreef Eric Iverson : Apologies for the rough start. The development was done in linux with arrayfire installed and not enough attention was paid to other platforms or new users. The addon has been updated. Raul: You were on macOS, which had not been tested at all. It should work now if arrayfire is installed in folder /opt/arrayfire. Michail: You were on windows and it looks as if arrayfire was not installed. There is now a more informative failure for that case. It should work once arrayfire is installed. Pascal: The families.ijs bug has been fixed. Please update the addon and try again. -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- -- mail written using NEO neo-layout.org -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] ArrayFire addon
should have read the first entry in row x … where x is the index of the number in list rows, and n is that number Am 27.01.22 um 01:25 schrieb Hauke Rehr: rows says: the first entry in col x is the n-th entry in values -- -- mail written using NEO neo-layout.org -- For information about J forums see http://www.jsoftware.com/forums.htm