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
41 lines (36 loc) · 1003 Bytes
/
Copy pathcachematrix.R
File metadata and controls
41 lines (36 loc) · 1003 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
41
## Put comments here that give an overall description of what your
## functions do
## Write a short comment describing this function
## function create a object contained a matrix and its basic functions
## which can cache its inverse
makeCacheMatrix <- function(x = matrix()) {
#m <- solve(x)
#print (m)
i <- NULL
set <- function(y) {
x <<- y
i <<- NULL
}
get <- function() x
setsolve <- function(solve) i <<- solve
getsolve <- function() i
list(set = set , get = get ,
setsolve = setsolve,
getsolve = getsolve)
}
## Write a short comment describing this function
## the function computes the inverse of the special matrix
## from makeCacheMatrix, if inverse has already been calculated
## the function return only the inverse from the cache
cacheSolve <- function(x, ...) {
## Return a matrix that is the inverse of 'x'
i <- x$getsolve()
if (!is.null(i)) {
message("getting cached data")
return(i)
}
data <- x$get()
i <- solve(data)
x$setsolve(i)
i
}