How can one speed up this correlation calculation in R without multicore? I have a colleague who calculates correlations in which one set of scores for a subject (e.g. 100 scores) is correlated with another set of scores for that same subject. The resulting correlation reflects the degree to which those sets of scores are associated for that subject.  He needs to do this for N subjects. Consider the following dataset:
ncol <- 100
nrow <- 100
x <- matrix(rnorm(ncol*nrow),nrow,ncol)
y <- matrix(rnorm(ncol*nrow),nrow,ncol)

The correct output vector of correlations would be:
diag(cor(t(x),t(y)))

Is there a faster way to do this without using a multicore package in R?
 A: While making a call to diag you throw out a lot of information, so you can save time by simply not calculating it. You code is equivalent to:
sapply(1:100,function(i) cor(x[i,],y[i,]))

Extended to reflect comments: This code will be slower for small matrices since it does not use the full "vectorization power" of cor. So, if you'd like to make fast calculations on small matrices, write it as a C chunk. If one would like to parallelize it (again, will be profitable only for large matrices), may use this code replacing sapply with mc.lapply or something like this.
A: This really depends on the relative numbers of "scores" and "subjects". The method you use calculates lots of cross-correlations which are not required. However, if there are relatively few "subjects" relative to "scores", then this probably doesn't matter too much, and the method you suggest is probably as good as anything, as it uses a small number of efficient blas operations. However, if there are a large number of "subjects" relative to scores, then it may well be quicker to loop over the rows computing the correlation for each pair separately, using the code suggested by "mbq". 
A: It might be one of those cases where using a different BLAS engine would help.  But I am not sure of it - it needs testing (and depends on your machine)
