File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ # # Put comments here that give an overall description of what your
2
+ # # functions do
3
+
4
+ # # Write a short comment describing this function
5
+
6
+ # #
7
+ makeCacheMatrix <- function (x = matrix ()) {
8
+ # # Holds the cache value or if nothing is cached
9
+ cache <- NULL
10
+ # #seting matrix
11
+ set <- function (y ) {
12
+ x <<- y
13
+ cache <<- NULL
14
+ }
15
+ get <- function () {
16
+ x
17
+ }
18
+ cacheInv <- function (solve ) {
19
+ cache <<- solve
20
+ }
21
+ getInv <- function () {
22
+ cache
23
+ }
24
+ # # get a list - naming fuction for each element of the list
25
+ list (set = set , get = get , cacheInv = cacheInv , getInv = getInv )
26
+ }
27
+
28
+
29
+ # # Write a short comment describing this function
30
+
31
+ # # following function calculates the inverse of matrix created above "makeCacheMatrix"
32
+ cacheSolve <- function (y , ... ) {
33
+ # # get cache value if it is in cache
34
+ inverse <- y $ getInv()
35
+ if (! is.null(inverse )) {
36
+ # # Display msg if data is cached!
37
+ message(" -- getting cached data --" )
38
+ return (inverse )
39
+ }
40
+ data <- y $ get()
41
+ inverse <- solve(data )
42
+ y $ cacheInv(inverse )
43
+ inverse
44
+ }
45
+
You can’t perform that action at this time.
0 commit comments