Skip to content

Commit

Permalink
Update cachematrix.R
Browse files Browse the repository at this point in the history
  • Loading branch information
NidaBat authored Apr 12, 2017
1 parent 7f657dd commit 7e5fc5e
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions cachematrix.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,35 @@
## Put comments here that give an overall description of what your
## functions do
## Caching the Inverse of a Matrix
## set a matrix
## get a matrix
## set an inverse
## get an inverse

## Write a short comment describing this function
## create a special "matrix" object that can cache its "inverse"

makeCacheMatrix <- function(x = matrix()) {

invrs = NULL
set = function(y) {
x <<- y
invrs <<- NULL
}
get = function() x
setinv = function(inverse) invrs <<- inverse
getinv = function() invrs
list(set = set, get = get,
setinv = setinv,
getinv = getinv)
}


## Write a short comment describing this function
## Compute the "inverse" of the special "matrix"

cacheSolve <- function(x, ...) {
## Return a matrix that is the inverse of 'x'
invrs = x$getinv()
if (!is.null(invrs)){
message("getting cached data")
return(invrs)
}
mat.data = x$get()
invrs = solve(mat.data, ...)
x$setinv(invrs)
return(invrs)
}

1 comment on commit 7e5fc5e

@NidaBat
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ProgrammingAssignment2 for caching the Inverse of Matrix

Please sign in to comment.