Skip to content

Commit b489aa8

Browse files
author
yaswanth Pulavarthi
committed
done
1 parent 7f657dd commit b489aa8

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

cachematrix.R

+24-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,30 @@
1-
## Put comments here that give an overall description of what your
2-
## functions do
3-
4-
## Write a short comment describing this function
1+
##Please include your own comment to explain your code (Required in Rubric)
52

63
makeCacheMatrix <- function(x = matrix()) {
7-
4+
j <- NULL
5+
set <- function(y){
6+
x <<- y
7+
j <<- NULL
8+
}
9+
get <- function()x
10+
setInverse <- function(inverse) j <<- inverse
11+
getInverse <- function() j
12+
list(set = set, get = get,
13+
setInverse = setInverse,
14+
getInverse = getInverse)
815
}
916

10-
11-
## Write a short comment describing this function
17+
##Please include your own comment to explain your code (Required in Rubric)
1218

1319
cacheSolve <- function(x, ...) {
14-
## Return a matrix that is the inverse of 'x'
15-
}
20+
## Return a matrix that is the inverse of 'x'
21+
j <- x$getInverse()
22+
if(!is.null(j)){
23+
message("getting cached data")
24+
return(j)
25+
}
26+
mat <- x$get()
27+
j <- solve(mat,...)
28+
x$setInverse(j)
29+
j
30+
}

0 commit comments

Comments
 (0)