10000 Peer Programming Assignement #2 Build 2 · elbrande/ProgrammingAssignment2@c08fe55 · GitHub
[go: up one dir, main page]

Skip to content

Commit c08fe55

Browse files
committed
Peer Programming Assignement rdpeng#2 Build 2
1 parent 0386d1e commit c08fe55

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

cachematrix.R

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,19 @@ makeCacheMatrix <- function(x = matrix()) {
3333
## inverse in the cache via the setInverse function
3434

3535
cacheSolve <- function(x, ...) {
36-
## Return a matrix that is the inverse of 'x'
36+
## Return a matrix that is the inverse of 'x'
37+
## First check if the inverse of x is already stored in cache
3738
i <- x$getInverse()
3839
if(!is.null(i)) {
40+
## If so, just return the cached value of the inverse of 'x'
3941
message("getting cached data")
4042
return(i)
4143
}
44+
##If there is no value cached, use the solve function to compute the
45+
##Inverse of the matrix
4246
data <- x$get()
4347
i <- solve(data, ...)
48+
##Save the result in cache and return the inverse of 'x'
4449
x$setInverse(i)
4550
i
4651
}

0 commit comments

Comments
 (0)
0