File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Expand file tree Collapse file tree 1 file changed +16
-5
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 function `makeCacheMatrix` takes a matrix as an argument and returns a
2
+ # special "matrix" object that caches the results of potentially time-consuming
3
+ # computations applied to the matrix, for example the function `solve`
4
+ # which returns the inverse of the matrix. You must use the companion function
5
+ # `cacheSolve` instead of `solve` with this special "matrix" object to take
6
+ # advantage of its time-saving caching behavior.
3
7
4
- # # Write a short comment describing this function
5
8
9
+ # This function creates a special "matrix" object that can cache its inverse.
10
+ # This special "matrix" object is really a list containing four functions to:
11
+ # 1. set the value of the matrix
12
+ # 2. get the value of the matrix
13
+ # 3. set the value of the inverse
14
+ # 4. get the value of the inverse
6
15
makeCacheMatrix <- function (x = matrix ()) {
7
16
inv <- NULL
8
17
set <- function (y ) {
@@ -19,8 +28,10 @@ makeCacheMatrix <- function(x = matrix()) {
19
28
}
20
29
21
30
22
- # # Return a matrix that is the inverse of 'x'
23
-
31
+ # This function computes the inverse of the special "matrix" returned by
32
+ # `makeCacheMatrix` above. If the inverse has already been calculated (and the
33
+ # matrix has not changed), then `cacheSolve` should retrieve the inverse from
34
+ # the cache.
24
35
cacheSolve <- function (x , ... ) {
25
36
inv <- x $ getinv()
26
37
if (! is.null(inv )) {
You can’t perform that action at this time.
0 commit comments