Skip to content

Commit 48dabca

Browse files
committed
First commit: implemented makeCacheMatrix
1 parent 7f657dd commit 48dabca

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

cachematrix.R

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
1-
## Put comments here that give an overall description of what your
2-
## functions do
1+
## Matrix inversion is usually a costly computation and there may be some benefit
2+
## to caching the inverse of a matrix rather than computing it repeatedly. These
3+
## functions implement such behaviour. These functions have been written to satisfy
4+
## the requirements of the Week 3 programming exercise.
35

4-
## Write a short comment describing this function
6+
## This function creates a special "matrix" object that can cache its inverse.
57

68
makeCacheMatrix <- function(x = matrix()) {
7-
9+
m <- NULL
10+
set <- function(y) {
11+
x <<- y
12+
m <<- NULL
13+
}
14+
get <- function() x
15+
setinv <- function(inv) m <<- inv
16+
getinv <- function() m
17+
list(set = set, get = get,
18+
setinv = setinv,
19+
getinv = getinv)
820
}
921

1022

11-
## Write a short comment describing this function
1223

1324
cacheSolve <- function(x, ...) {
14-
## Return a matrix that is the inverse of 'x'
25+
## Return a matrix that is the inverse of 'x'
26+
1527
}

0 commit comments

Comments
 (0)