File tree Expand file tree Collapse file tree 1 file changed +23
-5
lines changed Expand file tree Collapse file tree 1 file changed +23
-5
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
1+ # # Assignment 2
32
4- # # Write a short comment describing this function
3+ # # makes a matrix inside a list, for x I used x = replicate(10, rnorm(10))
54
65makeCacheMatrix <- function (x = matrix ()) {
6+ m <- NULL
7+ set <- function (y ) {
8+ x <<- y
9+ m <<- NULL
10+ }
11+ get <- function () x
12+ setinv <- function (inv ) m <<- inv
13+ getinv <- function () m
14+ list (set = set , get = get ,
15+ setinv = setinv ,
16+ getinv = getinv )
717
818}
919
1020
11- # # Write a short comment describing this function
21+ # # cache de inverse of the matrix made in de previous function
1222
1323cacheSolve <- function (x , ... ) {
14- # # Return a matrix that is the inverse of 'x'
24+ m <- x $ getinv()
25+ if (! is.null(m )) {
26+ message(" getting cached data" )
27+ return (m )
28+ }
29+ data <- x $ get()
30+ m <- solve(data , ... )
31+ x $ setinv(m )
32+ m
1533}
You can’t perform that action at this time.
0 commit comments