Skip to content

Commit 80536c5

Browse files
author
Mrudul P
committed
Adding comments to the code
1 parent 1fb1909 commit 80536c5

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

cachematrix.R

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
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-
# Function to cache inverse of Matrix
1+
# Function returns a list of functions which can be used to set/get data either to/from cache
72
makeCacheMatrix <- function(x = matrix()) {
83
m <- NULL # creating a variable m in global environment
94
set <- function(y){ # This function is used to set matrix direction
@@ -16,17 +11,16 @@ makeCacheMatrix <- function(x = matrix()) {
1611
x
1712
}
1813
setInv <- function(inv) {# Store Inverse to cache
19-
m <<- inv
14+
m <<- inv # Storing data to variable in global environment
2015
}
21-
getInv <- function(){
16+
getInv <- function(){ # Retrive from Cache
2217
m
2318
}
2419
list (set = set, get = get, setInv = setInv, getInv = getInv)
2520
}
2621

27-
28-
## Write a short comment describing this function
29-
22+
# Function returns inverse of Matrix.
23+
# Expects matrix as input.
3024
cacheSolve <- function(x, ...) {
3125
## Return a matrix that is the inverse of 'x'
3226
m <- x$getInv()

0 commit comments

Comments
 (0)