We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 48dabca commit b98be2cCopy full SHA for b98be2c
cachematrix.R
@@ -19,9 +19,20 @@ makeCacheMatrix <- function(x = matrix()) {
19
getinv = getinv)
20
}
21
22
-
+## This function computes the inverse of the special "matrix" returned by
23
+## makeCacheMatrix above. If the inverse has already been calculated
24
+## (and the matrix has not changed), then cacheSolve should retrieve the
25
+## inverse from the cache.
26
27
cacheSolve <- function(x, ...) {
28
## Return a matrix that is the inverse of 'x'
29
+ m <- x$getinv()
30
+ if(!is.null(m)) {
31
+ message("getting cached data")
32
+ return(m)
33
+ }
34
+ data <- x$get()
35
+ m <- solve(data, ...)
36
+ x$setinv(m)
37
+ m
38
0 commit comments