Generate vectors A and B;

perform an outer product to create a rectangular array C;

transpose C to obtain T;

perform an outer product (matrix multiply) to obtain O;

solve C to obtain S.

- Code: Select all
`A ← ⍳ 5`

A

1 2 3 4 5

B ← ⍳ 9

B

1 2 3 4 5 6 7 8 9

C ← A ∘.× B

C

1 2 3 4 5 6 7 8 9

2 4 6 8 10 12 14 16 18

3 6 9 12 15 18 21 24 27

4 8 12 16 20 24 28 32 36

5 10 15 20 25 30 35 40 45

T ← ⍉ C

T

1 2 3 4 5

2 4 6 8 10

3 6 9 12 15

4 8 12 16 20

5 10 15 20 25

6 12 18 24 30

7 14 21 28 35

8 16 24 32 40

9 18 27 36 45

O ← C +.× T

O

285 570 855 1140 1425

570 1140 1710 2280 2850

855 1710 2565 3420 4275

1140 2280 3420 4560 5700

1425 2850 4275 5700 7125

S ← C ⌹ A

S

1 2 3 4 5 6 7 8 9

Expressed in aplc's ascii notation :

- Code: Select all
`'A:'`

A .is .iota 5

A

' '

'B:'

B .is .iota 9

B

' '

'C: inner product:'

C .is A .jot . .times B

C

' '

'T: transpose:'

T .is .tr C

T

' '

'O: outer product (matrix multiply):'

O .is C + . .times T

O

' '

'S: solve matrix:'

S .is C .domino A

S

This runs fine, but is surprisingly slow, even given most of this code is running in the library, in external DRAM :

- Code: Select all
`14: Message from eCore 0x8cb ( 3, 3): "A:`

1 2 3 4 5

B:

1 2 3 4 5 6 7 8 9

C: outer product:

1 2 3 4 5 6 7 8 9

2 4 6 8 10 12 14 16 18

3 6 9 12 15 18 21 24 27

4 8 12 16 20 24 28 32 36

5 10 15 20 25 30 35 40 45

T: transpose:

1 2 3 4 5

2 4 6 8 10

3 6 9 12 15

4 8 12 16 20

5 10 15 20 25

6 12 18 24 30

7 14 21 28 35

8 16 24 32 40

9 18 27 36 45

O: inner product (matrix multiply):

285 570 855 1140 1425

570 1140 1710 2280 2850

855 1710 2565 3420 4275

1140 2280 3420 4560 5700

1425 2850 4275 5700 7125

S: solve matrix:

1 2 3 4 5 6 7 8 9

"

In fact to solve the matrix, the delay has to be increased beyond 10s. For comparison, on a NIOS II soft processor on a low-grade FPGA, there is just a noticeable delay for the matrix to solve. Perhaps there is severe memory contention ?

It is also possible that the residual precision being asked of the solve is in appropriate, but it has not needed changing for other computer hosts, and should be set in the aplc building stage by configure.