inchol-class.RdThe reduced Cholesky decomposition object
Objects can be created by calls of the form new("inchol", ...).
or by calling the inchol function.
.Data:Object of class "matrix" contains
the decomposed matrix
pivots:Object of class "vector" contains
the pivots performed
diagresidues:Object of class "vector" contains
the diagonial residues
maxresiduals:Object of class "vector" contains
the maximum residues
Class "matrix", directly.
signature(object = "inchol"): returns
the diagonial residues
signature(object = "inchol"): returns
the maximum residues
signature(object = "inchol"): returns
the pivots performed
data(iris)
datamatrix <- as.matrix(iris[,-5])
# initialize kernel function
rbf <- rbfdot(sigma=0.1)
rbf
#> new("rbfkernel", .Data = function (x, y = NULL)
#> {
#> if (!is(x, "vector"))
#> stop("x must be a vector")
#> if (!is(y, "vector") && !is.null(y))
#> stop("y must a vector")
#> if (is(x, "vector") && is.null(y)) {
#> return(1)
#> }
#> if (is(x, "vector") && is(y, "vector")) {
#> if (!length(x) == length(y))
#> stop("number of dimension must be the same on both data points")
#> return(exp(sigma * (2 * crossprod(x, y) - crossprod(x) -
#> crossprod(y))))
#> }
#> }, kpar = list(sigma = 0.1))
#> <bytecode: 0x564204d155f8>
#> <environment: 0x564207ba34b8>
#> attr(,"kpar")
#> attr(,"kpar")$sigma
#> [1] 0.1
#>
#> attr(,"class")
#> [1] "rbfkernel"
#> attr(,"class")attr(,"package")
#> [1] "kernlab"
Z <- inchol(datamatrix,kernel=rbf)
#> Warning: NaNs produced
#> Error in while (residue > tol && counter < maxiter) { if (counter%%BLOCKSIZE == 0) { Tktmp <- matrix(0, m, dim(Tk)[2] + BLOCKSIZE) Tktmp[1:m > 0, 1:(dim(Tk)[2] + BLOCKSIZE) <= dim(Tk)[2]] <- Tk Tk <- Tktmp Ttmp <- matrix(0, dim(T)[1] + BLOCKSIZE, BLOCKSIZE + counter) ind <- 1:(dim(T)[1] + BLOCKSIZE) <= dim(T)[1] ind2 <- 1:(BLOCKSIZE + counter) <= counter Ttmp[ind, ind2] <- T Ttmp[ind == FALSE, ind2 == FALSE] <- diag(1, BLOCKSIZE) T <- Ttmp padded.veck.tmp <- matrix(0, dim(padded.veck)[1] + BLOCKSIZE) padded.veck.tmp[1:(dim(padded.veck)[1] + BLOCKSIZE) <= dim(padded.veck)[1]] <- padded.veck padded.veck <- padded.veck.tmp pivots.tmp <- matrix(0, dim(pivots)[1] + BLOCKSIZE) pivots.tmp[1:(dim(pivots)[1] + BLOCKSIZE) <= dim(pivots)[1]] <- pivots pivots <- pivots.tmp maxresiduals.tmp <- matrix(0, dim(maxresiduals)[1] + BLOCKSIZE) maxresiduals.tmp[1:(dim(maxresiduals)[1] + BLOCKSIZE) <= dim(maxresiduals)[1]] <- maxresiduals maxresiduals <- maxresiduals.tmp if (counter == 0) t <- rep(0, BLOCKSIZE) else t <- rep(0, length(t) + BLOCKSIZE) } veck <- kernelFast(kernel, x, x[index, , drop = FALSE], dota) if (counter == 0) { tau <- sqrt(veck[index]) T[1, 1] <- tau update <- veck/tau } else { padded.veck[1:counter] <- veck[pivots[1:counter]] t[1:counter] <- backsolve(T, k = counter, padded.veck, transpose = TRUE) tau <- as.vector(sqrt(veck[index] - crossprod(t))) T[1:counter, counter + 1] <- t[1:counter] T[counter + 1, counter + 1] <- tau update <- (1/tau) * (veck - Tk %*% t) } Tk[, counter + 1] <- update diag.residues <- diag.residues - update^2 pivots[counter + 1] <- index maxresiduals[counter + 1] <- residue residue <- max(diag.residues) index <- which.max(diag.residues) counter <- counter + 1 if (counter%%blocksize == 0 && (verbose == TRUE)) cat("counter = ", counter, " ", "residue = ", residue, "\n")}: missing value where TRUE/FALSE needed
dim(Z)
#> Error: object 'Z' not found
pivots(Z)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'object' in selecting a method for function 'pivots': object 'Z' not found
diagresidues(Z)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'object' in selecting a method for function 'diagresidues': object 'Z' not found
maxresiduals(Z)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'object' in selecting a method for function 'maxresiduals': object 'Z' not found