I am looking for an efficient algorithm to perform the below function:
for(j in 1:nrow) { #begin loop over j from 1 to nrow
xJ=vectorX1[j] #some random vector
yJ=vectorY1[j] #some random vector
for(ij in j:nrow) { #begin loop over ij from j to nrow
xIJ=vectorX1[ij] #some random vector
yIJ=vectorX1[ij] #some random vector
if(j != ij) { #only perform on unique pairs
XX=myfun(xJ, yJ, xIJ, yIJ)
}
}
}
My vectors are pretty long do the for loops are time sinks. Any help would be greatly appreciated.