[R] horizontal direct product

2006-08-25 Thread Luke Keele
II am translating some gauss code into R, and gauss has a matrix product function called the horizontal direct product (*~), which is some sort of variant on the Kronecker product. For example if x is 2x2 and y is 2x2 the horizontal direct product, z, of x and y is defined (in the Gauss

Re: [R] horizontal direct product

2006-08-25 Thread Dimitrios Rizopoulos
maybe something like: %*~% - function(x, y){ n - nrow(x) out - matrix(0, n, ncol(x) * ncol(y)) for(i in 1:n) out[i, ] - c(y[i, ] %o% x[i, ]) out } x - matrix(1:4, 2, 2, TRUE) y - matrix(5:8, 2, 2, TRUE) x %*~% y I hope it helps. Best, Dimitris Dimitris

Re: [R] horizontal direct product

2006-08-25 Thread Thomas Lumley
On Fri, 25 Aug 2006, Luke Keele wrote: II am translating some gauss code into R, and gauss has a matrix product function called the horizontal direct product (*~), which is some sort of variant on the Kronecker product. For example if x is 2x2 and y is 2x2 the horizontal direct product, z,