8000 Initial commit of assignment #2 · jrincon23/ProgrammingAssignment2@efb6646 · GitHub
[go: up one dir, main page]

Skip to content

Commit efb6646

Browse files
committed
Initial commit of assignment rdpeng#2
1 parent 7f657dd commit efb6646

File tree

3 files changed

+40
-6
lines changed

3 files changed

+40
-6
lines changed

.gitignore

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

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: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,32 @@
1-
## Put comments here that give an overall description of what your
2-
## functions do
1+
## Functions to cache a matrix inverse
32

4-
## Write a short comment describing this function
53

6-
makeCacheMatrix <- function(x = matrix()) {
4+
##Creates an special "matrix" object able to cache its inverse
75

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

1018

11-
## Write a short comment describing this function
19+
20+
##Computes the inverse of the special "matrix"
1221

1322
cacheSolve <- function(x, ...) {
14-
## Return a matrix that is the inverse of 'x'
23+
i <- x$getinverse()
24+
if(!is.null(i)){
25+
message("getting cached data for the matrix inverse")
26+
return(i)
27+
}
28+
mat <- x$get()
29+
i <- solve(mat, ...)
30+
x$setinverse(i)
31+
i
1532
}

0 commit comments

Comments
 (0)
0