File tree Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Original file line number Diff line number Diff line change 5
5
# # matrix inversion calculations.
6
6
7
7
makeCacheMatrix <- function (x = matrix ()) {
8
- inv <- NULL
8
+ inverse <- NULL
9
9
10
10
# # Init object
11
11
set <- function (y ) {
12
12
x <<- y
13
- inv <<- NULL
13
+ inverse <<- NULL
14
14
}
15
- get <- function () x
16
- setinverse <- function (solve ) inv <<- solve
17
- getinverse <- function () inv
15
+ get <- function () return ( x )
16
+ setinverse <- function (inv ) inverse <<- inv
17
+ getinverse <- function () return ( inverse )
18
18
list (set = set ,
19
19
get = get ,
20
20
setinverse = setinverse ,
@@ -26,13 +26,13 @@ list(set = set,
26
26
27
27
cacheSolve <- function (x , ... ) {
28
28
# # Return a matrix that is the inverse of 'x'
29
- inv <- x $ getinverse()
30
- if (! is.null(inv )) {
29
+ inverse <- x $ getinverse()
30
+ if (! is.null(inverse )) {
31
31
message(" getting cached inverse matrix" )
32
- return (inv )
32
+ return (inverse )
33
33
}
34
34
data <- x $ get()
35
- inv <- solve(data , ... )
36
- x $ setinverse(inv )
37
- inv
35
+ inverse <- solve(data , ... )
36
+ x $ setinverse(inverse )
37
+ return ( inverse )
38
38
}
You can’t perform that action at this time.
0 commit comments