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 0e92e52 commit 5e2a076Copy full SHA for 5e2a076
cachematrix.R
@@ -31,11 +31,17 @@ makeCacheMatrix <- function(x = matrix()) {
31
cacheSolve <- function(x, ...) {
32
## Return a matrix that is the inverse of 'x'
33
m <- x$getinverse()
34
+ ##Has the inverse already been calculated?
35
+ ##If so, returns the inverse from the cache
36
if(!is.null(m)) {
37
message("getting cached data")
38
return(m)
39
}
40
+ #Otherwise, it calculates the mean of the data and sets
41
+ #the value of the inverse in the cache via the setinverse function.
42
data <- x$get()
43
+ ##Using the solve function to
44
+ ##compute the inverse of the square matrix
45
m <- solve(data, ...)
46
x$setinverse(m)
47
m
0 commit comments