rdpeng / ProgrammingAssignment2

Repository for Programming Assignment 2 for R Programming on Coursera
843 stars 143.51k forks source link

R-Programming_ProgrammingAssignment2 #1628

Open GayanWithanage opened 8 years ago

GayanWithanage commented 8 years ago

'makeCacheMatrix' creates a special "matrix" object while 'cacheSolve' function computes the inverse of the special "matrix" returned.

'makeCacheMatrix' creates a special "matrix" object that can cache its inverse.

makeCacheMatrix <- function(x = matrix()) { int <- NULL set <- function(a) { dig <<- a int <<- NULL } get <- function() dig setinverse <- function(inverse) int <<- inverse getinverse <- function() int list(set = set, get = get, setinverse = setinverse, getinverse = getinverse) }

'cacheSolve' function computes the inverse of the special "matrix" returned by makeCacheMatrix above and

if the inverse has already been calculated (and the matrix has not changed),

then cacheSolve retrieve the inverse from the cache.

cacheSolve <- function(dig, ...) { int <- int$getinverse() ## Return a matrix that is the inverse of 'dig' if(!is.null(int)) { message("getting cached data") return(int) } else{ data <- dig$get() int <- mean(data, ...) dig$setinverse(int) int } } cachematrix.txt

reitzig commented 8 years ago

This is not the way you should submit your assignment.

GayanWithanage commented 8 years ago

Yeah, I submitted again in the correct way. Thanks. On 5 Feb 2016 21:29, "Raphael R." notifications@github.com wrote:

This is not the way you should submit your assignment.

— Reply to this email directly or view it on GitHub https://github.com/rdpeng/ProgrammingAssignment2/issues/1628#issuecomment-180414715 .

GayanWithanage commented 8 years ago

Thank you very much for your comment. I completed the course...