8000 Add comments to functions · rdpeng/ProgrammingAssignment2@0518e76 · GitHub
[go: up one dir, main page]

Skip to cont 65E4 ent

Commit 0518e76

Browse files
committed
Add comments to functions
1 parent 80453a1 commit 0518e76

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

cachematrix.R

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
## Put comments here that give an overall description of what your
2-
## functions do
3-
4-
## Write a short comment describing this function
1+
## `makeCacheMatrix` creates a special matrix that can hold its cached inverse
2+
##
3+
## internal fields
4+
## x : cached matrix
5+
## i : cached inverse
6+
##
7+
## To explore:
8+
## use matrix equality to avoid assignment when matrix is already cached
9+
## https://stat.ethz.ch/pipermail/r-help/2012-June/315408.html?BHT-9c73f427-7e3a-bc46-bc8a-5ff5849f6d30.0
510

611
makeCacheMatrix <- function(x = matrix()) {
7-
# internal fields
8-
# x : cached matrix
9-
# i : cached inverse
10-
11-
# explore:
12-
# use matrix equality to avoid assignment when matrix is already cached
13-
# https://stat.ethz.ch/pipermail/r-help/2012-June/315408.html?BHT-9c73f427-7e3a-bc46-bc8a-5ff5849f6d30.0
1412
i <- NULL
1513
set <- function(y) {
1614
x <<- y
@@ -26,12 +24,14 @@ makeCacheMatrix <- function(x = matrix()) {
2624
)
2725
}
2826

29-
## Write a short comment describing this function
27+
## Return a matrix that is the inverse of 'x'
28+
## If there is a cached inverse return that,
29+
## if not calculate, cache, and return the inverse of the matrix
30+
##
31+
## `x`: is the special matrix made by makeCacheMatrix
32+
## ex: makeCacheMatrix(matrix(c(3,1,7,5)),2,2)
3033

3134
cacheSolve <- function(x, ...) {
32-
## Return a matrix that is the inverse of 'x'
33-
## `x`: is the special matrix made by makeCacheMatrix
34-
## ex: makeCacheMatrix(matrix(c(3,1,7,5)),2,2)
3535
i <- x$getInverse()
3636
if(!is.null(i)) {
3737
message("getting cached inverse")

0 commit comments

Comments
 (0)
0