Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update cachematrix.R #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

pratheeshnp
Copy link

No description provided.

pursh2002 referenced this pull request in pursh2002/ProgrammingAssignment2 Dec 16, 2014
jpavkov added a commit to jpavkov/ProgrammingAssignment2 that referenced this pull request Dec 19, 2014
borispetukhov added a commit to borispetukhov/ProgrammingAssignment2 that referenced this pull request Feb 22, 2015
russellding referenced this pull request in russellding/ProgrammingAssignment2 Jul 25, 2015
013b5b79 pushed a commit to 013b5b79/ProgrammingAssignment2 that referenced this pull request Oct 14, 2015
sharthee pushed a commit to sharthee/ProgrammingAssignment2 that referenced this pull request Oct 23, 2015
fixed vote number typo in get_senate_vote function spec
janekdb added a commit to janekdb/ProgrammingAssignment2 that referenced this pull request Feb 23, 2016
Example test run,

  > testCachingForMatrices(3000)
  [1] "Iteration rdpeng#1 seconds: 18"
  [1] "Iteration rdpeng#2 seconds: 0"
  [1] "Iteration rdpeng#3 seconds: 0"
  [1] "Iteration rdpeng#4 seconds: 0"
terrebonne added a commit to terrebonne/ProgrammingAssignment2 that referenced this pull request Aug 9, 2016
…s inverse. #1.  set value of the matrix rdpeng#2.  get value of the matrix rdpeng#3.  set value of the inverse rdpeng#4.  get value of the inversemakeCacheMatrix <- function(x = matrix()) {      j <- NULL     set <- function(y) {       x <<- y       j <<- NULL     }     get <- function() x     setinverse <- function(solve) j <<- solve     getinverse <- function() j     list(set = set, get = get, setinverse = setinverse, getinverse = getinverse)   } ## `cacheSolve` function computes the inverse of the "matrix" returned by `makeCacheMatrix` above.  #If the inverse has already been calculated (and the matrix has not changed), then`cacheSolve` should retrieve the inverse from the cache.  ## when giving: Error in x$getinverse : $ operator is invalid for atomic vectors cachesolve <- function(x, ...) {      i<- x$getinverse()     if(!is.null(j)) {       message("getting cached data")       return(j)     }     data <- x$get()     j<- solve(data, ...)     x$setinverse(j)     j  }


## makeCacheMatrix function creates a "matrix" object that caches its inverse.
#1.  set value of the matrix
rdpeng#2.  get value of the matrix
rdpeng#3.  set value of the inverse
rdpeng#4.  get value of the inversemakeCacheMatrix <- function(x = matrix()) {

    j <- NULL
    set <- function(y) {
      x <<- y
      j <<- NULL
    }
    get <- function() x
    setinverse <- function(solve) j <<- solve
    getinverse <- function() j
    list(set = set, get = get, setinverse = setinverse, getinverse = getinverse)
 
}
## `cacheSolve` function computes the inverse of the "matrix" returned by `makeCacheMatrix` above. 
#If the inverse has already been calculated (and the matrix has not changed), then`cacheSolve` should retrieve the inverse from the cache.

## when giving: Error in x$getinverse : $ operator is invalid for atomic vectors
cachesolve <- function(x, ...) { 
    i<- x$getinverse()
    if(!is.null(j)) {
      message("getting cached data")
      return(j)
    }
    data <- x$get()
    j<- solve(data, ...)
    x$setinverse(j)
    j

}
mksarnala referenced this pull request in mksarnala/ProgrammingAssignment2 May 15, 2017
cbirole added a commit to cbirole/ProgrammingAssignment2 that referenced this pull request Feb 27, 2018
makeCacheMatrix <- function(x = matrix()) {
  inv <- NULL   
  set <- function(y) { rdpeng#2
    x <<- y
    inv <<- NULL
    
  }
  get <- function() x rdpeng#1
  setinverse <- function(inverse) inv <<- inverse rdpeng#3
  getinverse <- function() inv rdpeng#4
  list(set=set, get=get, setinverse=setinverse,getinverse=getinverse)
}

#This function returns the inverse of matrix,
#it checks if the inverse has already been returned first. If so, it gets the result.
#if not, it retrieve the matrix from cache

cacheSolve <- function(x, ...) {
  ## Return a matrix that is the inverse of 'x'
  inv <- x$getinverse{ ##Chitra's comment- Unexpected '{'
    if(!is.null(inv)){
      message('getting cached data')
      return (inv)
    } #Chitra's comment- If I run this code in R - I get an error stating object 'inv' not found
    data <- x$get() #Chitra's comment- $ operator is unexpected here
    inv <- solve(data) #Chitra's comment- R is not able to coerce type 'closure' to vector type 'any'
    x$setinverse(inv) #Chitra's comment- $ is unexpected
    inv #Chitra's comment- Object 'inv' not found
  } #Chitra's comment- unexpected '}'
  
}
@Shakeab21 Shakeab21 mentioned this pull request Oct 21, 2018
harshtripathi6 added a commit to harshtripathi6/ProgrammingAssignment2 that referenced this pull request Apr 26, 2020
kenyasmiles referenced this pull request in kenyasmiles/ProgrammingAssignment2 Oct 13, 2020
wguo2017 added a commit to wguo2017/ProgrammingAssignment2 that referenced this pull request Aug 26, 2021
swsan added a commit to swsan/ProgrammingAssignment2 that referenced this pull request Nov 9, 2022
Merge branch 'master' of github.com:swsan/ProgrammingAssignment2

# Conflicts:
#	cachematrix.R
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant