We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7f657dd commit 6bc6699Copy full SHA for 6bc6699
cachematrix.R
@@ -5,11 +5,37 @@
5
6
makeCacheMatrix <- function(x = matrix()) {
7
8
+ ainv <- NULL
9
+
10
+ set <- function(newMatrix)
11
+ {
12
+ x <<- newMatrix
13
+ ainv <<- NULL
14
+ }
15
16
+ get <- function() x
17
+ setInv <- function(inv) ainv <<- inv
18
+ getInv <- function() ainv
19
20
+ list (set=set,get=get,setInv=setInv,getInv=getInv)
21
22
23
}
24
25
26
## Write a short comment describing this function
27
28
cacheSolve <- function(x, ...) {
29
## Return a matrix that is the inverse of 'x'
30
31
+ if (is.null(x$getInv()))
32
33
+ message("calculating Inverse ::")
34
+ inv <- solve(x$get(),...)
35
+ x$setInv(inv)
36
37
+ else
38
+ message("Getting Inv from cache:")
39
+ x$getInv()
40
41
0 commit comments