R/qgram.R

Defines functions qgram

Documented in qgram

# rational gram schmidt

qgram <- function(x, remove.zero.vectors = TRUE) {

    if (! (is.numeric(x) || is.character(x)))
        stop("'x' not numeric or character")
    if (is.numeric(x))
        x <- d2q(x)
    if (! (is.character(x))) stop("Cannot happen!")
    if (! (is.matrix(x)))
        stop("'x' must be matrix")
    stopifnot(is.logical(remove.zero.vectors))
    stopifnot(length(remove.zero.vectors) == 1)

    result <- .Call(C_qgram, x)

    if (remove.zero.vectors) {
        is.zero <- apply(result == "0", 2, all)
        return(result[ , ! is.zero, drop = FALSE])
    } else {
        return(result)
    }
}

Try the rcdd package in your browser

Any scripts or data that you put into this service are public.

rcdd documentation built on April 25, 2023, 1:09 a.m.