Thanks Aai,
Your definition gives the same results for the tests at the end of the article 
as Eugene's original, so we have a working version now.

I imagine it would be preferable to use Eugene's original code as closely as 
possible. Does anyone have a copy of the original Vector article (Vector 11, 3 
(January 1995)) they can check to see what was printed there? Alternatively 
could some of the differences be explained by changes in J since J8?


> From: Aai
> May be this is of some help.
> 
> Playing with combinations of mxp it seems that only(?) applying p=: 0 3
> 1 2 will lead to the same test results. By a small modification of mxp
> you get the same result:
> 
> mxp=: [:C. 1 0;<:@(,~ >:@|.)@>:@+:@i...@-:
> 
>    mxp 4
> 0 3 1 2
> 
> I don't know however if it will work for 6, 8 etc...
> 
> 
> 
> =@@i
> 
> 
> Hallo Sherlock, Ric, je schreef op 27-03-09 10:21:
> > I've been working on the Jacobi's Method article, but have run in to
> a problem with the definition of the verb mxp.
> >
> > >From the Word document:
> >
> > mxp=: [: C. 0: ; <: , (,~ >:@|.)@>:@+:@i.@<:v
> >    mxp 6
> > |value error: v
> > |       mxp 6
> > mxp1=: [: C. 0: ; <: , (,~ >:@|.)@>:@+:@i.@<:
> >    mxp1 6
> > |index error: mxp1
> > |       mxp1 6
> >
> >
> > I suspect that the v on the end is a typo, but even then the verb
> gives an index error.
> >
> > >From the description of what it is supposed to do:
> > ==============================================
> > The subverb mxp (make index permutation) takes a positive even
> integer as argument and yields a list which is a permutation of the
> integers from 0 through one less than the argument. The permutation is
> such that when applied repeatedly to a conforming list, none of the
> successive pairs in the lists are equal.
> > ===============================================
> >
> > ... I came up with the following but I don't think it's quite right.
> Any ideas?
> >
> > mxp2=: [: C. 0 ; (,~ <:@|.)@:>:@:+:@i...@-:
> >    mxp 6
> > 1 3 0 5 2 4
> >
> > ---------------------------------------------------------------------
> -
> > 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

Reply via email to