GithubHelp home page GithubHelp logo

Comments (3)

DIV015395 avatar DIV015395 commented on May 30, 2024

Put comments here that give an overall description of what your

functions do

Write a short comment describing this function

makeCacheMatrix <- function(x = matrix()) {
inv <- NULL ## initialize inv as NULL; will hold value of inverse matrix
set <- function(y) { ## set to assign new function
x <<- y ## value of matrix in parent environment
inv <<- NULL ## if there is a new matrix, reset inv to NULL
}
get <- function() {x} ## define the get function - returns value of the matrix argument
setInverse <- function(inverse) {inv <<- inverse} ## assigns value of inv in parent environment
getInverse <- function() {inv} ## gets the value of inv where called
list(set = set, get = get, setInverse = setInverse, getInverse = getInverse)
}

Write a short comment describing this function

cacheSolve <- function(x, ...) {
## Return a matrix that is the inverse of 'x'
inv <- x$getInverse()
if(!is.null(inv)) { ## if inverse has not been already cached, it is cached and collected
message("cached data collected")
return(inv)
}
m <- x$get()
assignmentprogramming2.txt
}

from programmingassignment2.

DIV015395 avatar DIV015395 commented on May 30, 2024

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

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

from programmingassignment2.

DIV015395 avatar DIV015395 commented on May 30, 2024

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

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

from programmingassignment2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.