File tree Expand file tree Collapse file tree 3 files changed +47
-11
lines changed Expand file tree Collapse file tree 3 files changed +47
-11
lines changed Original file line number Diff line number Diff line change
1
+ .Rproj.user
2
+ .Rhistory
3
+ .RData
Original file line number Diff line number Diff line change
1
+ Version: 1.0
2
+
3
+ RestoreWorkspace: Default
4
+ SaveWorkspace: Default
5
+ AlwaysSaveHistory: Default
6
+
7
+ EnableCodeIndexing: Yes
8
+ UseSpacesForTab: Yes
9
+ NumSpacesForTab: 2
10
+ Encoding: UTF-8
11
+
12
+ RnwWeave: Sweave
13
+ LaTeX: pdfLaTeX
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
-
4
- # # Write a short comment describing this function
5
-
6
1
makeCacheMatrix <- function (x = matrix ()) {
7
-
2
+ inverse <- NULL
3
+
4
+ get <- function () x
5
+
6
+ set <- function (y ) {
7
+ x <<- y
8
+ inverse <<- NULL
9
+ }
10
+
11
+ getInverse <- function () inverse
12
+
13
+ setInverse <- function (inv ) inverse <<- inv
14
+
15
+ list (get = get ,
16
+ set = set ,
17
+ getInverse = getInverse ,
18
+ setInverse = setInverse )
8
19
}
9
20
10
-
11
- # # Write a short comment describing this function
12
-
13
21
cacheSolve <- function (x , ... ) {
14
- # # Return a matrix that is the inverse of 'x'
15
- }
22
+ inverse <- x $ getInverse()
23
+
24
+ if (! is.null(inverse )) {
25
+ message(" reading from cache" )
26
+ return (inverse )
27
+ }
28
+
29
+ message(" computing inverse" )
30
+
31
+ inverse <- solve(x $ get())
32
+ x $ setInverse(inverse )
33
+
34
+ inverse
35
+ }
You can’t perform that action at this time.
0 commit comments