In http://www.jsoftware.com/pipermail/programming/2006-December/004410.html
I proposed a better oblique:
   obl=: 1 : '(+/"1)@(#: [:i. */)@$ u/. ,'

It is not only faster, it also does not contain the bug you found.

   -~/ obl tab
100.978 0.603 _0.616 _0.544 100.013
   -/ obl tab
100.978 _0.603 0.616 0.544 100.013

   %~/ obl tab
100.978 1.0060079 0.99388057 0.99460713 100.013
   %/ obl tab
100.978 0.99402799 1.0061571 1.0054221 100.013

About performance:

   $TAB=:10000$&.|: tab
2 10000

   ts'%~/ /. TAB'
0.05099115 5973824
   ts'%~/ obl TAB'
0.019744517 1962560             NB. faster
   (%~/ obl -: %~/ /.) TAB
1

   (%/ obl -: %/ /.) TAB
0                                       NB. no surprise
   ts'%/ obl TAB'
0.0033366463 1215552
   ts'%/ /. TAB'
0.00051275486 132224            NB. ???????

With minus the same phenomena can be observed.


R.E. Boss



> -----Oorspronkelijk bericht-----
> Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens
> Mike Day
> Verzonden: vrijdag 8 juni 2007 8:51
> Aan: [email protected]
> Onderwerp: [Jbeta] Problem with oblique - was Re: [Jprogramming]
> re:tacticprogramming
> 
> The recent correspondence under the former heading
> appears to demonstrate a problem with   u//.   for
> non-commutative u . The value delivered is the same
> as u~//.
> 
> eg (with extra line throws in case some are ignored)
> 
>    tab  NB. 2 row matrix
> 
> 100.978 100.368 100.663 100.874
> 100.971 100.047  100.33 100.013
> 
>    </.tab  NB. the boxed arguments for oblique
> 
> +-------+---------------+---------------+--------------+-------+
> |100.978|100.368 100.971|100.663 100.047|100.874 100.33|100.013|
> +-------+---------------+---------------+--------------+-------+
> 
>    -//.tab  NB. try subtract
> 
> 100.978 0.603614 _0.615946 _0.54397 100.013
> 
>    -~//.tab
> 100.978 0.603614 _0.615946 _0.54397 100.013
> 
>    -/ each </. tab  NB. correct result?!
> +-------+---------+--------+-------+-------+
> |100.978|_0.603614|0.615946|0.54397|100.013|
> +-------+---------+--------+-------+-------+
> 
> 
>    %//.tab  NB. try divide
> 
> 100.978 1.00601 0.993881 0.994607 100.013
> 
>    %~//.tab
> 
> 100.978 1.00601 0.993881 0.994607 100.013
> 
> 
>    !//.tab  NB. try "out of"
> 
> 100.978 0.0275227 19.149 13.8644 100.013
> 
>    !~//.tab
> 
> 100.978 0.0275227 19.149 13.8644 100.013
> 
> Two devices at least get round the problem,
> but with considerable loss of elegance:
> 
>    !`!//.tab    NB. Raul (I think)
> 
> 100.978 18.1541 0.0252168 0.041804 100.013
> 
>    !/@:,/.tab   NB. Mike
> 
> 100.978 18.1541 0.0252168 0.041804 100.013
> 
> David Alis's note (below) suggests that
> user-defined verbs are safe.
> 
> Mike
> 
> 
> david alis wrote:
> > On 6/7/07, Mike Day <mike_liz.day at tiscali.co.uk> wrote:
> >> Why doesn't " ~ " work here?  Is this a bug or one of
> >> those features I keep missing?
> > However,
> >   q=.%/
> >   4{.open (q/.@:,:)close
> > 100.617 0.996043 1.00659 1.00291   NB. ok
> >   4{.open (%//.@:,:)close
> > 100.617 1.00397 0.993454 0.997096  NB. not ok
> > Furthermore:
> >   s=.(q/.@:,:)
> >   4{.open (s f.)  close
> > 100.617 1.00397 0.993454 0.997096
> >   4{.open (s )  close
> > 100.617 0.996043 1.00659 1.00291
> >
> > where:
> >   4{."1 open,:close
> > 100.617 100.572 100.706 100.622
> > 100.971 100.047  100.33 100.013
> >
> > Strange that this behaviour wasn't noticed before.
> > What else is would affected by whatever is causing this?
> > ----------------------------------------------------------------------
> > 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