Skip to content

Commit f2042f8

Browse files
committed
completed first pass at makeCacheMatrix function
1 parent e4eed41 commit f2042f8

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

cachematrix.R

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
## Put comments here that give an overall description of what your
22
## functions do
33

4-
## Write a short comment describing this function
4+
## Using a function call to create space to cache a matrix's inverse.
5+
## Functions to access that space are created: (get, set, getinv, setinv)
56

67
makeCacheMatrix <- function(x = matrix()) {
7-
8+
i <- NULL #initialize variable to store inverse
9+
set <- function(y) {
10+
#assign a matrix to this CacheMatrix
11+
x <<- y
12+
m <<- NULL
13+
}
14+
get <- function() x #get the matrix currently in this CacheMatrix
15+
setinv <- function(inv) i <<- inv #assign an inverse to this CacheMatrix
16+
getinv <- function() i #get the inverse currently in this CacheMatrix
17+
list(set = set, get = get, setinv = setinv, getinv = getinv)
818
}
919

1020

11-
## Write a short comment describing this function
21+
## Computes the inverse of a makeCacheMatrix 'matrix'. If the inverse has been
22+
##cached, it retrieves it.
1223

1324
cacheSolve <- function(x, ...) {
1425
## Return a matrix that is the inverse of 'x'

0 commit comments

Comments
 (0)