/* Horizontal Direct Sum Author: Benoit Durocher Cirano Center, Montreal. Tel. (514) 985-4000 ext. 3113 durocheb@CIRANO.UMontreal.CA Date: 28 Aug 95 Provided without guarantee for public non-commercial use. An example: x[2,2]=1 2 3 4;y[2,2]=5 6 7 8; the direct sum would be 6 7 7 8 10 11 11 12 ####################################################################### Syntax: xy = som(x,y) Where x is a NxK matrix y is a NxL matrix xy is a Nx(K*L) matrix ####################################################################### */ proc som(x,y); local rx,ry,cx,cy,xy,ss,qq,col1,col2,colt; rx = rows(x); cx = cols(x); ry = rows(y); cy = cols(y); if ry /= rx; ? "Error, rows don't match!!!"; stop; endif; xy = zeros(rx,1); ss = 1; do while ss <= cx; col1 = x[.,ss]; qq = 1; do while qq <= cy; col2 = y[.,qq]; colt = col1+col2; xy = xy~colt; qq = qq+1; endo; ss = ss+1; endo; xy = xy[.,2:cols(xy)]; retp(xy); endp;