This repository was archived by the owner on Jan 10, 2026. It is now read-only.
forked from rdpeng/ProgrammingAssignment2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcachematrix.R
More file actions
52 lines (46 loc) · 1.41 KB
/
cachematrix.R
File metadata and controls
52 lines (46 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
## Put comments here that give an overall description of what your
## functions do
## Write a short comment describing this function
## INVERSE MATRIX (Return a matrix that is the inverse of 'x')
makeCacheMatrix <- function(x = matrix()) {
# setting solve to NULL
mm <- NULL
# New value being assigned to x
set <- function(y) {
x <<- y
#Setting solve as NULL
mm <<- NULL
}
#Get function will return object
get <- function() x
#Mean function set, cache solve
setsolve <- function(solve) mm <<- solve
#Get object function, return object
getsolve <- function() mm
list(set = set, get = get,
#list of objects
setsolve = setsolve,
getsolve = getsolve)
}
## Write a short comment describing this function
#Object x calling get solve
cachesolve <- function(x, ...) {
mm <- x$getsolve()
#Check if cache solve present, and then return cached solve
if(!is.null(mm)){
return(mm)
}
#find solve of data
data <- x$get()
#call set solve
mm <- solve(data, ...)
#return solve
x$setsolve(mm)
mm
}
#Test
#matr1<-matrix(sample.int(10000,size=1089,replace=TRUE), nrow=33)
#bigvector<- makeCacheMatrix(matr1)
#cachesolve(bigvector)
#solve(matr1)
#matr1