Skip to content
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
28 changes: 27 additions & 1 deletion cachematrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,40 @@
## functions do

## Write a short comment describing this function
## This function applies the same principle as the makeVector function in the caching the mean of a vector sample

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

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


## Write a short comment describing this function
## This function applies the same principle as the cachemean function in the caching the mean of a vector samle. It only
## uses the solve function as recommended to create the inverse of a matrix.

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