Thanks to visit codestin.com Credit goes to github.com
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 efaf537 commit bb8f2e0Copy full SHA for bb8f2e0
cachematrix.R
@@ -9,6 +9,14 @@
9
## makeCacheMatrix: This function creates a special "matrix" object that can cache its inverse.
10
11
makeCacheMatrix <- function(x = matrix()) {
12
+ m <- NULL
13
+ set <- function(y) {
14
+ x <<- y
15
+ m <<- NULL
16
+ }
17
+ get <- function() x
18
+ setmatrix <- function(matrix) m <<- mean
19
+ getmatrix <- function() m
20
21
}
22
@@ -19,5 +27,13 @@ makeCacheMatrix <- function(x = matrix()) {
27
## retrieve the inverse from the cache.
28
29
cacheSolve <- function(x, ...) {
- ## Return a matrix that is the inverse of 'x'
30
+ m <- x$getmatrix()
31
+ if(!is.null(m)) {
32
+ message("getting cached data")
33
+ return(m)
34
35
+ data <- x$get()
36
+ m <- matrix(data, ...)
37
+ x$setmatrix(m)
38
+ m
23
39
0 commit comments