1
- # # Put comments here that give an overall description of what your
2
- # # functions do
3
-
4
- # # Write a short comment describing this function
1
+ # # library to provide matrix inversion caching
2
+ # #
3
+ # # software provides two functions to be used in concert for the purposes
4
+ # # of wrapping a matrix object with an adaptor that memoizes inversion calls.
5
+ # #
6
+ # # uses: to be used in cases where a large matrix must be inverted multiple times,
7
+ # # or if the inversion happens inside of a loop
8
+ # #
5
9
10
+ # # makeCacheMatrix
11
+ # #
12
+ # # Description
13
+ # # Wraps a matrix object in a list with getter/setters for matrix inversion. this
14
+ # # function should be called when preparing a matrix for use with the cacheSolve
15
+ # # function.
16
+ # #
17
+ # # Usage
18
+ # # tt <- matrix( rnorm(3000*3000,mean=0,sd=1), 3000, 3000)
19
+ # # cachingMatrix <- makeCacheMatrix(tt)
20
+ # #
21
+ # # Arguments
22
+ # #
23
+ # # x the matrix to be prepared for cached matrix inversion
24
+ # #
25
+ # # Returns
26
+ # #
27
+ # # a list with the keys set, get, setsolve, and getsolve
6
28
makeCacheMatrix <- function (x = matrix ()) {
7
29
m <- NULL
8
30
set <- function (y ) {
@@ -18,18 +40,34 @@ makeCacheMatrix <- function(x = matrix()) {
18
40
}
19
41
20
42
21
- # # Write a short comment describing this function
22
-
43
+ # # cacheSolve
44
+ # #
45
+ # # Description
46
+ # # When provided a matrix prepared by makeCacheMatrix, calls
47
+ # # the native solve function to execute matrix inversion. If
48
+ # # the matrix is inverted again, a memoized result is provided
49
+ # # thereby accelerating response time.
50
+ # #
51
+ # #
52
+ # # Usage
53
+ # # tt <- matrix( rnorm(3000*3000,mean=0,sd=1), 3000, 3000)
54
+ # # cachingMatrix <- makeCacheMatrix(tt)
55
+ # # inverseOfMatrix <- cacheSolve(cachingMatrix)
56
+ # #
57
+ # # Arguments
58
+ # #
59
+ # # x the object provided by makeCacheMatrix
60
+ # #
61
+ # # Returns
62
+ # #
63
+ # # the inverse of the original matrix, back in a native R matrix
23
64
cacheSolve <- function (x , ... ) {
24
- # # Return a matrix that is the inverse of 'x'
25
65
m <- x $ getsolve()
26
66
if (! is.null(m )) {
27
- message(" getting cached data" )
28
67
return (m )
29
68
}
30
69
data <- x $ get()
31
70
m <- solve(data , ... )
32
71
x $ setsolve(m )
33
72
m
34
-
35
73
}
0 commit comments