I am following Datara's Coursera course, and I have a question regarding one of the purposes in which I have to invert the matrix and then cache this result.
Mostly I went to the search engine and I found the answer, but there are parts of the answer that I still don't understand. For this reason, I do not want to present my task since I do not want to represent anything that I do not quite understand.
The part that I donβt understand from the code below is the part where setInverse is defined. where does the function (inverse) inv come from? especially the "reverse" has never been determined?
After that comes back a list that doesn't make much sense to me?
If someone can take the time to explain this feature, I would be very grateful!
makeCacheMatrix <- function(x = matrix()) {
inv <- NULL
set <- function(y) {
x <<- y
inv <<- NULL
}
get <- function() x
setInverse <- function(inverse) inv <<- inverse
getInverse <- function() inv
list(set = set,
get = get,
setInverse = setInverse,
getInverse = getInverse)
}
## Write a short comment describing this function
cacheSolve <- function(x, ...) {
inv <- x$getInverse()
if (!is.null(inv)) {
message("getting cached data")
return(inv)
}
mat <- x$get()
inv <- solve(mat, ...)
x$setInverse(inv)
inv
}