CACHING THE INVERSE OF A MATRIX

This assignment writes a pair of functions that cache the inverse of a matrix.
These functions are the makeCacheMatrix and cacheSolve functions.
This approach is beneficial to prevent repeated computations of a matrix inverse.

## This function creates a special "matrix" object that can cache its inverse

makeCacheMatrix <- function(x = matrix()) {

 f<-NULL
  set<-function(z){
    x<<-z
    f<<-NULL
  }
  get<-function() x
  setmatrix<-function(solve) f<<- solve
  getmatrix<-function() f
  list(set=set, get=get,
       setmatrix=setmatrix,
       getmatrix=getmatrix)
 }


-## Write a short comment describing this function
+## cacheSolve: This function computes the inverse of the special "matrix" returned by makeCacheMatrix above.

-cacheSolve <- function(x, ...) {
cacheSolve <- function(x=matrix(), ...) {
         ## Return a matrix that is the inverse of 'x'

  f<-x$getmatrix()
  if(!is.null(f)){
   message("getting cached data")
    return(f)
  }
  matrix<-x$get()
  f<-solve(matrix, ...)
  x$setmatrix(f)
  f
 }

#As an example, Store the matrix function in a variable "g", and
#use the casheSolve function to retrieve the inverse of a square matrix

g<-makeCacheMatrix()
#Run g$set(matrix(1:6,2,2)to store a matrix
g$set(matrix(1:6,2,2))
cacheSolve(g)