Dear S-users
I have a n*m matrix A and a m*n matrix B where n is large (say 10000).
The measure I'm interested in is
> max(diag(A%*%B))
However the calculation above takes too long, has to calculate many things
I don't need (the off-diagonal elements) and uses too much memory for
n large.
Of course I could avoid the matrix multiplication by using a for-loop, i.e.
> x <- vector("numeric",10000)
> for (index in 1:10000)
> { x[index] <- A[index,]%*%B[,index] }
> max(x)
But there must be a more efficient way to do it...
It should be easy but I just can't find it.
Thanks a lot for your help.
Marcel Wolbers
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news
|