Skip to content

Commit

Permalink
Commit initial edits - PA3
Browse files Browse the repository at this point in the history
This is the first draft for programming assignment rdpeng#3.
  • Loading branch information
jnewkirk00 committed Jan 22, 2015
1 parent 7f657dd commit 5688bcb
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
## These functions are designed to cache the inverse of a matrix. This is a demonstration of both
## caching values that take a long time to computer and usage of the <<- operator.

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

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

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


## Write a short comment describing this function
## cacheSolve computes the inverse of the special"matrix" returned by makeCacehMatrix. If
## the inverse has already been calculated, and has not changed, the cached result
## is returned

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

0 comments on commit 5688bcb

Please sign in to comment.