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 226cd4e commit 4f17798Copy full SHA for 4f17798
cachematrix.R
@@ -1,7 +1,7 @@
1
## Put comments here that give an overall description of what your
2
## functions do
3
4
-## Create a matrix that will cache its inverse.
+## Create a matrix wrapping function ("object") that will cache the matrix's inverse.
5
6
makeCacheMatrix <- function(x = matrix()) {
7
inverse <- NULL
@@ -25,10 +25,13 @@ makeCacheMatrix <- function(x = matrix()) {
25
cacheSolve <- function(x, ...) {
26
inverse <- x$getinverse()
27
if (!is.null(inverse)) {
28
+ # inverse has been calculated already
29
return(inverse)
30
}
31
data <- x$get()
32
+ # actual solving
33
inverse <- solve(data)
34
+ # save inverse
35
x$setinverse(inverse)
36
inverse
37
0 commit comments