Re: [Jprogramming] Nested looping for a newbie in J

2013-05-26 Thread Olivier N.
In Elton Wang's implementation, I can see one trivial change that might help: +/+/+/(57=x+/y+/z)*x/y*y/z Where x=.y=.z=i.29 could instead use +/,(57=x+/y+/z)*x/y*y/z Oh yes, good point. Is there a way to test resource (cpu, mem, time) usage within J? or, if you prefer

[Jprogramming] Fwd: Do Out of memory errors vary by J implementation?

2013-05-26 Thread Jeremy Smith
Hi everyone, I was trying to take 9 boxes and multiply them all together, storing the output in a single box. The first of the 9 boxes contains 12 numbers, the second contains 11, and so on, so that the output of this calculation will be a single box with 12*11*10*9*8*7*6*5*4=79,833,600 numbers.

Re: [Jprogramming] Fwd: Do Out of memory errors vary by J implementation?

2013-05-26 Thread Raul Miller
The OS must indeed supply the memory used by J and it's up to the OS to decide whether it can do so or not. Memory fragmentation can be an issue - rebooting might help the OS here, in some cases. Another issue is virtual memory (swapping to disk, and how that has been implemented). That said,

Re: [Jprogramming] Fwd: Do Out of memory errors vary by J implementation?

2013-05-26 Thread Dan Bron
Can you post your commands? It would be an interesting exercise trying to optimize for performance. -Dan Please excuse typos; composed on a handheld device. On May 26, 2013, at 10:26 AM, Jeremy Smith actuaryjeremysm...@gmail.com wrote: Hi everyone, I was trying to take 9 boxes and

Re: [Jprogramming] Fwd: Do Out of memory errors vary by J implementation?

2013-05-26 Thread William Tanksley, Jr
Out of memory errors are notoriously hard to debug; if you need to run this program on any different data than what you're using now I'd take up the offer to come up with an alternate approach. By the way, it's common for different oses to display different behavior under pressure. Windows fails

Re: [Jprogramming] Fwd: Do Out of memory errors vary by J implementation?

2013-05-26 Thread Linda Alvord
-Original Message- From: programming-boun...@forums.jsoftware.com [mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Raul Miller Sent: Sunday, May 26, 2013 10:49 AM To: Programming forum Subject: Re: [Jprogramming] Fwd: Do Out of memory errors vary by J implementation? The

Re: [Jprogramming] Fwd: Do Out of memory errors vary by J implementation?

2013-05-26 Thread Linda Alvord
Windows Vista 32 bit: f=: 13 :'(y#1)*/i.y' ]A=:f 12 0 1 2 3 4 5 6 7 8 9 10 11 0 1 2 3 4 5 6 7 8 9 10 11 0 1 2 3 4 5 6 7 8 9 10 11 0 1 2 3 4 5 6 7 8 9 10 11 0 1 2 3 4 5 6 7 8 9 10 11 0 1 2 3 4 5 6 7 8 9 10 11 0 1 2 3 4 5 6 7 8 9 10 11 0 1 2 3 4 5 6 7 8 9 10 11 0 1 2 3 4 5 6 7 8 9 10 11 0 1 2

Re: [Jprogramming] Do Out of memory errors vary by J implementation?

2013-05-26 Thread Jeremy Smith
Can you post your commands? It would be an interesting exercise trying to optimize for performance. -Dan I will be happy to share my commands, with the disclaimer that I'm a novice at J. My approach is simply what I've been able to cobble together in isolation. Suppose you have the

Re: [Jprogramming] Nested looping for a newbie in J

2013-05-26 Thread Robert Herman
I have worked through the solution arrived at by a few of you to better learn J, namely this one: +/,(57=x+/y+/z)*x/y*y/z In order to fully understand the way the matrix operations are carried out, I minimized the answer space by making P = 13, and worked through the output (not shown for

Re: [Jprogramming] Nested looping for a newbie in J

2013-05-26 Thread Raul Miller
[this is my second attempt at sending - my first attempt at sending seemed to succeed, but gmail later declared that this was still a draft.] On Sun, May 26, 2013 at 8:48 AM, Olivier N. onemailid4mailingli...@edpnet.be wrote: In Elton Wang's implementation, I can see one trivial change that

Re: [Jprogramming] Nested looping for a newbie in J

2013-05-26 Thread Robert Herman
Sorry about the small font in the last post, corrected here: I need to work on the last bit with the [/] in it, and the use of ~ here. It is sometimes hard for a beginner to realize where one word begins and another ends, or if they are combinations (dyads). It took me a while to get the * as a

Re: [Jprogramming] Nested looping for a newbie in J

2013-05-26 Thread Bo Jacoby
Raul wrote: I think that any time we delve into some area of computation that leaving and coming back after an extended absence can leave us in a jarring situation where we need to reacquaint ourselves with the original topic. I do not know of any general cure for this, finding good names for

Re: [Jprogramming] Nested looping for a newbie in J

2013-05-26 Thread Robert Herman
My reference to Perl's output was of the solutions printed on the count lines such as this: 1: 2 27 28 2: 3 26 28 3: 4 25 28 . 60: 17 19 21 61: 18 19 20 Total 61 Raul, thank you so much for your other pointers on inspecting the arrays. I will have two more days after work going over all of

Re: [Jprogramming] Nested looping for a newbie in J

2013-05-26 Thread Robert Herman
Couldn't sleep. Turns out it soesn't take too long to brute force it by pencil and paper. Given z is 28..1, y is 27..1 and x is 26..1, you start with z at 28 and y at 27 and x at 2. It took me 15 minutes to enumerate the list of 61 solutions. Certainly not near J's speed, but I would have thought

[Jprogramming] How read text file, sort its lines, write it back out?

2013-05-26 Thread Murray Eisenberg
I'm really out of practice with J, and the meager-to-nonexistent documentation is not helping me. I have a very simple task to perform. I have a text file infile.txt on my desktop and here's what I want to do: (1) read the file as lines (so I don't get all the end-of-line symbols); (2) sort

Re: [Jprogramming] Nested looping for a newbie in J

2013-05-26 Thread Brian Schott
Is this a start to your indexing request? $. produces a sparse array. $. ((57=[+/+/)*[/]*/)~ i. 29 2 27 28 | 1 3 26 28 | 1 4 25 28 | 1 4 26 27 | 1 5 24 28 | 1 [...] 17 18 22 | 1 17 19 21 | 1 18 19 20 | 1 On Sun, May 26, 2013 at 2:54 PM, Robert Herman rpjher...@gmail.com wrote: My

Re: [Jprogramming] How read text file, sort its lines, write it back out?

2013-05-26 Thread Brian Schott
It looks as though your version of 'text.ijs' does NOT include cuttext. On Sun, May 26, 2013 at 3:50 PM, Murray Eisenberg mur...@math.umass.eduwrote: I'm really out of practice with J, and the meager-to-nonexistent documentation is not helping me. I have a very simple task to perform. I have

Re: [Jprogramming] How read text file, sort its lines, write it back out?

2013-05-26 Thread Don Guinn
sortandprint=:4 : 0 text=.'b' fread y text=./:~text text=.text,.LF (;text) fwrite x ) The 'b' option means box each line. y is file to read, x is file to write sorted. If you are dealing with windows and need CRLF as a line separator, replace the LF with CRLF. On Sun, May 26, 2013 at

Re: [Jprogramming] Nested looping for a newbie in J

2013-05-26 Thread elton wang
to index the solution: ind=. (57=x+/y+/z)*x/y*y/z triples =. _3 ]\ x,0 1/y,0 0/z ans =. (,ind) # triples From: Robert Herman rpjher...@gmail.com To: programm...@jsoftware.com Sent: Sunday, May 26, 2013 2:01 PM Subject: Re: [Jprogramming] Nested looping for a

Re: [Jprogramming] Nested looping for a newbie in J

2013-05-26 Thread elton wang
There was a missing , in triples in my previous message. But Brian's answer is the most direct one. $.  triples =. _3 ]\ ,x,0 1/y,0 0/z From: elton wang ahala2...@yahoo.com To: programm...@jsoftware.com programm...@jsoftware.com Sent: Sunday, May 26, 2013

Re: [Jprogramming] newbie help: how to avoid division by zero

2013-05-26 Thread Don Kelly
how about (phase-/phase)%lineReactance note that the diagonal elements of phase-/phase will be 0 but also note that with line reactances of 0 the 0/0 terms will be 0 however- the problems may well be with the non zero phase differences and 0 reactances. so you need to eliminate the

Re: [Jprogramming] How read text file, sort its lines, write it back out?

2013-05-26 Thread Raul Miller
One issue is that J's ~ convention is not the OS convention, so you will need to deal with that. If you are not on windows (which is probably the case if you are using a ~ OS convention), you can use HOME=: 2!:5'HOME' INFILE=: HOME,'/Desktop/infile.txt' OUTFILE=: HOME,'/DESKTOP/outfile.txt'

Re: [Jprogramming] Nested looping for a newbie in J

2013-05-26 Thread Raul Miller
On Sun, May 26, 2013 at 2:54 PM, Robert Herman rpjher...@gmail.com wrote: My reference to Perl's output was of the solutions printed on the count lines such as this: 1: 2 27 28 2: 3 26 28 3: 4 25 28 . 60: 17 19 21 61: 18 19 20 Total 61 I see that you have already been given an

[Jprogramming] Clean

2013-05-26 Thread km
Let's say a real number ought to be zero if its absolute value is : the comparison tolerance 2^_44 . Write a verb clean that replaces real numbers that ought to be zero with zero. How would you clean a complex number? 1 o. 1r2p1 * i. 5 0 1 1.22465e_16 _1 _2.44929e_16 clean 1 o. 1r2p1

Re: [Jprogramming] Clean

2013-05-26 Thread Roger Hui
clean=: (* |@*).+. Eugene McDonnell objected when we made *x to be 0 for x near 0, saying that *x should be 0 only if x is 0. On Sun, May 26, 2013 at 9:32 PM, km k...@math.uh.edu wrote: Let's say a real number ought to be zero if its absolute value is : the comparison tolerance 2^_44 .

Re: [Jprogramming] Clean

2013-05-26 Thread km
I didn't think of Signum! Thanks, Roger. Sent from my iPad On May 26, 2013, at 11:56 PM, Roger Hui rogerhui.can...@gmail.com wrote: clean=: (* |@*).+. Eugene McDonnell objected when we made *x to be 0 for x near 0, saying that *x should be 0 only if x is 0. On Sun, May 26, 2013 at