Skip to content

Commit

Permalink
rprog-15 homework assignment rdpeng#3
Browse files Browse the repository at this point in the history
  • Loading branch information
squirrelandr committed Jun 21, 2015
1 parent 7f657dd commit 20cca16
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 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
## This function is to store a temporary inversed matrix in the environment
##

## Write a short comment describing this function
## This function creates a special "matrix" object that can cache its inverse
## Not sure if these would work

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

## set the value of the matrix
m <- null
set <- function(y) {
x <<- y
m <<- NULL
}

## get the value of the matrix
get <- function() x
setinverse <- function(inverse) m <<- inverse
getinverse <- function() m
list(set = set, get = get, setinverse = setinverse, getinverse = getinverse)
}


## Write a short comment describing this function
## 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 the cachesolve should retrieve the inverse from the cache.

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

0 comments on commit 20cca16

Please sign in to comment.