Re: [Jprogramming] Question about foreign 2!:0
Yes, in j806, 2!:0 had changed and implemented using posix_spawn(), but macos still remained the same and continued to use system() . But you got trouble on mac mini not linux. Can you also check running with j805 on linux and mac mini? On Nov 23, 2017 10:49 PM, "J. Patrick Harrington"wrote: > Thanks Chris, > > I'm involved with Thanksgiving right now, but will try this ASAP. > > On Wed, 22 Nov 2017, chris burke wrote: > >> You should be able to do a simple test to see if 2!:0 waits, for example >> as >> below. This does wait on my Mac with the same J as you, except the avx >> version. >> >> F=: jpath '~temp/t1.sh' >> F fwrites~ '#!/bin/bash',LF,'sleep 2',LF,'echo "done"' >> fmakex F >> >> foo=: 3 : 0 >> echo 2!:0 F >> echo 2+3 >> ) >> >> foo'' >> >> On Wed, Nov 22, 2017 at 7:28 PM, J. Patrick Harrington > > >> wrote: >> >> Bill, >>> >>>I've tried that. ../synmod.exe < fort.5 > fort.6 in a terinal >>> window works fine on all three machines. And the directory change >>> is OK. WHen the program fails on the Mac Mini, the J session is >>> left in the /home/tages/tlusty205/synspec/jph directory. >>> >>> Patrick >>> >>> On Thu, 23 Nov 2017, bill lam wrote: >>> >>> You can try executing the cmd in bash shell to verify whether it actually work on the other machine. Also check the cwd in J session to see it is correct. On Nov 23, 2017 12:54 AM, "J. Patrick Harrington" wrote: A>>A problem has surfaced which has me puzzled. I have written a >>> >>> program which needs the results of another program, synmod.exe, which >>> reads in a file, executes for a few seconds, and writes the results > to the file fort.6 (synmod.exe is my modification of a 10,000 line > fortran program). The relevant part of my program is as follows: > > LAM=: IX=: QX=: <'' > 1!:44 '/home/tages/tlusty205/synspec/jph' > 'Ti gi lam1 lam2'=. y > fix55 lam1, lam2NB. put lam1 & lam2 into fort.55 > lngg=. 10^. gi > nh=. -:#Ti > i=. _1 > while. (i=. >:i) Tii=. i{Ti > lngi=. i{lngg > Kbicub Tii, lngi > 2!:0 '../synmod.exe < fort.5 > fort.6' > Z=. lam2 CLEAN Extract'' > 'mu rad deg lam Flx Ia Qa pol'=. Z > LAM=: LAM, IX=: IX, QX=: QX, end. > 1!:44 '/home/tages/J6/SPIN.d' > > The issue here is the Foreign 2!:0. This code works *perfectly* on my > Dell > laptop running >JVERSION > Engine: j806/j64/linux > Release: commercial/2017-11-06T09:54:01 > Library: 8.06.09 > Qt IDE: 1.6.2/5.3.2 > Platform: Linux 64 > Installer: J806 install > InstallPath: /home/tages/j64-806 > > But... the very same code running on either of the other two machines I > use fails. The line 2!:0 '../synmod.exe < fort.5 > fort.6' > should write the results of synmod to the file fort.6, but > instead defines fort.6 but writes nothing to it. Thus the > Extract'' routine fails when it tries to read fort.6. > > I suspect that while 2!:0 waits for synmod.exe to finish, maybe > on my other machines it transfers to the next line of the J code > before fort.6 is written. One of these machines is a Mac Mini running >JVERSION >Engine: j806/j64nonavx/darwin >Release: commercial/2017-11-06T10:18:00 >Library: 8.06.09 >Qt IDE: 1.6.2s/5.6.3 >Platform: Darwin 64 >Installer: J806 install >InstallPath: /users/jph/j64-806 > > So I'm asking if the foreign 2!:0 in some cases returns without > waiting. I thought just 2!:1 did that. > > Apologies for the long-winded post, Patrick > > -- > 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 -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Question about foreign 2!:0
Thanks Chris, I'm involved with Thanksgiving right now, but will try this ASAP. On Wed, 22 Nov 2017, chris burke wrote: You should be able to do a simple test to see if 2!:0 waits, for example as below. This does wait on my Mac with the same J as you, except the avx version. F=: jpath '~temp/t1.sh' F fwrites~ '#!/bin/bash',LF,'sleep 2',LF,'echo "done"' fmakex F foo=: 3 : 0 echo 2!:0 F echo 2+3 ) foo'' On Wed, Nov 22, 2017 at 7:28 PM, J. Patrick Harringtonwrote: Bill, I've tried that. ../synmod.exe < fort.5 > fort.6 in a terinal window works fine on all three machines. And the directory change is OK. WHen the program fails on the Mac Mini, the J session is left in the /home/tages/tlusty205/synspec/jph directory. Patrick On Thu, 23 Nov 2017, bill lam wrote: You can try executing the cmd in bash shell to verify whether it actually work on the other machine. Also check the cwd in J session to see it is correct. On Nov 23, 2017 12:54 AM, "J. Patrick Harrington" wrote: A>>A problem has surfaced which has me puzzled. I have written a program which needs the results of another program, synmod.exe, which reads in a file, executes for a few seconds, and writes the results to the file fort.6 (synmod.exe is my modification of a 10,000 line fortran program). The relevant part of my program is as follows: LAM=: IX=: QX=: <'' 1!:44 '/home/tages/tlusty205/synspec/jph' 'Ti gi lam1 lam2'=. y fix55 lam1, lam2NB. put lam1 & lam2 into fort.55 lngg=. 10^. gi nh=. -:#Ti i=. _1 while. (i=. >:i) fort.6' Z=. lam2 CLEAN Extract'' 'mu rad deg lam Flx Ia Qa pol'=. Z LAM=: LAM, fort.6' should write the results of synmod to the file fort.6, but instead defines fort.6 but writes nothing to it. Thus the Extract'' routine fails when it tries to read fort.6. I suspect that while 2!:0 waits for synmod.exe to finish, maybe on my other machines it transfers to the next line of the J code before fort.6 is written. One of these machines is a Mac Mini running JVERSION Engine: j806/j64nonavx/darwin Release: commercial/2017-11-06T10:18:00 Library: 8.06.09 Qt IDE: 1.6.2s/5.6.3 Platform: Darwin 64 Installer: J806 install InstallPath: /users/jph/j64-806 So I'm asking if the foreign 2!:0 in some cases returns without waiting. I thought just 2!:1 did that. Apologies for the long-winded post, Patrick -- 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] Partitions
Hmm.. and playing with this idea shows that I'm not on quite on the right track for the n-2 case. +/@, (i.3)= -~/~^:2 i.3 18 #3 parMD 5 25 I can get away with bits for the n-1 case, but I need to track two independent free positions for the n-2 case. -- Raul On Thu, Nov 23, 2017 at 5:36 AM, 'Mike Day' via Programmingwrote: > It's pretty efficient though. > > Here's the result of a crude 13 : tacitisation, resulting from replacing > all (i.x) by y, and assuming the single argument is n : > RDM1 =: (([: |. >:/~) #&(,/) ] + (1 j. ] =/ -~/~) #"1"_1 -~/~ ) @: i. @ > <: > > |: RDM1 4 > 0 0 0 0 0 0 > 0 1 1 1 1 1 > 1 0 2 1 2 2 > 2 2 0 2 1 2 > >ts'RDM1 10' > 0.000420082 216064 >ts'rgfMD/9 10' > 0.00145139 27264 > > The main overhead in mine for k=n-1 appears to be in the > makeinsert routine, even with a somewhat more efficient > use of it than in the listing I posted yesterday.I might > special-case it... > > Thanks for using 1j1 in the left arg of # - if I'd ever seen > that, I'd certainly forgotten it! V useful. > > Perhaps best to leave k=3, n-2, etc, to the existing codes. > > I phorgot phumbs... phrom my laptop, > > Mike > > > > On 23/11/2017 09:59, Raul Miller wrote: >> >> Well.. hmm... >> >> Here's the heart of that k=n-1 expression: >> >> (i.x)=/-~/~i.x) >> >> For example: >> (i.4)=/-~/~i.4 >> 1 0 0 0 >> 0 1 0 0 >> 0 0 1 0 >> 0 0 0 1 >> >> 0 1 0 0 >> 0 0 1 0 >> 0 0 0 1 >> 0 0 0 0 >> >> 0 0 1 0 >> 0 0 0 1 >> 0 0 0 0 >> 0 0 0 0 >> >> 0 0 0 1 >> 0 0 0 0 >> 0 0 0 0 >> 0 0 0 0 >> >> (As you can see, it's not incredibly efficient. It might make sense to >> transform one of those dimensions into index values to gain an order >> of magnitude in compactness. You do not have to worry much about index >> values all 0 rows because those get compressed out later. But the >> problem you would have to solve is: what do you replace the rightmost >> # operation with, when working with indices? It will probably be >> something like an index and ravel and then another transformation to >> get the partition control list. On the positive side, this should >> eliminate the need to subtrace/add the rows - which is how I am >> inserting non-zero values into the final rows with that # operation.) >> >> Anyways... >> >> In principle you could use a similar expression with a rank-4 bit >> array which a triangular plane slicing it in a similar fashion (or, >> ok, maybe map that to a rank 3 array of indices). But of course, you >> lose an additional order of magnitude in efficiency from the >> additional array rank - though sparse arrays might help here, >> depending on how the expressions work. But I've not thought up any >> good expressions for constructing that array. >> >> Thanks, >> > > > --- > 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 -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Partitions
It's pretty efficient though. Here's the result of a crude 13 : tacitisation, resulting from replacing all (i.x) by y, and assuming the single argument is n : RDM1 =: (([: |. >:/~) #&(,/) ] + (1 j. ] =/ -~/~) #"1"_1 -~/~ ) @: i. @ <: |: RDM1 4 0 0 0 0 0 0 0 1 1 1 1 1 1 0 2 1 2 2 2 2 0 2 1 2 ts'RDM1 10' 0.000420082 216064 ts'rgfMD/9 10' 0.00145139 27264 The main overhead in mine for k=n-1 appears to be in the makeinsert routine, even with a somewhat more efficient use of it than in the listing I posted yesterday.I might special-case it... Thanks for using 1j1 in the left arg of # - if I'd ever seen that, I'd certainly forgotten it! V useful. Perhaps best to leave k=3, n-2, etc, to the existing codes. I phorgot phumbs... phrom my laptop, Mike On 23/11/2017 09:59, Raul Miller wrote: Well.. hmm... Here's the heart of that k=n-1 expression: (i.x)=/-~/~i.x) For example: (i.4)=/-~/~i.4 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 (As you can see, it's not incredibly efficient. It might make sense to transform one of those dimensions into index values to gain an order of magnitude in compactness. You do not have to worry much about index values all 0 rows because those get compressed out later. But the problem you would have to solve is: what do you replace the rightmost # operation with, when working with indices? It will probably be something like an index and ravel and then another transformation to get the partition control list. On the positive side, this should eliminate the need to subtrace/add the rows - which is how I am inserting non-zero values into the final rows with that # operation.) Anyways... In principle you could use a similar expression with a rank-4 bit array which a triangular plane slicing it in a similar fashion (or, ok, maybe map that to a rank 3 array of indices). But of course, you lose an additional order of magnitude in efficiency from the additional array rank - though sparse arrays might help here, depending on how the expressions work. But I've not thought up any good expressions for constructing that array. Thanks, --- 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
Re: [Jprogramming] Partitions
Well.. hmm... Here's the heart of that k=n-1 expression: (i.x)=/-~/~i.x) For example: (i.4)=/-~/~i.4 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 (As you can see, it's not incredibly efficient. It might make sense to transform one of those dimensions into index values to gain an order of magnitude in compactness. You do not have to worry much about index values all 0 rows because those get compressed out later. But the problem you would have to solve is: what do you replace the rightmost # operation with, when working with indices? It will probably be something like an index and ravel and then another transformation to get the partition control list. On the positive side, this should eliminate the need to subtrace/add the rows - which is how I am inserting non-zero values into the final rows with that # operation.) Anyways... In principle you could use a similar expression with a rank-4 bit array which a triangular plane slicing it in a similar fashion (or, ok, maybe map that to a rank 3 array of indices). But of course, you lose an additional order of magnitude in efficiency from the additional array rank - though sparse arrays might help here, depending on how the expressions work. But I've not thought up any good expressions for constructing that array. Thanks, -- Raul On Thu, Nov 23, 2017 at 3:45 AM, 'Mike Day' via Programmingwrote: > Wow - more than I could manage with my phone and phingers! > > Or desktop! > > So have we got closed forms for k=3, k=n-2? > > M > > > On 23/11/2017 02:49, Raul Miller wrote: >> >> Hmm... right - it corresponds to an upper (or lower) triangular matrix, >> not >> the identity matrix. So... >> >> (|.>:/~i.x)#&(,/)(i.x)+(1 j.(i.x)=/-~/~i.x)#"1"_1-~/~i.x >> >> In other words, once again, oops. (But at least, this time, I tested the >> expression. Though I know it could be refactored to be more concise-- but >> the phone UI is too clumsy for that...) >> >> Thanks, >> > > > --- > 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 -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Partitions
Wow - more than I could manage with my phone and phingers! Or desktop! So have we got closed forms for k=3, k=n-2? M On 23/11/2017 02:49, Raul Miller wrote: Hmm... right - it corresponds to an upper (or lower) triangular matrix, not the identity matrix. So... (|.>:/~i.x)#&(,/)(i.x)+(1 j.(i.x)=/-~/~i.x)#"1"_1-~/~i.x In other words, once again, oops. (But at least, this time, I tested the expression. Though I know it could be refactored to be more concise-- but the phone UI is too clumsy for that...) Thanks, --- 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
Re: [Jprogramming] (no subject)
Thanks Bo, Roger, & Mike. All useful ways to create big integers of all one digit! Skip On Thu, Nov 23, 2017 at 2:37 AM, 'Bo Jacoby' via Programming < programm...@jsoftware.com> wrote: >9%~1-~10^50x > > 11 > without using any array > > > Den 9:33 torsdag den 23. november 2017 skrev 'Skip Cave' via > Programming: > > > Thanks Bo. > I also found this: > (50#10)#.1x > 11 > > Skip Cave > > > On Thu, Nov 23, 2017 at 2:26 AM, 'Bo Jacoby' via Programming < > programm...@jsoftware.com> wrote: > > >+/10^i.50x > > 11 > > > >Den 9:17 torsdag den 23. november 2017 skrev 'Skip Cave' via > > Programming : > > > > > > I want to greate an integer with all ones: > > > > ".10#'1' > > > > 11 > > > > > > datatype ".10#'1' > > > > integer > > > > > > ".15#'1' > > > > 111 > > > > datatype ".15#'1' > > > > integer > > > > > > ".20#'1' > > > > 1.1e19 > > > > > > NB. Drat! it seitched to floating. > > > > > >datatype ".20#'1' > > > > floating > > > > NB. So I need to use extended precision: > > > >x:".20#'1' > > > > 0656 > > > > > > NB. Uh oh! something is wrong. Not all ones! > > > > > >datatype x:".20#'1' > > > > rational > > > > > > NB. Rational? What happened to extended precision? > > > > NB. So how do I create an integer with say, 50 onres? > > > > > >x:".50#'1' > > > > 0805019569335803527359330256945152 > > > > > > NB. Nope! > > > > > > > > Skip Cave > > -- > > 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] (no subject)
or with a scalar power: (,~#@:":) (9%~<:&(10&^)@: x:) 50 NB. showing result and its size 50 11 OK? Mike On 23/11/2017 08:26, 'Bo Jacoby' via Programming wrote: +/10^i.50x 11 Den 9:17 torsdag den 23. november 2017 skrev 'Skip Cave' via Programming: I want to greate an integer with all ones: ".10#'1' 11 datatype ".10#'1' integer ".15#'1' 111 datatype ".15#'1' integer ".20#'1' 1.1e19 NB. Drat! it seitched to floating. datatype ".20#'1' floating NB. So I need to use extended precision: x:".20#'1' 0656 NB. Uh oh! something is wrong. Not all ones! datatype x:".20#'1' rational NB. Rational? What happened to extended precision? NB. So how do I create an integer with say, 50 onres? x:".50#'1' 0805019569335803527359330256945152 NB. Nope! Skip Cave -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm --- 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
Re: [Jprogramming] (no subject)
(15#10)#.15#1 111 (25x#10x)#.25x#1x 1 /Erling Den 2017-11-23 kl. 09:17, skrev 'Skip Cave' via Programming: I want to greate an integer with all ones: ".10#'1' 11 datatype ".10#'1' integer ".15#'1' 111 datatype ".15#'1' integer ".20#'1' 1.1e19 NB. Drat! it seitched to floating. datatype ".20#'1' floating NB. So I need to use extended precision: x:".20#'1' 0656 NB. Uh oh! something is wrong. Not all ones! datatype x:".20#'1' rational NB. Rational? What happened to extended precision? NB. So how do I create an integer with say, 50 onres? x:".50#'1' 0805019569335803527359330256945152 NB. Nope! Skip Cave -- 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] (no subject)
10#.40#1x datatype 10#.40#1x extended Sent from Mail for Windows 10 From: 'Skip Cave' via Programming Sent: Thursday, November 23, 2017 3:17 AM To: programm...@jsoftware.com Subject: [Jprogramming] (no subject) I want to greate an integer with all ones: ".10#'1' 11 datatype ".10#'1' integer ".15#'1' 111 datatype ".15#'1' integer ".20#'1' 1.1e19 NB. Drat! it seitched to floating. datatype ".20#'1' floating NB. So I need to use extended precision: x:".20#'1' 0656 NB. Uh oh! something is wrong. Not all ones! datatype x:".20#'1' rational NB. Rational? What happened to extended precision? NB. So how do I create an integer with say, 50 onres? x:".50#'1' 0805019569335803527359330256945152 NB. Nope! Skip Cave -- 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] (no subject)
Thanks Bo. I also found this: (50#10)#.1x 11 Skip Cave On Thu, Nov 23, 2017 at 2:26 AM, 'Bo Jacoby' via Programming < programm...@jsoftware.com> wrote: >+/10^i.50x > 11 > > Den 9:17 torsdag den 23. november 2017 skrev 'Skip Cave' via > Programming: > > > I want to greate an integer with all ones: > > ".10#'1' > > 11 > > > datatype ".10#'1' > > integer > > > ".15#'1' > > 111 > > datatype ".15#'1' > > integer > > > ".20#'1' > > 1.1e19 > > > NB. Drat! it seitched to floating. > > > datatype ".20#'1' > > floating > > NB. So I need to use extended precision: > > x:".20#'1' > > 0656 > > > NB. Uh oh! something is wrong. Not all ones! > > > datatype x:".20#'1' > > rational > > > NB. Rational? What happened to extended precision? > > NB. So how do I create an integer with say, 50 onres? > > > x:".50#'1' > > 0805019569335803527359330256945152 > > > NB. Nope! > > > > Skip Cave > -- > 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] (no subject)
+/10^i.50x 11 Den 9:17 torsdag den 23. november 2017 skrev 'Skip Cave' via Programming: I want to greate an integer with all ones: ".10#'1' 11 datatype ".10#'1' integer ".15#'1' 111 datatype ".15#'1' integer ".20#'1' 1.1e19 NB. Drat! it seitched to floating. datatype ".20#'1' floating NB. So I need to use extended precision: x:".20#'1' 0656 NB. Uh oh! something is wrong. Not all ones! datatype x:".20#'1' rational NB. Rational? What happened to extended precision? NB. So how do I create an integer with say, 50 onres? x:".50#'1' 0805019569335803527359330256945152 NB. Nope! Skip Cave -- 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] (no subject)
I want to greate an integer with all ones: ".10#'1' 11 datatype ".10#'1' integer ".15#'1' 111 datatype ".15#'1' integer ".20#'1' 1.1e19 NB. Drat! it seitched to floating. datatype ".20#'1' floating NB. So I need to use extended precision: x:".20#'1' 0656 NB. Uh oh! something is wrong. Not all ones! datatype x:".20#'1' rational NB. Rational? What happened to extended precision? NB. So how do I create an integer with say, 50 onres? x:".50#'1' 0805019569335803527359330256945152 NB. Nope! Skip Cave -- For information about J forums see http://www.jsoftware.com/forums.htm