File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,8 @@ makeCacheMatrix <- function(x = matrix()) {
27
27
get <- function () cachedMatrix
28
28
29
29
# Setter function for the inverse
30
+ # Only provided for API compatibility. Getting the inverse
31
+ # will prime the cache
30
32
setInverse <- function (inverse ) cachedInverse <<- inverse
31
33
32
34
# Getter function for the inverse
@@ -83,4 +85,16 @@ test <- function() {
83
85
print(" Good, a's inverse is still correct and you should not see a cache miss" )
84
86
}
85
87
88
+ b.normal2 <- matrix (rnorm(9 ), 3 , 3 )
89
+ b.cached $ set(b.normal2 )
90
+
91
+ if (identical(solve(b.normal2 ), cacheSolve(b.cached ))) {
92
+ print(" Good, you can update (should have seen a cache miss)" )
93
+ }
94
+
95
+ if (identical(solve(b.normal2 ), cacheSolve(b.cached ))) {
96
+ print(" Good...same thing but no cache miss" )
97
+ }
98
+
99
+
86
100
}
You can’t perform that action at this time.
0 commit comments