R/spginv.R

spginv<-function (x)
{
  Xsvd <- sparsesvd::sparsesvd(x)
  Positive <- Xsvd$d > max(sqrt(.Machine$double.eps) * Xsvd$d[1L], 0)
  if (all(Positive))
    Xsvd$v %*% (1/Xsvd$d * t(Xsvd$u))
  else if (!any(Positive))
    array(0, dim(x)[2L:1L])
  else Xsvd$v[, Positive, drop = FALSE] %*% ((1/Xsvd$d[Positive]) * t(Xsvd$u[, Positive, drop = FALSE]))
}

Try the LRQMM package in your browser

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

LRQMM documentation built on Oct. 4, 2021, 9:08 a.m.