Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 62 additions & 5 deletions cachematrix.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,72 @@
## Put comments here that give an overall description of what your
## functions do

## functions do

## Write a short comment describing this function

makeCacheMatrix <- function(x = matrix()) {
library(MASS)

makeCachematrix <- function(x=matrix())

{

inv<-NULL #initializing inverse as null

set<-function(y)

{

x<<-y

inv<<-NULL

}

get<-function()x #function to get matrix

setinv<-function(inverse)inv<<-inverse

getinv<-function()

{

inver<-ginv(x)

inver%*%x #function to obtain inverse of matrix

}

list(set =set, get=get,

setinv=setinv,

getinv=getinv)

}

cachesolve <- function(x,...) ##gets cache data

## Write a short comment describing this function
{

inv<-x$getinv()

if(!is.null(inv)) ##checking in inverse is null

{

message("getting cached data!")

return(inv)

}

data<-x$get()

inv<-solve(data....) ##calculates inverse value

x$setinv(inv)

inv

cacheSolve <- function(x, ...) {
## Return a matrix that is the inverse of 'x'
}