-
Notifications
You must be signed in to change notification settings - Fork 144k
my work
chloeljohnson edited this page Jan 2, 2023
·
2 revisions
makeCacheMatrix <- function(x = matrix()) {
}
cacheSolve <- function(x, ...) { ## Return a matrix that is the inverse of 'x' }
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) }
cacheSolve <- function(x, ...) {
inv <- x$get.inverse() if (!is.null(inv)) { message("getting cached data") return(inv) } mat <- x$get() inv <- solve(mat, ...) x$set.inverse(inv) inv }