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
3
1
4
- # # Write a short comment describing this function
2
+ # These functions compute and store in cache the inverse of a inversible matrix
3
+
4
+ # # Cache a matrix inverse like in assigment text
5
5
6
6
makeCacheMatrix <- function (x = matrix ()) {
7
+ i <- NULL
8
+ set <- function (y ) {
9
+ x <<- y
10
+ i <<- NULL
11
+ }
12
+ get <- function () x
13
+ setinverse <- function (inverse ) i <<- inverse
14
+ getinverse <- function () i
15
+ list (set = set , get = get , setinverse = setinverse , getinverse = getinverse )
7
16
8
17
}
9
18
10
19
11
- # # Write a short comment describing this function
20
+ # # Solves a matrix inverse using cache if available like in assigment text
12
21
13
22
cacheSolve <- function (x , ... ) {
14
- # # Return a matrix that is the inverse of 'x'
23
+ i <- x $ getinverse()
24
+ if (! is.null(i )) {
25
+ message(" getting cached data." )
26
+ return (i )
27
+ }
28
+ data <- x $ get()
29
+ i <- solve(data )
30
+ x $ setinverse(i )
31
+ i
32
+
15
33
}
You can’t perform that action at this time.
0 commit comments