Skip to content

Commit 00866c8

Browse files
author
Eduardo Arino de la Rubia
committed
Added documentation, followed provided rubric.
1 parent 57ac876 commit 00866c8

File tree

1 file changed

+47
-9
lines changed

1 file changed

+47
-9
lines changed

cachematrix.R

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,30 @@
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+
##
59

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
628
makeCacheMatrix <- function(x = matrix()) {
729
m <- NULL
830
set <- function(y) {
@@ -18,18 +40,34 @@ makeCacheMatrix <- function(x = matrix()) {
1840
}
1941

2042

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
2364
cacheSolve <- function(x, ...) {
24-
## Return a matrix that is the inverse of 'x'
2565
m <- x$getsolve()
2666
if(!is.null(m)) {
27-
message("getting cached data")
2867
return(m)
2968
}
3069
data <- x$get()
3170
m <- solve(data, ...)
3271
x$setsolve(m)
3372
m
34-
3573
}

0 commit comments

Comments
 (0)