File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change 3
3
4
4
# # Write a short comment describing this function
5
5
6
+ # This function creates a special matrix object, which inverse will be cached, if computed using cacheSolve
7
+ # x is the matrix you want to allow to be cached
6
8
makeCacheMatrix <- function (x = matrix ()) {
7
-
9
+ # initialize the variable which will store the inversed cached value
10
+ # initially do not assign any value (it will be lazily assigned when cacheSolve is called)
11
+ inversedCache <- NULL
12
+
13
+ # changes the stored matrix to a different one
14
+ # cleares cache
15
+ set <- function (newMatrix ) {
16
+ x <<- newMatrix
17
+ inversedCache <<- NULL
18
+ }
19
+
20
+ # returns the backend matrix
21
+ get <- function () x
22
+
23
+ # returns the cached inverse. Cached inverse will be NULL if it has
24
+ # not been computed yet
25
+ getinverse <- function () inversedCache
26
+
27
+ # sets the cached inverse
28
+ setinverse <- function (inverse ) inversedCache <<- inverse
29
+
30
+ # returns a 'public API' of this makeCacheMatrix
31
+ list (set = set , get = get ,
32
+ getinverse = getinverse ,
33
+ setinverse = setinverse )
8
34
}
9
35
10
36
You can’t perform that action at this time.
0 commit comments