Preview

cachematrix1

Satisfactory Essays
Open Document
Open Document
270 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
cachematrix1
## The following functions calculate the inverse of a matrix and saves it
## to the cache such that the next time the user attempts to calculate the
## matrix inverse, the previously saved value is returned instead of
## repeating the calculation.

## This function creates a special "matrix" object, which is really a list
## containing a function to
## 1. set the value of the matrix
## 2. get the value of the matrix
## 3. set the value of the inverse
## 4. get the value of the inverse

makeCacheMatrix <- function(x = matrix()) { ## create a matrix object x and some associated sub-functions/methods ## define the cache m m <- NULL set <- function(y) { x <<- y ## assign the input matrix y to the variable x in the ## parent environment m <<- NULL ## re-initialize m in the parent environment to null } get <- function() x ## return the matrix x setinverse <- function(inverse) m <<- inverse ## set the cache m equal ## to the inverse of the matrix x getinverse <- function() m ## return the cached inverse of x list(set = set, get = get, setinverse = setinverse, getinverse = getinverse)
}

## The following function calculates the inverse of the special "matrix" created
## with the above function. However, it first checks to see if the inverse
## has already been caclulated. If so, it 'get's the inverse from the cache
## and skips the computation. Otherwise, it calculates the matrix inverse
## and sets the value of the inverse in the cache via the 'setinverse' function.

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
}

You May Also Find These Documents Helpful

  • Satisfactory Essays

    Mat126 Wk2 Dis 1

    • 343 Words
    • 2 Pages

    Fruits and vegetables are sold by the pound. Add up your prices per pound for the fruits and vegetables and find the average cost per pound. (Example: If bananas are .79 per pound and apples are .59 per pound, the average is calculated like this: (.79 + .59)/2 = 1.38/2 = .69 per pound on average for the two fruits.)…

    • 343 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Explanation: (4,1) corresponds to an arrow on a mapping diagram that starts at 4 and ends at 1. The first value in an ordered pair is the x-coordinate, which corresponds to the input column on a mapping diagram. The second value is the y-coordinate, which corresponds to the output column.…

    • 506 Words
    • 3 Pages
    Good Essays
  • Powerful Essays

    If > denotes +, < denotes –, + denotes  , Λ denotes x, – denotes =, x denotes > and =…

    • 1942 Words
    • 8 Pages
    Powerful Essays
  • Satisfactory Essays

    Many of his 14 points are process-driven, such as breaking down barriers between departments will lead to a reduction of waste, errors, and delay.…

    • 632 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    The next problem, I will be finding the solution for g(x). I will replace the x in the f function with the g function. My function will look like this:…

    • 495 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    unit 3

    • 313 Words
    • 2 Pages

    Some languages assign a default value as 0 to uninitialized variables. In many languages, however, uninitialized variables hold unpredictable values.…

    • 313 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    HIS145r7 Matrix W3

    • 678 Words
    • 3 Pages

    Title VI, 42 U.S.C. 2000d was enacted as part of the landmark Civil Rights Acts 1964. It prohibits discrimination on the basis of race, color, and national origin in programs and activities receiving financial assistance.…

    • 678 Words
    • 3 Pages
    Good Essays
  • Good Essays

    ISSC362 Lab 2 Assessment

    • 492 Words
    • 2 Pages

    The Hash Value is set to a exactly the value so once it is altered the values will change to the alteration.…

    • 492 Words
    • 2 Pages
    Good Essays
  • Good Essays

    Income Tax

    • 950 Words
    • 11 Pages

    8 Subtract line 7 from line 6. If zero or less, enter -0-. However, if line 7…

    • 950 Words
    • 11 Pages
    Good Essays
  • Satisfactory Essays

    06

    • 4188 Words
    • 33 Pages

    After the highest possible value for a sequence has been reached, previous values can be reused if the NOCYCLE option has been specified.…

    • 4188 Words
    • 33 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Psy Matrix

    • 268 Words
    • 2 Pages

    | |involves the client lying on a couch, unable to see the |behaviors and how to change those behaviors. |thinking. |…

    • 268 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Operating System

    • 1099 Words
    • 5 Pages

    Answer: d. It redirects the output of one command to the input of another command.…

    • 1099 Words
    • 5 Pages
    Good Essays
  • Satisfactory Essays

    Tda Cache 2

    • 312 Words
    • 2 Pages

    It is so important to apply the boundaries and rules for children and young people’s behaviour because it brings consistently to the class/school.…

    • 312 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    A1) Cache Level 3

    • 507 Words
    • 3 Pages

    For effective team work to contribute to the safety of children teaching assistants, school staff and outside agencies i.e.- social services, need to work closely with each other, communicating well by ensuring all relevant information is passed over to the right person by contributing in meetings. We as teaching assistants need to be fully aware of all policies, procedures and legislations within the school, like safeguarding, risk management, child protection and so on....also knowing the right person to approach if you have any concerns with the children; if a child has had an accident knowing, so knowing who the first aider is important so they can be assessed for any injuries and so on. If a child asked to talk to you and disclosed something that you think could put them in danger or come to any harm knowing the right person to handover the information to is vital because you could be putting the child at risk by not communicating with your team members. All staff should know who the two school child protection officers as one may be absent.…

    • 507 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    Apv and Wacc

    • 330 Words
    • 2 Pages

    | (supposed to handle financial side effect automatically, without requiring any addition after the fact)…

    • 330 Words
    • 2 Pages
    Satisfactory Essays

Related Topics