Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rdpeng/ProgrammingAssignment2
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: stishkin/ProgrammingAssignment2
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Jun 22, 2014

  1. Assignment 2

    Implementation of caching of inverse of a matrix
    stishkin committed Jun 22, 2014
    Copy the full SHA
    257aadc View commit details
Showing with 29 additions and 7 deletions.
  1. +29 −7 cachematrix.R
36 changes: 29 additions & 7 deletions cachematrix.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,37 @@
## Put comments here that give an overall description of what your
## functions do

## Write a short comment describing this function
## Module that implements calculating of matrix inverse and
## caching of the inverse for future re-use without need to calculate it again

## Creates a special "matrix" object that can cache its inverse.
makeCacheMatrix <- function(x = matrix()) {

s <- NULL
set <- function(y) {
x <<- y
s <<- NULL
}
get <- function() x
setsolve <- function(solve) s <<- solve
getsolve <- function() s
list(set = set, get = get,
setsolve = setsolve,
getsolve = getsolve)

}


## Write a short comment describing this function
## Computes the inverse of the special "matrix" returned by
## makeCacheMatrix above. If the inverse has already been calculated
## (and the matrix has not changed), then cacheSolve should retrieve
## the inverse from the cache.

cacheSolve <- function(x, ...) {
## Return a matrix that is the inverse of 'x'
## Return a matrix that is the inverse of 'x'
s <- x$getsolve()
if (!is.null(s)){
message("getting cached data")
return(s)
}
data <- x$get()
s <- solve(data, ...)
x$setsolve(s)
s
}