subdistance <- function(A, B){ svdresult = svd(t(A) %*% B) U = svdresult$u V = svdresult$v O = U %*% t(V); l = norm(A %*% O-B, type = c('F')) return(l) }