File tree Expand file tree Collapse file tree 1 file changed +25
-8
lines changed Expand file tree Collapse file tree 1 file changed +25
-8
lines changed Original file line number Diff line number Diff line change 1
- # # Put comments here that give an overall description of what your
2
- # # functions do
3
1
4
- # # Write a short comment describing this function
5
-
6
- makeCacheMatrix <- function (x = matrix ()) {
2
+ # # Create an object to store a matrix and its' inverse
7
3
4
+ makeCacheMatrix <- function (m = matrix ()) {
5
+ i <- NULL
6
+ set <- function (y ) {
7
+ m <<- y
8
+ inv <<- NULL
9
+ }
10
+ get <- function () m
11
+ setinv <- function (inv ) i <<- inv
12
+ getinv <- function () i
13
+ list (set = set , get = get ,
14
+ setinv = setinv ,
15
+ getinv = getinv )
8
16
}
9
17
10
18
11
- # # Write a short comment describing this function
19
+ # # Chave the inverse of a matrix using an objetc
20
+ # # returned by makeCacheMatrix
12
21
13
- cacheSolve <- function (x , ... ) {
14
- # # Return a matrix that is the inverse of 'x'
22
+ cacheSolve <- function (m , ... ) {
23
+ i <- m $ getinv()
24
+ if (! is.null(i )) {
25
+ message(" getting cached data" )
26
+ return (i )
27
+ }
28
+ data <- m $ get()
29
+ i <- solve(data , ... )
30
+ m $ setinv(i )
31
+ i
15
32
}
You can’t perform that action at this time.
0 commit comments