Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Programming Assignment 2 # #1978

Open
bxjaj opened this issue May 1, 2016 · 0 comments
Open

Programming Assignment 2 # #1978

bxjaj opened this issue May 1, 2016 · 0 comments

Comments

@bxjaj
Copy link

bxjaj commented May 1, 2016

Sorry this is the wrong link!!!
The right link is https://github.com/bxjaj/Programming-Assignment-2-/tree/master
Please go the that link to check my assignment!
I can't change the link once I accidentally upload the wrong one, really sorry for that.

sapplymakeCacheMatrix <- function(x = matrix()) {
## set the matrix
## get the matrix
## set the inverse
## get the inverse
## this list is used as the input to cacheSolve()
inv_x <- NULL
set <- function(y) {
## use "<<-" to assign a value to an object in an environment
x <<- y
inv_x <<- NULL
}
get <- function() x
setinse<- function(inse) inv_x <<-inse
getinse <- function() inv_x
list(set = set, get = get,
setinse = setinse,
getinse = getinse)
}

cacheSolve <- function(x, ...) {
inv_x <- x$getinse()
if (!is.null(inv_x)) {
## get it from the cache and skips the computation.
message("getting cached inverse matrix")
return(inv_x)
} else {
inv_x <- solve(x$get())
## sets the value of the inverse in the cache via the setinv function.
x$setinse(inv_x)
return(inv_x)
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant