Skip to content

Commit 6b44e4a

Browse files
author
Manoj Xavier
committed
Added comments
1 parent 2e577e3 commit 6b44e4a

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

cachematrix.R

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
## Put comments here that give an overall description of what your
2-
## functions do
1+
## makeCacheMatrix creates special "matrix" whereas the cacheSolve returns the inverse of the
2+
## matrix from cache, if it exists there. if not, it computes the inverse and returns it.
33

4-
## Write a short comment describing this function
4+
## makeCacheMatrix creates a special "matrix" ,which is a list containing a function to
5+
## 1. set the value of the matrix
6+
## 2. get the value of the matrix
7+
## 3. set the inverse of the matrix
8+
## 4. get the inverse of the matrix
59

610
makeCacheMatrix <- function(x = matrix()) {
711
inv <- NULL
@@ -19,7 +23,8 @@ makeCacheMatrix <- function(x = matrix()) {
1923
}
2024

2125

22-
## Write a short comment describing this function
26+
## cacheSolve returns the inverse of a matrix if it exists in the cache.
27+
## if not, it computes the inverse and returns it
2328

2429
cacheSolve <- function(x, ...) {
2530
## Return a matrix that is the inverse of 'x'
@@ -34,6 +39,8 @@ cacheSolve <- function(x, ...) {
3439
inv
3540
}
3641

42+
## Test both functions with test data
3743
a = matrix( c(4,10,23,12), nrow=2, ncol=2)
3844
mat <- makeCacheMatrix(a)
3945
cacheSolve(mat)
46+
cacheSolve(mat)

0 commit comments

Comments
 (0)