Skip to content

Commit 0c0dd6c

Browse files
committed
Added comments
1 parent c9112ce commit 0c0dd6c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

cachematrix.R

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
## Put comments here that give an overall description of what your
2-
## functions do
1+
## makeCacheMatrix and cacheSolve are two functions that allow
2+
## for the caching the calculation of the inverse of a matrix.
3+
## The functions assume that the matrix is always invertible.
34

4-
## Write a short comment describing this function
5+
## makeCacheMatrix function creates a special matrix object that
6+
## can cache its inverse. It allows for getting and setting the
7+
## matrix and its inverse.
58

69
makeCacheMatrix <- function(x = matrix()) {
710
i <- NULL
@@ -20,10 +23,11 @@ makeCacheMatrix <- function(x = matrix()) {
2023
}
2124

2225

23-
## Write a short comment describing this function
26+
## cacheSolve computes the inverse of the matrix returned by makeCacheMatrix.
27+
## If the inverse has already been calculated the function, it will be
28+
## retrieved from the cache.
2429

2530
cacheSolve <- function(x, ...) {
26-
## Return a matrix that is the inverse of 'x'
2731
i <- x$getinverse()
2832

2933
if(!is.null(i)) {
@@ -33,6 +37,6 @@ cacheSolve <- function(x, ...) {
3337

3438
data <- x$get()
3539
i <- solve(data, ...)
36-
x$setmean(i)
40+
x$setinverse(i)
3741
i
3842
}

0 commit comments

Comments
 (0)