Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9afdd02

Browse files
committed
initial import
1 parent 7f657dd commit 9afdd02

File tree

3 files changed

+47
-11
lines changed

3 files changed

+47
-11
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.Rproj.user
2+
.Rhistory
3+
.RData

ProgrammingAssignment2.Rproj

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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

cachematrix.R

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,35 @@
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-
61
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)
819
}
920

10-
11-
## Write a short comment describing this function
12-
1321
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+
}

0 commit comments

Comments
 (0)