8000 Commit #2 · chernir/ProgrammingAssignment2@cbfbdab · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cbfbdab

Browse files
committed
Commit rdpeng#2
1 parent 55fabba commit cbfbdab

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

cachematrix.R

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,33 @@
1-
##CHANGE TEST
1+
##This function creates a special "matrix" object that can cache its inverse.
22

33
makeCacheMatrix <- function(x = matrix()) {
4-
4+
i <- NULL
5+
set <- function(y) {
6+
x <<- y
7+
i <<- NULL
8+
}
9+
get <- function() x
10+
setinverse <- function(inverse) i <<- inverse
11+
getinverse <- function() i
12+
list(set = set,
13+
get = get,
14+
setinverse = setinverse,
15+
getinverse = getinverse)
516
}
617

718

8-
## Write a short comment describing this function
19+
## This function computes the inverse of the special"matrix" returned by `makeCacheMatrix` above. If the inverse has
20+
##already been calculated (and the matrix has not changed), then
21+
##`cacheSolve` should retrieve the inverse from the cache.
922

1023
cacheSolve <- function(x, ...) {
11-
## Return a matrix that is the inverse of 'x'
24+
i <- x$getinverse()
25+
if (!is.null(i)) {
26+
message("Getting Cached Data")
27+
return(i)
28+
}
29+
data <- x$get()
30+
i <- solve(data, ...)
31+
x$setinverse(i)
32+
i
1233
}

0 commit comments

Comments
 (0)
0