X-Git-Url: http://iramuteq.org/git?p=iramuteq;a=blobdiff_plain;f=Rscripts%2Fmysvd.R;h=596e55bcee3280548de0a73683a9753c9f9cf652;hp=d936196b0d29d645913927b3df96395231402840;hb=b19770356272772c8c8ba75f351520eca186bd19;hpb=22cd27b2bbe9ab1ffa7ef06fa764b5147ae17dad diff --git a/Rscripts/mysvd.R b/Rscripts/mysvd.R index d936196..596e55b 100644 --- a/Rscripts/mysvd.R +++ b/Rscripts/mysvd.R @@ -21,13 +21,24 @@ write.sparse <- function (m, to) { } } } + +write.sparse2 <- function(m, to) { + stopifnot(inherits(m, "dgCMatrix")) + fh <- file(to, open="w") + + wl <- function(...) cat(..., "\n", file=fh) + wl(dim(m), length(m@x)) + +} + +print('FIXME : svdpath hardcoded !!') my.svd <- function(x, nu, nv) { stopifnot(nu==nv) rc <- system(paste("/usr/bin/svd -o /tmp/sout -d", nu, "/tmp/sparse.m")) if (rc != 0) stop("Couldn't run external svd code") d <- scan("/tmp/sout-S", skip=1) -#FIXME : sometimes, libsvdc doesn't find solution with 2 dimensions, but does with 3 +#FIXME : sometimes, svdlibc doesn't find solution with 2 dimensions, but does with 3 if (length(d)==1) { nu <- nu + 1 rc <- system(paste("/usr/bin/svd -o /tmp/sout -d", nu, "/tmp/sparse.m"))