You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
}
}
The text was updated successfully, but these errors were encountered:
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)
}
}
The text was updated successfully, but these errors were encountered: