简体   繁体   中英

Row Reduction with indexed parameters in GNU APL

I'm using the following data structure:

x1a ← 2 1 ⍴ 1 0
x1b ← ⍬

x2a ← 2 2 ⍴ 1 1 0 0
x2b ← 2 1 ⍴ 1 0

x3a ← 1 2 ⍴ 1 0
x3b ← 1

q ← (x3a x3b) (x2a x2b) (x1a x1b)

And attempting a row reduction equivalent to the following operations:

output ← x3b + x3a +.× x2b + x2a +.× x1a

I was thinking the result would be similar to the following, but I can't get the correct rank/operations working:

{⍵[2] + ⍺[1] +.× ⍵[1]}/q

Appreciate any advice or help!

There are three issues:

  1. You are using ⍵[1] which will give you an enclosed element of . Use "pick" instead.

  2. You have a typo: ⍵[2] should use instead, ie 2⊃⍺

  3. The function you reduce with, expects its right argument to be a two element vector, where it uses only the first element. It therefore needs to return such a structure for the next iteration.

Also note that the result will both be enclosed due to / needing to reduce the rank from 1 to 0, and furthermore will have the inserted dummy element, so we need to pick the first element of the only element, that is, ⍬ 1⊃ :

      x3b + x3a +.× x2b + x2a +.× x1a
3
      ⍬ 1⊃{((2⊃⍺) + (1⊃⍺) +.× (1⊃⍵)) 'dummy'}/q
3

Try it online!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM