The goal of matrixmodp is to make two matrix algebra tasks easier when
working with the fields rref_p() calculates the reduced-row echelon
form of a matrix, and inv_p() calculates the inverse of a (square,
invertible) matrix.
You can install the public released version of matrixmodp from CRAN
with:
install.packages("matrixmodp")
#> Installing package into 'C:/Users/rhigginbottom/AppData/Local/Temp/Rtmpc35hmI/temp_libpath93c0442736d5'
#> (as 'lib' is unspecified)
#> Warning: package 'matrixmodp' is not available for this version of R
#>
#> A version of this package for your version of R might be available elsewhere,
#> see the ideas at
#> https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packagesYou can install the development version of matrixmodp from GitHub with:
# install.packages("devtools")
devtools::install_github("rhigginbottom/matrixmodp")We first provide an example of finding the RREF of a matrix with entries
in
library(matrixmodp)
entries <- c(4, 1, 2, 0, 0, 3, 4, 0, 0, 1, 4, 1)
A <- matrix(entries, 3, 4)
rref_p(A, 5)
#> [,1] [,2] [,3] [,4]
#> [1,] 1 0 0 4
#> [2,] 0 1 0 1
#> [3,] 0 0 1 0We now show how to find the inverse of a
library(matrixmodp)
entries <- c(3, 3, 3, 2, 0, 2, 1, 2, 5)
A <- matrix(entries, 3, 3)
inv_p(A, 7)
#> [,1] [,2] [,3]
#> [1,] 6 5 1
#> [2,] 3 3 1
#> [3,] 5 0 2Some of the code for the rref_p() function was taken from the
echelon() function in the matlib package. Because of the different
way row operations need to work when using entries in matlib package
because of this overlap in code.