Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 27 additions & 8 deletions cachematrix.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
## Put comments here that give an overall description of what your
## functions do

## Write a short comment describing this function
#makeCacheMatrix: This function creates a special "matrix" object that can cache its inverse.
#cacheSolve: This function computes the inverse of the special "matrix" returned by makeCacheMatrix above.
#If the inverse has already been calculated (and the matrix has not changed), then cacheSolve should retrieve the inverse from the cache.

## Write a cache function
makeCacheMatrix <- function(x = matrix()) {

inverse <- NULL
set <- function(y) {
x <<- y
inverse <<- NULL
}
get <- function() x
setsolve <- function(solve) inverse <<- solve
getsolve <- function() inverse
list(set = set, get = get,
setsolve = setsolve,
getsolve = getsolve)
}


## Write a short comment describing this function

## get an inverse matrix from cache if there's one, or make a new one
cacheSolve <- function(x, ...) {
## Return a matrix that is the inverse of 'x'
## Return a matrix that is the inverse of 'x'
x.inverse <- x$getsolve()
if(!is.null(x.inverse)) {
message("getting cached data")
return(x.inverse)
}
data <- x$get()
x.inverse <- solve(data, ...)
x$setsolve(x.inverse)
x.inverse

}