forked from rdpeng/ProgrammingAssignment2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
37 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,44 @@ | ||
## Put comments here that give an overall description of what your | ||
## functions do | ||
## ProgrammingAssignment2 | ||
|
||
## Write a short comment describing this function | ||
## makeCacheMatrix converts an ordinary matrix into | ||
## a cache matrix, a matrix that stores it's inverse. | ||
|
||
makeCacheMatrix <- function(x = matrix()) { | ||
## cacheSolve calculates the inverse of the cache matrix | ||
## when it has not been calculated yet. | ||
|
||
} | ||
|
||
## makeCacheMatrix | ||
## Allows get and set of some matrix "x" | ||
## Stores the matrix inverse in "m" | ||
## Allows get and set of the inverse "m" | ||
## Returns a list of functions for getting and setting "x" and "m" | ||
|
||
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) | ||
} | ||
|
||
## Write a short comment describing this function | ||
## cacheSolve | ||
## Calculates and sets the inverse of a cache matrix | ||
## Returns the inverse "m" of cache matrix "x" | ||
|
||
cacheSolve <- function(x, ...) { | ||
## Return a matrix that is the inverse of 'x' | ||
} | ||
m <- x$getinverse() | ||
if(!is.null(m)) { | ||
message("getting cached data") | ||
return(m) | ||
} | ||
data <- x$get() | ||
m <- solve(data, ...) | ||
x$setinverse(m) | ||
m | ||
} |