Skip to content
Merged
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
54 changes: 39 additions & 15 deletions cachematrix.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,39 @@
## Put comments here that give an overall description of what your
## functions do

## Write a short comment describing this function

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

}


## Write a short comment describing this function

cacheSolve <- function(x, ...) {
## Return a matrix that is the inverse of 'x'
}
## These functions take a matrix, store it, calculate the inverse
## of the matrix, and cache it so as to not require heavy repeated
## computation

## This first function creates an object which is really a list
## that contains a function to set and get the values of a matrix
## and also sets and gets the inverse matrix

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)
}


## This function calculates the inverse of the results from the
## first function above. If it's been calculated already, it will
## get the inverse from the cache

cacheSolve <- function(x, ...) {
## Return a matrix that is the inverse of 'x'
inv <- x$getInverse()
if (!is.null(inv)) {
message("getting cached data")
return(inv)
}
m <- x$get()
inv <- solve(m, ...)
x$setInverse(inv)
inv
}