forked from rdpeng/ProgrammingAssignment2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcachematrix.R
More file actions
37 lines (30 loc) · 983 Bytes
/
cachematrix.R
File metadata and controls
37 lines (30 loc) · 983 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
## CachedMatrix Creation
## Ashish Verma May-20-2019
##Programming Assignment 2
#Function to create Cache Matrix.
makeCacheMatrix <- function(x = matrix()) {
indicator<-NULL ##Assigning NULL to indicator
set<-function(y){
x<<-y
indicator<<-NULL
}
get <- function() x
setinverse <- function(inverse) indicator <<- inverse ##Assigning inverse to indicator
getinverse <- function() indicator
list(set = set, ##In the list preparing the serinverse and gerinverse
get = get,
setinverse = setinverse,
getinverse = getinverse)
}
#Function to create the CacheSolve
cacheSolve <- function(x, ...) {
value <- x$getinverse()
if (!is.null(value)) { ##Checking if the value are not NULL
message("getting cached data") ##Printing the message
return(value)
}
data <- x$get()
i <- solve(data, ...)
x$setinverse(value)
value ##Returning the value back to fucntion call
}