cc_svd | R Documentation |
Conjugate complement of span(X) in span(Z) with respect to inner product ip
cc_svd(X, Z = NULL, ip = NULL, tol = 1e-14)
cc_qr(X, Z = diag(NROW(X)), ip = diag(NROW(X)), tol = 1e-14)
X |
matrix defining space whose complement is computed. Not necessarily of full column rank |
Z |
matrix defining space within which the complement is computed. Should be of full column rank. Default: diag(nrow(X)) |
ip |
positive definite matrix defining inner product with respect to which complement is computed. Default: diag(nrow(X)) |
tol |
tolerance (default 1e-14) |
cc_qr()
: Conjugate complement using QR algorithm
#' cc_svd(cbind(1:3))
cc_svd(cbind(1:3), cbind(1:3,1))
cc_svd(cbind(1:3), cbind(3*c(1,-2,1), 1:3,1))
# challenge with large numbers
K <- cc_svd(cbind(1,1:10,(1:10)^2))
K
ret <- list()
for(i in 1:20){
cbind(1,(1:10-10^i)^2,1:10) %>%
{ list(svd = ccor(cc_svd(.), K) -1, qr =ccor(cc_qr(.), K) -1)
} %>% lapply(abs) %>%
{list(med=lapply(.,median), ave = lapply(.,mean))} %>% unlist->ret[[i]]
}
ret <- do.call(rbind, ret)
ret
library(lattice)
library(latticeExtra)
xyplot(ts(log2(ret)), scales = list(y = 'same'), ylab = 'cancorr: log base 2 of deviation from 1')
#
# challenge with small numbers
#
i <- 1
K <- cc_svd(cbind(1,1:10,(1:10 == 1)* 10^{-i}))
K
ret <- list()
for(i in 1:30){
cbind(1,1:10,(1:10 == 1)* 10^{-i}) %>%
{ list(svd = ccor(cc_svd(.), K) -1, qr =ccor(cc_qr(.), K) -1)
} %>% lapply(abs) %>%
{list(med=lapply(.,median), ave = lapply(.,mean))} %>% unlist->ret[[i]]
}
ret <- do.call(rbind, ret)
ret
xyplot(ts(log2(ret)), scales = list(y = 'same'), ylab = 'cancorr: log base 2 of deviation from 1')
#
# challenge with small numbers added to 1
#
i <- 1
K <- cc_svd(cbind(1,1:10,1+(1:10 == 1)* 10^{-i}, (1:10 != 1)))
K
ret <- list()
for(i in 1:30){
cbind(1,1:10, 1 + (1:10 == 1)* 10^{-i}) %>%
{ list(svd = ccor(cc_svd(.), K) -1, qr =ccor(cc_qr(.), K) -1)
} %>% lapply(abs) %>%
{list(med=lapply(.,median), ave = lapply(.,mean))} %>% unlist->ret[[i]]
}
ret <- do.call(rbind, ret)
ret
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.