If I understand correctly, you want something like:

  0    1    2    3
  4   15   26   37
 48  159  270  381

  0    1    2    3
  4   25   46   67
 88  509  930 1351

  0    1    2    3
  4   35   66   97
128 1059 1990 2921


This can be done by using a (non reducing modifying) fold. I will also
use non-boxed data.

data=: (3 3 4$i.12),"1 0 (10 20 30)

I don't use the noun 'out', because the first row of each plane will
serve as the initial element. I also separate the modifier verb, so it
is easy to compose another modifier.

NB. a + out * b
modify=: }:@[ + {:@[*}:@]

NB. modify fold a plane
domodify=: 13 :'(]`,:@.(1...@$)y), x modify {:`...@.(1 = #...@$) y'

Though I'm not very happy with this 'ugly' verb, because of the left and
right gerunds to handle the initial state. Perhaps this will serve as a
start for a better solution by the J-experts.

   ([: }:"1 domodify/@|.)"2 data
  0    1    2    3
  4   15   26   37
....
...

But only, if this is what you want :-)
 


Hallo Robert O'Boyle, je schreef op 16-01-10 21:00:
> Hi all
>
>  
>
> I am doing some probabistic population projections and have come up with a
> problem. I have an arbitrary 3 x 3 x 2 matrix
>
>  
>
> data =. (3 3 4$i.12);"1 0 (10 20 30)
>
>  
>
> and a noun out =. 0 0 0 0
>
>  
>
> What I would like to do is separately for each plane of data to apply a verb
> TEST
>
>  
>
> TEST =: 3 : 0
>
> 'a          b' =: y
>
> out       =:         a+out*b
>
> )
>
>  
>
> which multiplies out by the second row scalar, adds this to out and then
> reassigns out. 
>
>  
>
> This works great for a simple matrix 
>
>  
>
> TEST"_1 (0{data)
>
>  
>
> But when I try 
>
>  
>
> TEST"_2 data I get (sorry for the formatting)
>
>  
>
> 0          1          2          3
>
> 4         25         46         67
>
> 128        759       1390       2021
>
>  
>
>      1280       7591      13902      20213
>
>     25604     151825     278046     404267
>
>    768128  4.55476e6  8.34139e6   1.2128e7
>
>  
>
> 7.68128e6  4.55476e7  8.34139e7   1.2128e8
>
> 1.53626e8  9.10952e8  1.66828e9   2.4256e9
>
> 4.60877e9 2.73286e10 5.00483e10 7.27681e10
>
>  
>
> It applies the verb sequentially through all the lists of the 3 planes. What
> I would like is the verb to be applied separately to each plane. In this
> case, I would have the same output for each plane. Ultimately, I will be
> sampling the first row of each plane from a population distribution and then
> undertaking, say, 500 -1000 projections (each of these being a plane in
> data).
>
>  
>
> I have tried a number of rank conjunctions formulations to no avail. I'm
> sure it is simple to do but I am just learning the nuances of the rank
> conjunction.
>
>  
>
> Any help would be most appreciated.
>
>  
>
> Bob
>
>  
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
>   

-- 
Met vriendelijke groet,
=@@i

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to