Skip to content

Commit 19a9584

Browse files
committed
spelling and renaming
1 parent 989dba7 commit 19a9584

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

cachematrix.R

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
##
1+
## The makeCacheMatrix(..) is a function which receives a matrix and returns a list
2+
## object with some internal get and set functions. get/set functions are to return
3+
## and receive the matrix, getinverse/setinverse are to return and receive the
4+
## matrix inverse.
5+
##
6+
## The cacheSolve(..) is a function which computes the matrix inverse and caches
7+
## the result.
8+
##
29
## Usage:
310
## source("cachematrix.R")
411
##
@@ -29,41 +36,39 @@
2936
##
3037
##
3138
##
32-
##
33-
##
34-
## a function wich recieves a matrix and return a list
35-
## with followin functions:
39+
## A function wich receives a matrix and returns a list
40+
## with following functions:
3641
## get() - returns the original matrix
37-
## set(m) - set the matrix, inverse matrix to NULL
38-
## setinverse(m) - sets the inversed matrix
39-
## getinverse() - return the inversed matrix or NULL
42+
## set(m) - set the matrix, matrixInverse to NULL
43+
## setinverse(m) - set the matrixInverse
44+
## getinverse() - returns the matrixInverse or NULL
4045
makeCacheMatrix <- function(x = matrix()) {
4146

42-
inverseMatrix <- NULL
47+
matrixInverse <- NULL
4348

4449
set <- function(pMatrix) {
4550
x <<- pMatrix
46-
inverseMatrix <<- NULL
51+
matrixInverse <<- NULL
4752
}
4853

4954
get <- function() {
5055
x
5156
}
52-
setinverse <- function(pMatrix) inverseMatrix <<- pMatrix
53-
getinverse <- function() inverseMatrix
57+
setinverse <- function(pMatrix) matrixInverse <<- pMatrix
58+
getinverse <- function() matrixInverse
5459

5560
list(get = get,
5661
set = set,
5762
setinverse = setinverse,
5863
getinverse = getinverse)
5964
}
6065

61-
## function which recieves a matrix and calculates its inversed matrix,
62-
## the inversed matrix gets cached
63-
## cache is only used if x has not changed
66+
## Function which receives the special object created by 'makeCacheMatrix' and
67+
## calculates its matrix inverse if it was not calculated before.
68+
## The matrix inverse gets cached by calling the 'setinverse' function.
69+
## To invert the matrix the solve function was used.
6470
cacheSolve <- function(x, ...) {
6571

66-
## Return a matrix that is the inverse of 'x'
6772
inverse <- x$getinverse()
6873
if(!is.null(inverse)) {
6974
message("getting cached data")

0 commit comments

Comments
 (0)