R/findcoeff.R

Defines functions findcoeff

findcoeff <- function(A, idxB, idxN){
  AB <- A[,idxB]
  AN <- A[,idxN]
  
  m <- nrow(AB)
  n <- ncol(AB)
  
  out <- Matrix::lu(Matrix(AB), sparse=TRUE)
  L <- out@L
  U <- out@U
  p <- out@p
  q <- out@q
  
  #Find W s.t AN = AB*W
  rhs <- AN[p+1,]
  Lhat <- L[1:n,]
  W <- (solve(U, (solve(Lhat, rhs[1:n,]))))[,q]
  resnorm <- norm(AN - AB %*% W, type="F")/max(1, norm(AN,type="F"))
  
  return(list(W=W, resnorm=resnorm))
}

Try the sdpt3r package in your browser

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

sdpt3r documentation built on May 2, 2019, 4:19 a.m.