File tree Expand file tree Collapse file tree 1 file changed +15
-6
lines changed
Expand file tree Collapse file tree 1 file changed +15
-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+ # # The functions below create a special object that stores a matrix vector and
2+ # # caches its inverse.
33
4- # # Write a short comment describing this function
4+ # # This function creates a special "matrix", which is really a list containing
5+ # # a function to
6+ # # 1. set the value of the vector
7+ # # 2. get the value of the vector
8+ # # 3. set the value of the inverse
9+ # # 4. get the value of the inverse
510
611makeCacheMatrix <- function (x = matrix ()) {
712 inv <- NULL
@@ -18,7 +23,11 @@ makeCacheMatrix <- function(x = matrix()) {
1823}
1924
2025
21- # # Write a short comment describing this function
26+ # # The following function calculates the inverse of the special "matrix" created
27+ # # with the above function. However, it first checks to see if the inverse has
28+ # # already been calculated. If so, it gets the inverse from the cache and skips
29+ # # the computation. Otherwise, it calculates the inverse of the data and sets
30+ # # the value of the inverse in the cache via the setinv function.
2231
2332cacheSolve <- function (x , ... ) {
2433 # # Return a matrix that is the inverse of 'x'
@@ -29,6 +38,6 @@ cacheSolve <- function(x, ...) {
2938 }
3039 data <- x $ get()
3140 inv <- solve(data , ... )
32- x $ setmean (inv )
41+ x $ setinv (inv )
3342 m
34- }
43+ }
You can’t perform that action at this time.
0 commit comments