3 proc prompt(value str[])=
4 seq i=[1 for str[byte 0]]
10 var A[N*N], x[N], k[N], y[N] :
22 decin(input, A[(i*n)+j], c)
30 decin(input, k[i], c) :
32 proc produce.xj(value j, chan south) =
33 -- north row: source of x values
37 proc consume.yi(value i, chan east) =
38 -- west column: read y values
41 proc offset(value ki, chan west) =
42 -- east column: source of k offsets
46 proc multiplier(value aij, chan north, south, west, east) =
47 -- middle: responsible for a values
48 var xj, aij.times.xj, yi :
58 west ! yi+aij.times.xj
61 proc sink(chan north) =
62 -- south row: sink for unused outputs
69 chan north.south[(N+1)*N], east.west[N*(N+1)] :
71 par j= [0 for n] -- producer of co-ordinates x[j]
72 produce.xj(j, north.south[j])
74 par -- the matrix multiplier
76 offset(k[i], east.west[(n*n)+i])
79 multiplier(A[(n*i)+j],
81 north.south[(n*(i+1))+j],
83 east.west[i+(n*(j+1))])
85 sink(north.south[(n*n)+j])
88 par i= [0 for n]-- consumer of transformed co-ordinates
89 consume.yi(i, east.west[i])
96 decout(output, y[i], 5)