Skip to content

Commit a68738f

Browse files
committed
add ... parameter processing
1 parent 22eaa35 commit a68738f

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

.RData

7.31 KB
Binary file not shown.

.Rhistory

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
source('~/dev/r/ProgrammingAssignment2/cachematrix.R')
2+
x <-matrix(rnorm(20), rif(10))
3+
x <-matrix(rnorm(20), rnorm(10))
4+
x <-matrix(rnorm(20), rnorm(20))
5+
x <-matrix(rnorm(20), rnorm(20))
6+
?matrix
7+
mdat <- matrix(c(1,2,3, 11,12,13), nrow = 2, ncol = 3, byrow = TRUE,
8+
dimnames = list(c("row1", "row2"),
9+
c("C.1", "C.2", "C.3"))
10+
mdat
11+
mdat <- matrix(c(1,2,3, 11,12,13), nrow = 2, ncol = 3, byrow = TRUE,
12+
dimnames = list(c("row1", "row2"),
13+
c("C.1", "C.2", "C.3")))
14+
mdat
15+
makeCacheMatrix(mdat)
16+
cacheSolve(m)
17+
cacheSolve(mdat)
18+
d = makeCacheMatrix(mdat)
19+
d
20+
d$get()
21+
cacheSolve(d)
22+
mm <- matrix(c(1,2,3), c(4,5,6), c(7,8,9))
23+
mm <- matrix(c[1,2,3], c[4,5,6], c[7,8,9])
24+
b = matrix( c(1,2,3,4), nrow=2, ncol=2)
25+
c = makeInverse(b)
26+
c = makeCacheMatrix(b)
27+
b$get
28+
c$get
29+
c$get()
30+
d = cacheSolve(c)
31+
debugSource('~/dev/r/ProgrammingAssignment2/cachematrix.R')
32+
}
33+
d = cacheSolve(c)
34+
c$getInverse()
35+
c$getInverse
36+
debugSource('~/dev/r/ProgrammingAssignment2/cachematrix.R')
37+
c$getInverse()
38+
d = cacheSolve(c)
39+
d
40+
c$getInverse()
41+
d = cacheSolve(c)
42+
c$getInverse()
43+
c$getInverse
44+
d = cacheSolve(c)
45+
debugSource('~/dev/r/ProgrammingAssignment2/cachematrix.R')
46+
debugSource('~/dev/r/ProgrammingAssignment2/cachematrix.R')

cachematrix.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ makeCacheMatrix <- function(x = matrix()) {
2020
## Before compute the inverse of matrix x, see if x has it cached , and return that if do.
2121

2222
cacheSolve <- function(x, ...) {
23-
## Return a matrix that is the inverse of 'x'
23+
## Return a matrix that is the inverse of 'x'
2424
m <- x$getInverse()
2525
if (!is.null(m)) {
2626
message("getting cached data")
2727
return (m)
2828
}
2929
data <- x$get()
30-
m <- solve(data)
30+
m <- solve(data, ...)
3131
x$setInverse(m)
3232
m
3333
}

0 commit comments

Comments
 (0)