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

Add files via upload #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
52 changes: 37 additions & 15 deletions cachematrix.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,37 @@
## 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'
}
## makeCachedMatrix creates a list that can store the original matrix and cached inverse
## cacheSolve utilizes the list created by makeCacheMatrix to return the inverse and only
## calculate the inverse if cached inverse is not found

## makeCacheMatrix: make a cached matrix with get/set/getinverse/setinverse methods

makeCacheMatrix <- function(x = matrix()) {
i <- NULL
set <- function(y) {
x <<- y
i <<- NULL
}
get <- function() x
setinverse <- function(inv) i <<- inv
getinverse <- function() i
list(set = set, get = get,
setinverse = setinverse,
getinverse = getinverse)
}


## cacheSolve: solve a matrix for its inverse. Retrieve cached inverse if already solved, otherwise solve and
## store the cache

cacheSolve <- function(x, ...) {

i <- x$getinverse()
if(!is.null(i)) {
message("getting cached inverse matrix")
return(i)
}
data <- x$get()
i <- solve(data, ...)
x$setinverse(i)
## Return a matrix that is the inverse of 'x'
i
}