R/utils.R

Defines functions oracFun oraculumLi

# Utility functions

# The oracle function that returns the value of A * G (but taking L^-1 as input)
oraculumLi <- function(Li, G, center=FALSE){
  if(center) {
    if(is.array(G)) G <- apply(G, 2, function(col) col - mean(col))
    if(is.vector(G)) G <- cbind(G) - mean(G)
  }
  Y <- spam::backsolve(t(Li), G)
  Y <- spam::forwardsolve(Li, Y)
  if(center) {

    if(is.array(Y)) return(apply(Y, 2, function(col) col - mean(col)))
    if(is.vector(Y)) return(Y - mean(Y))
  } else {
    return(Y)
  }
}

# Oracle function with swapped parameters as input to RSpectra::eigs
oracFun <- function(x, args) oraculumLi(args$A, x, args$cent)

Try the randPedPCA package in your browser

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

randPedPCA documentation built on Aug. 8, 2025, 6:37 p.m.