FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ProgrammingAssignment2/cachematrix.R at master · Digital-Rabbit/ProgrammingAssignment2 · GitHub
Digital-Rabbit
/
ProgrammingAssignment2
Public
forked from
rdpeng/ProgrammingAssignment2
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
ProgrammingAssignment2
/
cachematrix.R
Copy path
More file actions
More file actions
Latest commit
History
History
History
39 lines (36 loc) · 1.14 KB
Breadcrumbs
ProgrammingAssignment2
/
cachematrix.R
Copy path
File metadata and controls
39 lines (36 loc) · 1.14 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#
# cachematrix.R
#
# Demonstrates how to cache data
#
# The makeCacheMatrix creates a special matrix object that can cache its inverse.
#
# It creates a list containing functions to
#
# 1. set the value of the matrix
#
# 2. get the value of the matrix
#
# 3. set the value of the inverse of the matrix
#
# 4. get the value of the inverse of the matrix
makeCacheMatrix
<-
function
(
x
=
matrix
()) {
m
<-
NULL
set
<-
function
(
y
) {
x
<<-
y
m
<<-
NULL
}
get
<-
function
()
x
setinverse
<-
function
(
inverse
)
m
<<-
inverse
getinverse
<-
function
()
m
list
(
set
=
set
,
get
=
get
,
setinverse
=
setinverse
,
getinverse
=
getinverse
)
}
#
# The cacheSolve function computes the inverse of the matrix returned by the
#
# makeCacheMatrix. If the inverse has been caclucated and the matrix has not
#
# changed, then cacheSolve retireves the inverse from the cache.
cacheSolve
<-
function
(
x
,
...
) {
#
# Return a matrix that is the inverse of 'x'
m
<-
x
$
getinverse()
if
(
!
is.null(
m
)) {
message(
"
getting cached data
"
)
return
(
m
)
}
data
<-
x
$
get()
m
<-
solve(
data
,
...
)
x
$
setinverse(
m
)
m
}
Back
|
FazBrowse Home
|
New Git URL