File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
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
+ # # 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.
3
4
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.
5
8
6
9
makeCacheMatrix <- function (x = matrix ()) {
7
10
i <- NULL
@@ -20,10 +23,11 @@ makeCacheMatrix <- function(x = matrix()) {
20
23
}
21
24
22
25
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.
24
29
25
30
cacheSolve <- function (x , ... ) {
26
- # # Return a matrix that is the inverse of 'x'
27
31
i <- x $ getinverse()
28
32
29
33
if (! is.null(i )) {
@@ -33,6 +37,6 @@ cacheSolve <- function(x, ...) {
33
37
34
38
data <- x $ get()
35
39
i <- solve(data , ... )
36
- x $ setmean (i )
40
+ x $ setinverse (i )
37
41
i
38
42
}
You can’t perform that action at this time.
0 commit comments