Skip to content

Commit 2d2f758

Browse files
author
Yeamin Majumder
authored
Update cachematrix.R
1 parent 7f657dd commit 2d2f758

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

cachematrix.R

+20
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,27 @@
44
## Write a short comment describing this function
55

66
makeCacheMatrix <- function(x = matrix()) {
7+
mat <- NULL
8+
inv_cache <- NULL
79

10+
setMatrix <-function(x){
11+
mat <<- x
12+
inv_cache <<- NULL
13+
}
14+
15+
getInverse <- function() {
16+
if (is.mull(inv_cache)){
17+
inv_cache <<- solve(mat)
18+
}
19+
inv_cache
20+
}
21+
22+
list(setMatrix = setMatrix, getInverse =getInverse)
23+
}
24+
cacheSolve <- function(x, ...){
25+
inv_cache <- x$getInverse()
26+
inv_cache
27+
}
828
}
929

1030

0 commit comments

Comments
 (0)