Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- get_tau<-function(cp.table){
- N <- nrow(cp.table);
- iseq <- 1:N;
- tau<-apply(as.matrix(iseq), 2,
- function (i,j) {
- sqrt((cp.table$x[i] - cp.table$x[j])^2 + (cp.table$y[i] - cp.table$y[j])^2)
- },
- j=1);
- for(j in 2:N) {
- tau <- cbind(tau,
- apply(as.matrix(iseq), 2,
- function(i,j) {
- sqrt((cp.table$x[i]-cp.table$x[j])^2 + (cp.table$y[i]-cp.table$y[j])^2)
- },
- j)
- )
- };
- return (tau);
- }
- get_tau2<-function(cp.table){
- N <- nrow(cp.table);
- g <- as.matrix(expand.grid(1:N, 1:N))
- tau<-apply(as.matrix(g), 1,
- function (index) {
- sqrt((cp.table$x[index[1]] - cp.table$x[index[2]])^2 +
- (cp.table$y[index[1]] - cp.table$y[index[2]])^2)
- }
- );
- return (matrix(tau, nrow=N));
- };
- get_tau3<-function(cp.table){
- N <- nrow(cp.table);
- iseq <- 1:N;
- sapply(as.list(iseq),
- function(j) {
- f.int <- function (i, j) {
- return(sqrt((cp.table$x[i] - cp.table$x[j])^2 + (cp.table$y[i] - cp.table$y[j])^2))
- }
- return (apply(as.matrix(iseq), 2, f.int, j))
- }
- )
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement