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
40 lines (33 loc) · 905 Bytes
/
Copy pathcachematrix.R
File metadata and controls
40 lines (33 loc) · 905 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
38
39
40
# Functions:
# making cache matrix
# get inverse of matrix
# Setting the value of a matrix
# Getting its value
# Setting its invers and getting its inverse
# Creation of special list matrix whitch contain these data
makeCacheMatrix <- function(x = matrix()) {
cache <- NULL
setMatrix <- function(newValue){
x <<- newValue
cache <<- NULL
}
getMatrix <- function() x
setInverse <- function(inverse) cache <<- inverse
getInverse <- function () cache
list(setMatrix = setMatrix, getMatrix = getMatrix,
setInverse = setInverse,
getInverse = getInverse)
}
# Computing value of matrix
# Retrieving a cache value
cacheSolve <- function(x, ...) {
inverse <- x$getInverse()
if(!is.null(inverse)) {
message("getting cached data")
return(inverse)
}
data <- x$getMatrix()
inverse <- solve(data)
x$cacheInverse(inverse)
inverse
}