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
36 lines (31 loc) · 933 Bytes
/
Copy pathcachematrix.R
File metadata and controls
36 lines (31 loc) · 933 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
## Put comments here that give an overall description of what your
## functions do
## function to create a special matrix that chaches its inverse
makeCacheMatrix <- function(x = matrix()) {
m <- NULL
# set the value of the matrix
set <- function(y){
x <<-y
m <<- NULL
}
#gets val of matrix
get <- function() x
setInv <- function(Inv) m <<- Inv
getInv <- function() m
list(set=set,get=get,
setInv = setInv,
getInv = getInv)
}
## retrieve this cached matrix, or calculate inverse
cacheSolve <- function(x, ...) {
m <- x$getInv()
if(!is.null(m)){
message('getting cached matrix')
return(m)
}
data <- x$get()
m <- solve(data,...)
x$setInv(m)
m
## Return a matrix that is the inverse of 'x'
}