Skip to content

Commit 27c40a6

Browse files
committed
Initial trials
1 parent fe6d1d4 commit 27c40a6

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

cachematrix.R

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,24 @@
22
## Put comments here that give an overall description of what your
33
## functions do
44

5-
## Write a short comment describing this function
6-
7-
makeCacheMatrix <- function(x = matrix()) {
5+
## This function will create a new matrix obj which can cache inverse that can be used later
86

7+
makeCacheMatrix <- function(x = matrix(c(1,2,3,4),nrow = 2, ncol = 2, byrow = TRUE)) {
8+
9+
# ToDo: We need to make special matrix object, inverse of that object to be cached
10+
## inverse will be created in seperate routine
11+
## square 2x2 matrix
12+
print (x)
13+
cacheSolve(x)
914
}
1015

1116

12-
## Write a short comment describing this function
13-
17+
## This function computes the inverse of the special "matrix" returned by makeCacheMatrix above.
18+
## If the inverse has already been calculated (and the matrix has not changed),
19+
## then the cachesolve should retrieve the inverse from the cache.
1420
cacheSolve <- function(x, ...) {
21+
## Inverse of a matrix of the x which is getting passed in cachesolve
22+
invmat<-solve(mat)
23+
print (invmat)
1524
## Return a matrix that is the inverse of 'x'
1625
}

0 commit comments

Comments
 (0)