File tree Expand file tree Collapse file tree 1 file changed +28
-6
lines changed Expand file tree Collapse file tree 1 file changed +28
-6
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
+ # # cachematrix.R
2
+ # #
3
+ # # Create a cache marix object in order
4
+ # # to increase performance by not have
5
+ # # to calculate repeatedly
3
6
4
- # # Write a short comment describing this function
7
+ # # Creates cacheMatrix object
5
8
6
9
makeCacheMatrix <- function (x = matrix ()) {
7
-
10
+ cachedInverse <- NULL
11
+ set <- function (y ) {
12
+ x <<- y
13
+ cachedInverse <<- NULL
14
+ }
15
+ get <- function () x
16
+ setInverse <- function (inverse ) cachedInverse <<- inverse
17
+ getInverse <- function () cachedInverse
18
+ list (set = set , get = get ,
19
+ setInverse = setInverse ,
20
+ getInverse = getInverse )
8
21
}
9
22
10
23
11
- # # Write a short comment describing this function
24
+ # # Returns the inverse cacheMatrix object
12
25
13
26
cacheSolve <- function (x , ... ) {
14
- # # Return a matrix that is the inverse of 'x'
27
+ # # Return a matrix that is the inverse of 'x'
28
+ invFunc <- x $ getInverse()
29
+ if (! is.null(invFunc )) {
30
+ message(" getting cached data" )
31
+ return (invFunc )
32
+ }
33
+ data <- x $ get()
34
+ invFunc <- solve(data , ... )
35
+ x $ setInverse(invFunc )
36
+ invFunc
15
37
}
You can’t perform that action at this time.
0 commit comments