R/Solve.R

Defines functions Solve

Documented in Solve

## =============================================================================
## Solve       : Generalised inverse solution of Ax=B
## =============================================================================

Solve <- function(A, B=diag(nrow=nrow(A)),
   tol=sqrt(.Machine$double.eps))   {

  M <-ginv(A,tol)
  if (is.null(M))
    return(NULL)
  B <- matrix(data=B, nrow=nrow(A))
  X <- M %*% B
  if (ncol(B) == 1)  {
    xnames <- colnames(A)
    X <- as.vector(X)
    names (X) <- xnames
  }
  return(X)
}

Try the limSolve package in your browser

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

limSolve documentation built on Sept. 22, 2023, 1:07 a.m.