Skip to content

Commit

Permalink
My answer to the second programming assignment version rdpeng#1
Browse files Browse the repository at this point in the history
  • Loading branch information
Markmydata committed May 13, 2019
1 parent 7f657dd commit a54fefb
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions cachematrix.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
## Put comments here that give an overall description of what your
## functions do
## These functions combined, will be able to return an inverse of a matrix.
## The function is written so that, should a matrix have remained the same, it will returned it's previously cached result, rather than computing the inverse again,
## making the solution more efficient.

## Write a short comment describing this function
## makeCachematrix creates a 'special' matrix out of a simple matrix and makes it able to store the inverse in the cached memory

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

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


## Write a short comment describing this function
## cacheSolve checks to see if the special matrix matches the special matrix from the previously cached inverse, and returns the cached inverse if true.
## Should the special matrix have been altered, it computes and returns the appropriate inverse.

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

0 comments on commit a54fefb

Please sign in to comment.