Skip to content

ProgrammingAssignment2 #2280

Open
Open
@alirezahassani

Description

@alirezahassani

Programming Assignment 2

in the first part create the function which can cache its inverse

contains set and get to assign a value to matrix

set and get the value of inverted matrix

makeCacheMatrix <- function(x = matrix()) {
inverted <- NULL
set <- function(y) {
x <<- y
inverted <<- NULL
}
get <- function() x
setInverted <- function(inverse) Inverted <<- inverse
getInverted <- function() Inverted

    list(set = set, get = get,
         setInverted = setInverted,
         getInverted = getInverted)

}

calculate inverted matrix

cacheSolve <- function(x, ...) {
m <- x$getInverted()
if(!is.null(m)) {
message("getting cached data")
return(Inverted)
}
m <- x$get()
Inverted <- solve(m, ...)
x$setInverted(Inverted)
Inverted
}

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