Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a21631e

Browse files
committed
Update cachematrix.R
1 parent 1a3a49e commit a21631e

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

cachematrix.R

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
## makeCacheMatrix is the fuctintion creating an object and calculated the inversion value of the matrix.
22
## In case there is the matrix already calculated the cached value is used instead of calculation
33
makeCacheMatrix <- function(x = matrix()) {
4+
5+
## Initialization
46
invValX <- NULL
7+
58
set <- function(Y)
69
{
710
x <<- y
@@ -10,11 +13,11 @@ makeCacheMatrix <- function(x = matrix()) {
1013

1114
get <- function() x
1215

13-
setinverse<- function(inverse) inv_x <<-inverse
14-
getinverse <- function() inv_x
15-
list(set = set, get = get,
16-
setinverse = setinverse,
17-
getinverse = getinverse)
16+
# Calculate the inverse value
17+
setinverse<- function(inverse) invValX <<-inverse
18+
getinverse <- function() invValX
19+
20+
list(set = set, get = get, setinverse = setinverse, getinverse = getinverse)
1821
}
1922

2023
## The function cacheSolve returns the inverse of a matrix by function makeCacheMatrix.

0 commit comments

Comments
 (0)