File tree Expand file tree Collapse file tree 1 file changed +19
-19
lines changed Expand file tree Collapse file tree 1 file changed +19
-19
lines changed Original file line number Diff line number Diff line change @@ -32,23 +32,23 @@ makeCacheMatrix <- function(x = matrix()) {
32
32
# # Given an object returned by makeCacheMatrix, calculate the inverse and cache it for further calls.
33
33
# # If a cached inverse has already been calculated on the wrapped matrix, the cached version is returned.
34
34
cacheSolve <- function (x , ... ) {
35
- # # Return a matrix that is the inverse of 'x'
36
-
37
- inv <- x $ getinverse
38
-
39
- if ( ! is.null( inv ) ) {
40
- # # The wrapped matrix has a non NULL inverse
41
- message( " cache hit" )
42
- return inv
43
- }
44
-
45
- # # Calculate the inverse using solve
46
- # # TODO: handle special cases more carefully, not all matrices can be inverted.
47
- inv <- solve( x $ get() )
48
-
49
- # # Cache the result of solve()
50
- x $ setinverse( inv )
51
-
52
- # # return the inverse
53
- inv
35
+ # # Return a matrix that is the inverse of 'x'
36
+
37
+ inv <- x $ getinverse
38
+
39
+ if ( ! is.null( inv ) ) {
40
+ # # The wrapped matrix has a non NULL inverse
41
+ message( " cache hit" )
42
+ return inv
43
+ }
44
+
45
+ # # Calculate the inverse using solve
46
+ # # TODO: handle special cases more carefully, not all matrices can be inverted.
47
+ inv <- solve( x $ get() )
48
+
49
+ # # Cache the result of solve()
50
+ x $ setinverse( inv )
51
+
52
+ # # return the inverse
53
+ inv
54
54
}
You can’t perform that action at this time.
0 commit comments