Skip to content

Programming Assignement 2 #2253

Open
Open
@escorial82

Description

@escorial82

These are the 2 functions

Make Cache Matrix:

makeCacheMatrix <- function(x = matrix()){
    inv <- NULL
    set <- function(y){
        x<<- y
        inv<<- NULL
    }
    get <- function() x
    setInv <- function(solve) inv<<- solve
    getInv <- function() inv
    list(set = set, get = get,
         setInv = setInv,
         getInv = getInv)

Solve the matrix, and check the result (the product of the Source Matrix and its inverse must be 1).

cacheSolve <- function(x, ...){
    inv <- x$getInv()
    if(!is.null(inv)){
        message('getting cached data')
        return(inv)
    }
    sourcematrix <- x$get()
    inv <- solve(sourcematrix,...)
    x$setInv(inv)
    inv
    sourcematrix %*% inv
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions