File tree Expand file tree Collapse file tree 3 files changed +43
-6
lines changed Expand file tree Collapse file tree 3 files changed +43
-6
lines changed Original file line number Diff line number Diff line change
1
+ .Rproj.user
2
+ .Rhistory
3
+ .RData
Original file line number Diff line number Diff line change
1
+ Version: 1.0
2
+
3
+ RestoreWorkspace: Default
4
+ SaveWorkspace: Default
5
+ AlwaysSaveHistory: Default
6
+
7
+ EnableCodeIndexing: Yes
8
+ UseSpacesForTab: Yes
9
+ NumSpacesForTab: 4
10
+ Encoding: UTF-8
11
+
12
+ RnwWeave: Sweave
13
+ LaTeX: pdfLaTeX
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
+ # # These functions provide a way to create an inverted matrix, and everytime
2
+ # # thereafter return a cached version of the matrix until another
3
+ # # matrix is inverted.
3
4
4
- # # Write a short comment describing this function
5
+ # # This function provides access to set and get a cached version of a matrix.
5
6
6
7
makeCacheMatrix <- function (x = matrix ()) {
7
-
8
+ im <- NULL
9
+ set <- function (y ) {
10
+ x <<- y
11
+ im <<- NULL
12
+ }
13
+ get <- function () x
14
+ setsolve <- function (inMatrix ) im <<- inMatrix
15
+ getsolve <- function () im
16
+ list (set = set , get = get ,
17
+ setsolve = setsolve ,
18
+ getsolve = getsolve )
8
19
}
9
20
10
21
11
- # # Write a short comment describing this function
22
+ # # This function returns an inverse of the matrix given to the makeCacheMatrix
23
+ # # function. If the matrix has already been inverted and cached, it will return
24
+ # # the cached version, otherwise, it will invert and then cache the matrix.
12
25
13
26
cacheSolve <- function (x , ... ) {
14
- # # Return a matrix that is the inverse of 'x'
27
+ m <- x $ getsolve()
28
+ if (! is.null(m )) {
29
+ message(" getting cached matrix" )
30
+ return (m )
31
+ }
32
+ data <- x $ get()
33
+ m <- solve(data , ... )
34
+ x $ setsolve(m )
35
+ m
15
36
}
You can’t perform that action at this time.
0 commit comments