You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: cachematrix.R
+35-1Lines changed: 35 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -4,12 +4,46 @@
4
4
## Write a short comment describing this function
5
5
6
6
makeCacheMatrix<-function(x=matrix()) {
7
-
7
+
## Symbol m holds the calcuated inverse of a given matrix
8
+
m<-NULL
9
+
## function set is used to refresh the matrix ( x ) and the inverse ( m )
10
+
set<-function(y) {
11
+
x<<-y
12
+
m<<-NULL
13
+
}
14
+
15
+
## function get is used to retrieve the matrix
16
+
get<-function() x
17
+
18
+
## setinverse is used to set the inverse of a matrix into the symbol m
19
+
setinverse<-function(inverse) m<<-inverse
20
+
21
+
## getinverse is used to get the inverse matrix assigned to the symbol m by the setinverse function
22
+
getinverse<-function() m
23
+
24
+
## list will be the output when you create an object for makeCacheMatrix.
25
+
## This list contains the alias names for the private fucntions defined within the makeCacheMatrix. So this alias will be used to invoke the functions by using the object of makeCacheMatrix.
26
+
list(set=set, get=get,
27
+
setinverse=setinverse,
28
+
getinverse=getinverse)
8
29
}
9
30
10
31
11
32
## Write a short comment describing this function
12
33
34
+
## cacheSolve function is accepts the object of makeCacheMatrix and invoke the getInverse method. Incase already the inverse has been calculated and cached in the object then retrieve the cached value.
35
+
## if thre is no inverse has been already calculated then get the matrix by using the get method and calculate the inverse by using the solve function and store the inverse value into the object by caling the setinverse function
0 commit comments