File tree 1 file changed +25
-4
lines changed 1 file changed +25
-4
lines changed Original file line number Diff line number Diff line change 1
- # #CHANGE TEST
1
+ # #This function creates a special "matrix" object that can cache its inverse.
2
2
3
3
makeCacheMatrix <- function (x = matrix ()) {
4
-
4
+ i <- NULL
5
+ set <- function (y ) {
6
+ x <<- y
7
+ i <<- NULL
8
+ }
9
+ get <- function () x
10
+ setinverse <- function (inverse ) i <<- inverse
11
+ getinverse <- function () i
12
+ list (set = set ,
13
+ get = get ,
14
+ setinverse = setinverse ,
15
+ getinverse = getinverse )
5
16
}
6
17
7
18
8
- # # Write a short comment describing this function
19
+ # # This function computes the inverse of the special"matrix" returned by `makeCacheMatrix` above. If the inverse has
20
+ # #already been calculated (and the matrix has not changed), then
21
+ # #`cacheSolve` should retrieve the inverse from the cache.
9
22
10
23
cacheSolve <- function (x , ... ) {
11
- # # Return a matrix that is the inverse of 'x'
24
+ i <- x $ getinverse()
25
+ if (! is.null(i )) {
26
+ message(" Getting Cached Data" )
27
+ return (i )
28
+ }
29
+ data <- x $ get()
30
+ i <- solve(data , ... )
31
+ x $ setinverse(i )
32
+ i
12
33
}
You can’t perform that action at this time.
0 commit comments