Skip to content

Commit 78c0ad7

Browse files
committed
Add brief comments in makeCacheMatrix
Briefly describe the implementation of makeCacheMatrix. It is a simple object (list) containing get/set functions for a matrix and its inverse.
1 parent f103b18 commit 78c0ad7

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

cachematrix.R

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,27 @@
55
## functions for getting and setting the matrix and its inverse.
66

77
makeCacheMatrix <- function(x = matrix()) {
8+
# Initialize the inverse of x to NULL.
89
inv <- NULL
10+
11+
# get and set functions for the matrix x.
12+
# The set function also sets the inverse of x
13+
# to NULL, to invalidate any previously cached
14+
# inverse.
915
set <- function(y) {
1016
x <<- y
1117
inv <<- NULL
1218
}
1319
get <- function() x
20+
21+
# get and set functions for the inverse of
22+
# the matrix x.
1423
setinv <- function(minv) inv <<- minv
1524
getinv <- function() inv
25+
26+
# Return a simple object (list) containing the
27+
# get and set functions for a matrix and its
28+
# inverse.
1629
list(set = set, get = get, setinv = setinv, getinv = getinv)
1730
}
1831

0 commit comments

Comments
 (0)