|
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 | +## |
2 | 9 | ## Usage:
|
3 | 10 | ## source("cachematrix.R")
|
4 | 11 | ##
|
|
29 | 36 | ##
|
30 | 37 | ##
|
31 | 38 | ##
|
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: |
36 | 41 | ## 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 |
40 | 45 | makeCacheMatrix <- function(x = matrix()) {
|
41 | 46 |
|
42 |
| - inverseMatrix <- NULL |
| 47 | + matrixInverse <- NULL |
43 | 48 |
|
44 | 49 | set <- function(pMatrix) {
|
45 | 50 | x <<- pMatrix
|
46 |
| - inverseMatrix <<- NULL |
| 51 | + matrixInverse <<- NULL |
47 | 52 | }
|
48 | 53 |
|
49 | 54 | get <- function() {
|
50 | 55 | x
|
51 | 56 | }
|
52 |
| - setinverse <- function(pMatrix) inverseMatrix <<- pMatrix |
53 |
| - getinverse <- function() inverseMatrix |
| 57 | + setinverse <- function(pMatrix) matrixInverse <<- pMatrix |
| 58 | + getinverse <- function() matrixInverse |
54 | 59 |
|
55 | 60 | list(get = get,
|
56 | 61 | set = set,
|
57 | 62 | setinverse = setinverse,
|
58 | 63 | getinverse = getinverse)
|
59 | 64 | }
|
60 | 65 |
|
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. |
64 | 70 | cacheSolve <- function(x, ...) {
|
65 | 71 |
|
66 |
| - ## Return a matrix that is the inverse of 'x' |
67 | 72 | inverse <- x$getinverse()
|
68 | 73 | if(!is.null(inverse)) {
|
69 | 74 | message("getting cached data")
|
|
0 commit comments