File tree Expand file tree Collapse file tree 1 file changed +29
-10
lines changed Expand file tree Collapse file tree 1 file changed +29
-10
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
1
+ # This script does 2 things:
2
+ # 1. it stores data into an object and initializes a "storage space" for a computation performed on said data
3
+ # 2. it performs computation on the vector, returns an answer, and stores the answer in the storage space
3
4
4
- # # Write a short comment describing this function
5
-
6
- makeCacheMatrix <- function ( x = matrix ()) {
5
+ # ###############################################################################
6
+ # Assignment 2
7
+ # ###############################################################################
7
8
9
+ makeCacheMatrix <- function (x = matrix ()) { # The function where data is stored and "stotage" or cache is initialized
10
+ inv <- NULL
11
+ set <- function (y ) {
12
+ x <<- y
13
+ m <<- NULL
14
+ }
15
+ get <- function () x
16
+ setinv <- function (inverse ) inv <<- inverse
17
+ getinv <- function () inv
18
+ list (set = set , get = get ,
19
+ setinv = setinv ,
20
+ getinv = getinv )
8
21
}
9
22
10
-
11
- # # Write a short comment describing this function
12
-
13
- cacheSolve <- function (x , ... ) {
14
- # # Return a matrix that is the inverse of 'x'
23
+ cacheSolve <- function (x , ... ) { # A function that solves the inverse of a matrix 'x', the inverse is stored in makeCasheMatrix for fast retrival
24
+ inv <- x $ getinv()
25
+ if (! is.null(inv )) {
26
+ message(" getting cached data" )
27
+ return (inv )
28
+ }
29
+ data <- x $ get()
30
+ inv <- solve(data , ... )
31
+ x $ setinv(inv )
32
+ inv
15
33
}
34
+
You can’t perform that action at this time.
0 commit comments