File tree Expand file tree Collapse file tree 1 file changed +41
-3
lines changed Expand file tree Collapse file tree 1 file changed +41
-3
lines changed Original file line number Diff line number Diff line change 1
1
# # Put comments here that give an overall description of what your
2
2
# # functions do
3
-
4
3
# # Write a short comment describing this function
5
4
6
- makeCacheMatrix <- function (x = matrix ()) {
5
+ # # ----------------------------------------- ##
6
+ # 1. set the value of the vector
7
+ # 2. get the value of the vector
8
+ # 3. set the value of the mean
9
+ # 4. get the value of the mean
10
+ # # ----------------------------------------- ##
7
11
12
+ makeCacheMatrix <- function (x = matrix ()) {
13
+
14
+ inverseMatrix <- NULL
15
+
16
+ set <- function (y ) {
17
+ x <<- y
18
+ inverseMatrix <<- NULL
19
+ }
20
+
21
+ get <- function () x
22
+ setinverse <- function ( inverse ) inverseMatrix <<- inverse
23
+ getinverse <- function () inverseMatrix
24
+ list ( set = set ,
25
+ get = get ,
26
+ setinverse = setinverse ,
27
+ getinverse = getinverse )
8
28
}
9
29
10
30
11
31
# # Write a short comment describing this function
12
32
33
+ # # ----------------------------------------- ##
34
+ # if it is possible solve inverse matrix
35
+ # # ----------------------------------------- ##
36
+
13
37
cacheSolve <- function (x , ... ) {
14
- # # Return a matrix that is the inverse of 'x'
38
+
39
+ # # Return a matrix that is the inverse of 'x'
40
+ xmatrix <- x $ getinverse()
41
+
42
+ if ( ! is.null( xmatrix )) {
43
+ message(" getting cached data." )
44
+ return ( xmatrix )
45
+ }
46
+
47
+ data <- x $ get()
48
+ xmatrix <- solve(data )
49
+
50
+ x $ setinverse(xmatrix )
51
+ xmatrix
15
52
}
53
+
You can’t perform that action at this time.
0 commit comments