8000 add additional comments and include helper test script whose contents… · rdpeng/ProgrammingAssignment2@8d3d468 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8d3d468

Browse files
committed
add additional comments and include helper test script whose contents I used on console to verify
1 parent dd8abd3 commit 8d3d468

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

cachematrix.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ makeCacheMatrix <- function(x = matrix()) {
2222

2323
## Returns inverse of x, storing the computation of the inverse
2424
## x is not actually a matrix, but rather a list generated by makeCacheMatrix
25+
## This will set the 'internal' inverse matrix for mackCacheMatrix context if
26+
## it doesn't already exist, and will simply return that matrix if it exists w/o
27+
## recomputing.
2528
cacheSolve <- function(x, ...) {
2629

2730
m <- x$getinv()

test.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
source('./cachematrix.R')
2+
x <- matrix(1:20, nrow=3, ncol=2)
3+
y <- matrix(100:106, nrow=3, ncol=2)
4+
z <- matrix(c("a", "v", "b", "aa", "ab", "cc"), nrow=3, ncol=3)
5+
cmx <- makeCacheMatrix(x)
6+
cmy <- makeCacheMatrix(y)
7+
cmz <- makeCacheMatrix(z)
8+
invx <- cacheSolve(cmx)
9+
invy <- cacheSolve(cmy)
10+
invz <- cacheSolve(cmz)

0 commit comments

Comments
 (0)
0