You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chloeljohnson edited this page Jan 2, 2023
·
2 revisions
<>
##Caching the Inverse of a Matrix:
##Matrix inversion is usually a costly computation and there may be some
##benefit to caching the inverse of a matrix rather than compute it repeatedly.
##Below are two functions that are used to create a special object that
##stores a matrix and caches its inverse.
##This function creates a "matrix" object that can cache its inverse.
makeCacheMatrix <- function(x = matrix()) {
inv <- NULL
set <- function(y) {
x <<- y
inv <<- NULL
}
get <- function() x
set.inverse <- function(inverse) inv <<- inverse
get.inverse <- function() inv
list(set = set,
get = get,
set.inverse = set.inverse,
get.inverse = get.inverse)
}
##This function computes the inverse of the special "matrix" created by
##makeCacheMatrix above. If the inverse has already been calculated (and the
##matrix has not changed), then it should retrieve the inverse from the cache.