Skip to content

Commit

Permalink
added my homework
Browse files Browse the repository at this point in the history
  • Loading branch information
mecsantos committed Feb 1, 2016
1 parent 7f657dd commit 4a611da
Showing 1 changed file with 37 additions and 8 deletions.
45 changes: 37 additions & 8 deletions cachematrix.R
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
}

0 comments on commit 4a611da

Please sign in to comment.