doichunk <- function(ichunk) { tot <- 0 nr <- nrow(lnks) for (i in ichunk) { tmp <- lnks[(i+1):nr,] %*% lnks[i,] tot <- tot + sum(tmp) } tot}