File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change 1
- # # Put comments here that give an overall description of what your
2
- # # functions do
1
+ # # The makeCacheMatrix and cacheSolve functions work together to create a
2
+ # # special matrix wrapper object that can cache its own inverse value.
3
3
4
- # # Write a short comment describing this function
4
+ # # The makeCacheMatrix function creates a special object that wraps a matrix
5
+ # # object and provides accessor functions to the matrix object and the cached
6
+ # # inverse of the matrix.
5
7
6
8
makeCacheMatrix <- function (x = matrix ()) {
7
9
i <- NULL
8
10
9
11
set <- function (y ) {
12
+ # Clear the cached inverse whenever we update the matrix object to make
13
+ # sure we don't return an incorrect inverse.
10
14
message(" clearing the cached inverse" )
11
15
i <<- NULL
12
16
x <<- y
@@ -18,7 +22,9 @@ makeCacheMatrix <- function(x = matrix()) {
18
22
}
19
23
20
24
21
- # # Write a short comment describing this function
25
+ # # The cacheSolve function calculates the inverse of the given matrix and
26
+ # # caches it on that object. If the inverse of the give matrix is already
27
+ # # cached it returns instead of calculating it anew.
22
28
23
29
cacheSolve <- function (x , ... ) {
24
30
# # Return a matrix that is the inverse of 'x'
You can’t perform that action at this time.
0 commit comments