Skip to content
Open

New #5868

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions cachematrix.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
## Put comments here that give an overall description of what your
## functions do
## makeCacheMatrix is a function that can cashe the inverse of a matrix. If the inverse has already been calculated (and the matrix has not changed), then the cacheSolve function retrieves the inverse from the cache.

## Write a short comment describing this function
## This function creates a special "matrix" object that can cache its inverse

makeCacheMatrix <- function(x = matrix()) {

inv <- NULL
get <- function() x
getinv <- function() inv <<- solve(x)
list(get = get,
getinv = getinv)
}


## Write a short comment describing this function
## This function computes the inverse of the special "matrix" returned by makeCacheMatrix above.

cacheSolve <- function(x, ...) {
## Return a matrix that is the inverse of 'x'
inv <- x$getinv()
if(!is.null(inv)) {
message("getting cached data")
return(inv)
}
data <- x$get()
inv <- solve(data, ...)
inv
}