forked from rdpeng/ProgrammingAssignment2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcachematrix.R
More file actions
38 lines (33 loc) · 821 Bytes
/
cachematrix.R
File metadata and controls
38 lines (33 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
## Put comments here that give an overall description of what your
## functions do
## This fuction caches the inverse of a matrix, as well as creates 4 fuctions
makeCacheMatrix <- function(x = matrix())
{
i <- NULL
set <- function(y)
{
x <<- y
i <<- NULL
}
get <- function() x
getInverse <- function() i
setInverse <- function(setInverse) i <<- setInverse
list(set = set, get = get,
setInverse = setInverse,
getInverse = getInverse)
}
## This fuction calculates the inverse of the matrix returned by the fuction above. If the inverse is cached,
## simply return the cached value.
cacheSolve <- function(x, ...)
{
i <- x$getInverse()
if(!is.null(i))
{
message("getting cached data")
return(i)
}
data <- x$get()
i <- solve(data, ...)
x$setInverse(i)
i
}