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
55 lines (41 loc) · 1.45 KB
/
Copy pathcachematrix.R
File metadata and controls
55 lines (41 loc) · 1.45 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
## Put comments here that give an overall description of what your
## functions do
## Write a short comment describing this function
## This is a pair of functions that cache the inverse of a a matrix
makeCacheMatrix <- function(x = matrix()) {
d<- NULL
## The method used in setting the matrix
set<-function(z) {
x<<-z
d<<-NULL
}
##The method to get the matrix
get<-function()x
## Method to set the inverse of the matrix
severse<-function(my_matrix) d<<- my_matrix
#Method to get the inverse of the matrix
geverse<-function()d
## This returns a list of the methods
list(set=set, get=get, severse=severse, geverse=geverse)
}
## Write a short comment describing this function
## Compute the inverse of the special matrix returned by 'MakeCacheMatrix'
## If the inverse has already been calculated and the matrix has not changed,
## then the 'CacheSolve' function retrieves the inverse from the cache.
cacheSolve <- function(x, ...) {
## Return a matrix that is the inverse of 'x'
d<-x$geverse()
## This returns the inverse if it has already been set
if(!is.null(d)) {
message('Getting catched data')
return(d)
}
## This gets the matrix from our objects
reson<-x$get()
## This line calculates the inverse
d<- solve(reson,...)
## This sets the inverse to the object
x$severse(d)
## Returns the matrix
d
}