Trying to translate some parts of pathstensor from part IV:
The part with 'multinomial' * sign:
multinomial [na,nb] * (-1)^nb
can be interpreted as:
mnpd=: (0&(,+,~)^: (]`1:))*(_1&*^:(<@(1&+)`(_1&^)))
(not really a first shot for) emulating mulArray and powers_of:
a=: _2]\ _2 1 _1 1 0 0 1 1 2 1
b=: _2]\ _2 1 _1 _1 0 0 1 _1 2 1
mularr=: [:({...@{.,+/@{:)@|:/.({.,{:)@(+,*)"1"1 _
powers_of=: 4 : 0
if. 0=y do. 0 1 return. end.
if. 1=y do. x return. end.
x&mularr^: (y-1) x
)
Some examples:
a powers_of 0
0 1
a powers_of 1
_2 1
_1 1
0 0
1 1
2 1
a powers_of 2
_4 1
_3 2
_2 1
_1 2
0 4
1 2
2 1
3 2
4 1
However they will be way too slow for pathstensor 100 (4,4). So
something to chew on.
... still trying to wrap my brain around 'mulSquareAt arr arr (i,j)' and
all the other stuff :-)
=@@i
Tracy Harms schreef:
> There is a lot of array-oriented thinking in a series of four blog
> posts by Twan van Laarhoven. The ideas include tensor product of rings
> and arrays as polynomials. Although his code is in Haskell, some here
> may share my interest in what he's written. I won't be surprised if
> somebody finds something fun to translate into J, or to do differently
> in J.
>
> Part one is here:
> http://twan.home.fmf.nl/blog/haskell/Knight1.details
>
> The overall blog post series (with all four parts) is here:
> http://twan.home.fmf.nl/blog/
>
> The problem examined is: A knight is placed at the origin of a
> chessboard that is infinite in all directions. How many ways are there
> for that knight to reach cell (i,j) in exactly n moves?
>
> --
> Tracy
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
>
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm