Repository navigation
Expand file tree
/
Copy pathcachematrix.R
More file actions
63 lines (48 loc) · 1.61 KB
/
Copy pathcachematrix.R
File metadata and controls
63 lines (48 loc) · 1.61 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
56
57
58
59
60
61
62
63
## Put comments here that give an overall description of what your
## functions do
## Write a short comment describing this function
## This function creates a special "matrix" object that can cache its inverse.
makeCacheMatrix <- function(x = matrix()) {
##
## This function creates a matrix object and
## cache the inverse matrix of it. The function solve
## is beeing used to create the inverse matrix
##
## Following functions are inside:
## set: function for setting the matrix
## get: function for getting the matrix
## setsolve: function for setting the invers matrix
## getsolve: function for getting the invers matrix
##
mi <- NULL
set <- function(y) {
x <<- y
mi <<- NULL
}
get <- function() x
setsolve <- function(solve) mi <<- solve
getsolve <- function() mi
## returnvalues
list(set = set, get = get, setsolve = setsolve, getsolve = getsolve)
}
## Write a short comment describing this function
cacheSolve <- function(x, ...) {
##
## Return a matrix that is the inverse of 'x'
## If the inverse matrix has already been
## computed, than it returs the value from the
## cache and write the message for the user,
## the the cached data have been used.
##
mi <- x$getsolve()
## checking if the value of the matrix is cached
if(!is.null(mi)) {
message("getting cached data")
return(mi) ## return with the value
}
## otherwise compute the inverse matrix
data <- x$get()
mi <- solve(data, ...)
x$setsolve(mi)
mi
}