Skip to content

Commit bc968f7

Browse files
committed
fixed some typos in the comments
1 parent f6dcaaa commit bc968f7

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

cachematrix.R

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
## These functions can calculate the inverse matrix and
2-
## cache the results so it does not need to be recalculated
3-
## when re-used.
1+
## These functions can calculate the inverse of a matrix and cache
2+
## the results, so it does not need to be recalculated when re-used.
43

5-
## This function returns a closure that contains
6-
## both the original matrix passed as argument x
7-
## and its inverse
4+
## This function returns a closure that holds both the original
5+
## matrix passed as argument x and its inverse
86
makeCacheMatrix <- function(x = matrix()) {
97
xi <- NULL
108

11-
## Sets the enclosed matrix and
12-
## resets any cached inverse
9+
## Sets the enclosed matrix and resets any cached inverse
1310
set <- function(y) {
1411
x <<- y
1512
xi <<- NULL
@@ -18,8 +15,7 @@ makeCacheMatrix <- function(x = matrix()) {
1815
## Returns the enclosed matrix
1916
get <- function() x
2017

21-
## Caches the given solution to the
22-
## a inverse matrix
18+
## Caches the given solution to the inverse matrix
2319
setSolve <- function(solve) xi <<- solve
2420

2521
## Gets the cached inverse of the matrix
@@ -31,10 +27,9 @@ makeCacheMatrix <- function(x = matrix()) {
3127
}
3228

3329

34-
## This function expects a closure returned
35-
## by makeCacheMatrix above and leverages its
36-
## caching capabilities to return the solution
37-
## for the inverse matrix
30+
## This function expects a closure returned by makeCacheMatrix above
31+
## and uses its caching capabilities to return the solution for
32+
## the inverse matrix
3833
cacheSolve <- function(x, ...) {
3934
## Return a matrix that is the inverse of 'x'
4035
xi <- x$getSolve()
@@ -61,8 +56,7 @@ print(cm$get())
6156
xi <- cacheSolve(cm)
6257
print(cm$getSolve())
6358

64-
## Calculates the inverse again, it should return
65-
## the cached value
59+
## Calculates the inverse again, it should return the cached value
6660
xi <- cacheSolve(cm)
6761

6862
## Is this really the inverse matrix?
@@ -73,7 +67,7 @@ if(isTRUE(all.equal(xi, mi))) {
7367
}
7468

7569
# Test #2: With a 3x3 matrix
76-
message("Test 2: with a 3x3 matrix")
70+
message("Test #2: with a 3x3 matrix")
7771
m <- matrix(c(3, 2, 0, 0, 0, 1, 2, -2, 1), 3, 3)
7872

7973
cm <- makeCacheMatrix(m)
@@ -82,8 +76,7 @@ print(cm$get())
8276
xi <- cacheSolve(cm)
8377
print(cm$getSolve())
8478

85-
## Calculates the inverse again, it should return
86-
## the cached value
79+
## Calculates the inverse again, it should return the cached value
8780
xi <- cacheSolve(cm)
8881

8982
if(isTRUE(all.equal(m %*% xi, diag(3)))) {

0 commit comments

Comments
 (0)