forked from rdpeng/ProgrammingAssignment2
/
cachematrix.R
57 lines (57 loc) · 1.5 KB
/
cachematrix.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
## Filename: cachematrix.R
## Author: Dann Hekman
## Email: dannhek@gmail.com
## Start Date: 4/26/14
## Initial Commit Date: n/a
## Last Revision: n/a
## Purpose: Assignment for Coursera
## Johns Hopkins University RPROG-002
##---------------------------
## Revision History:
## 04/2014 - Created
## makeCacheMatrix
## cacheSolve
##---------------------------
## Function: makeCacheMatrix
## Start Date: 4/26/14
## Initial Commit Date: n/a
## Last Revision: n/a
## Description: description1
## description2
## Parameters:
## x (I,REQ) - a matrix to cache and invert
## Returns:
makeCacheMatrix <- function(x = matrix()) {
m <- NULL
set <- function(y) {
x <<- y
m <<- NULL
}
get <- function() x
setinverse <- function(solve) m <<- solve
getinverse <- function() m
list(set = set, get = get,
setinverse = setinverse,
getinverse = getinverse)
}
##---------------------------
## Function: cacheSolve
## Start Date: 4/26/14
## Initial Commit Date: n/a
## Last Revision: n/a
## Description: description1
## description2
## Parameters:
## x (I,REQ) - a matrix to cache and invert
## ... (I,OPT) - not currently used
cacheSolve <- function(x, ...) {
m <- x$getinverse()
if(!is.null(m)) {
message("getting cached data")
return(m)
}
data <- x$get()
m <- solve(data, ...)
x$setinverse(m)
m
}