R/solve2.R

Defines functions solve2

solve2 = function(H)
{
  H.inv = try( solve(H), silent=TRUE )
  if ( class(H.inv)[1] == "try-error" )
    H.inv = try( Matrix::solve(Matrix::Matrix(H)), silent=TRUE )
  if ( class(H.inv)[1] == "try-error" )
    H.inv = try( chol2inv( chol(H) ), silent=TRUE )
  if ( class(H.inv)[1] == "try-error" )
    H.inv = matrix(NA, nrow(H), ncol(H))

  return(H.inv)
}    

Try the OptimModel package in your browser

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

OptimModel documentation built on May 29, 2024, 9:47 a.m.