{"id":18430177,"url":"https://github.com/friendly/matlib","last_synced_at":"2025-04-13T00:43:58.980Z","repository":{"id":53781395,"uuid":"45190492","full_name":"friendly/matlib","owner":"friendly","description":"Matrix Functions for Teaching and Learning Linear Algebra and Multivariate Statistics","archived":false,"fork":false,"pushed_at":"2025-03-15T02:47:12.000Z","size":45705,"stargazers_count":64,"open_issues_count":7,"forks_count":16,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-13T00:43:51.649Z","etag":null,"topics":["diagrams","linear-equations","matrix","matrix-functions","matrix-visualizer","vector","vignette"],"latest_commit_sha":null,"homepage":"http://friendly.github.io/matlib/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/friendly.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-10-29T15:01:24.000Z","updated_at":"2025-03-22T11:21:51.000Z","dependencies_parsed_at":"2023-01-25T16:16:13.436Z","dependency_job_id":"a2dfdc39-bfe5-4662-8b77-83b33a6986c6","html_url":"https://github.com/friendly/matlib","commit_stats":{"total_commits":761,"total_committers":8,"mean_commits":95.125,"dds":0.3942181340341656,"last_synced_commit":"8ff1307426179acc5715bf31c3ce9ba708c2b595"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friendly%2Fmatlib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friendly%2Fmatlib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friendly%2Fmatlib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friendly%2Fmatlib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/friendly","download_url":"https://codeload.github.com/friendly/matlib/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650419,"owners_count":21139672,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["diagrams","linear-equations","matrix","matrix-functions","matrix-visualizer","vector","vignette"],"created_at":"2024-11-06T05:19:48.249Z","updated_at":"2025-04-13T00:43:58.961Z","avatar_url":"https://github.com/friendly.png","language":"R","readme":"\u003c!-- badges: start --\u003e\n\n[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/matlib)](https://cran.r-project.org/package=matlib)\n[![R-universe](https://friendly.r-universe.dev/badges/matlib)](https://friendly.r-universe.dev)\n[![Downloads](http://cranlogs.r-pkg.org/badges/grand-total/matlib)](https://cran.r-project.org/package=matlib)\n[![downloads](http://cranlogs.r-pkg.org/badges/matlib)](https://cran.r-project.org/package=matlib)\n[![pkgdown](https://img.shields.io/badge/documentation-blue)](https://friendly.github.io/matlib)\n\u003c!-- [![Dependencies](https://tinyverse.netlify.com/badge/matlib)](https://cran.r-project.org/package=matlib) --\u003e\n\n\u003c!-- badges: end --\u003e\n\n# matlib \u003cimg src=\"man/figures/logo.png\" align=\"right\" height=\"200px\" /\u003e\n\n**Matrix Functions for Teaching and Learning Linear Algebra and Multivariate Statistics**, http://friendly.github.io/matlib/\n\nVersion 1.0.1\n\nThese functions were originally designed for tutorial purposes in teaching \u0026 learning matrix algebra\nideas using R. In some cases, functions are provided for concepts or computations available\nelsewhere in R, but where the name is not obvious, e.g., `R()` for the rank of a matrix,\nor `tr()` for matrix trace.\n\nIn other\ncases, we provide cover functions to show or demonstrate an algorithm in more detail, sometimes\nproviding a `verbose =` argument to print the details of computations, e.g., `Det()` for a\nmatrix determinant, `Inverse()` for a matrix inverse, using `gaussianElimination()` to show the\nsteps.\n\nIn addition, a collection of functions are provided for drawing vector diagrams in 2D and 3D, illustrating\nvarious concepts of linear algebra more concretely than has been available before.\nFor example, \n\n* `showEqn(A, b)` shows the matrix equations $\\mathbf{A x} = \\mathbf{b}$ in text or LaTeX form, while\n`plotEqn(A, b)` and `plotEqn3d(A, b)` plots those equations in 2D or 3D space.\n\n* `matrix2latex()`, `latexMatrix()`, `Eqn()` and friends facilitate writing matrix equations in LaTeX.\n\n* `vectors()`, `vectors3d()` plot geometric vector diagrams in 2D or 3D, with other functions to draw\nangles and arcs.\n\n* `regvec3d()` calculates and plot vectors representing a bivariate regression model, `lm(y ~ x1 + x2)`\n\n## Installation 📦\n\nGet the released version from CRAN:\n\n     install.packages(\"matlib\")\n\nOr the development version from my [R-universe](https://friendly.r-universe.dev):\n\n    install.packages('matlib', repos = c('https://friendly.r-universe.dev', 'https://cloud.r-project.org'))\n\nThe development version can also be installed to your R library directly from this repo via:\n\n     if (!require(remotes)) install.packages(\"remotes\")\n     remotes::install_github(\"friendly/matlib\", build_vignettes = TRUE)\n\n\nThe functions that draw 3D graphs use the **rgl** package. On macOS, **rgl** requires that [XQuartz](https://www.xquartz.org/) be installed. After installing XQuartz, it's necessary either to log out of and back into your macOS account or to reboot your Mac.\n\n\n## Topics 🍪\n\nThe functions in this package are grouped under the following topics\n\n1. **Convenience functions**:  \n\n  - `tr()` - trace of a matrix\n  - `R()` - rank of a matrix\n  - `J()` - constant vector, matrix or array\n  - `len()` - Euclidean length of a vector or columns of a matrix\n  - `vec()` - vectorize a matrix\n  - `Proj(y, X)` - projection of vector y on columns of matrix **X**\n  - `mpower(A, p)` - matrix powers for a square symmetric matrix\n  - `xprod(...)` - vector cross-product\n\n2. **Determinants**: functions for calculating determinants by cofactor expansion\n\n  - `minor()` - Minor of A[i,j]\n  - `cofactor()` - Cofactor of A[i,j]\n  - `rowMinors()` - Row minors of A[i,]\n  - `rowCofactors()` - Row cofactors of A[i,]\n  - `Det()` - Determinants by elimination or eigenvalues\n\n3. **Elementary row operations**: functions for solving linear equations \"manually\" by the steps used in row echelon form and Gaussian elimination\n\n  - `rowadd()` - Add multiples of rows to other rows\n  - `rowmult()` - Multiply rows by constants\n  - `rowswap()` - Interchange two rows of a matrix\n\n4. **Linear equations**: functions to illustrate linear equations of the form $\\mathbf{A x = b}$\n\n  - `showEqn(A, b)` - show matrices (A, b) as linear equations, as text or in LaTeX\n  - `plotEqn(A, b)`, `plotEqn3d(A, b)`  - plot matrices (A, b) as linear equations\n  \n5. **Gaussian elimination**: functions for illustrating Gaussian elimination for solving systems of linear equations of the form\n$\\mathbf{A x = b}$.  These functions provide a `verbose=TRUE` argument to show the intermediate steps\nand a `fractions=TRUE` argument to show results using `MASS::fractions()`.\n\n  - `gaussianElimination(A, B)` - reduces $(A, B)$ to $(I, A^{-1} B)$\n  - `Inverse(X)`, `inv()` - uses `gaussianElimination` to find the inverse of X, $\\mathbf{X}^{-1}$\n  - `echelon(X)` - uses `gaussianElimination` to find the reduced echelon form of X\n  - `Ginv(X)` - uses `gaussianElimination` to find the generalized inverse of X\n  - `LU(X)` - LU decomposition of a matrix X\n  - `cholesky(X)` - calculates a Cholesky square root of a matrix\n  - `swp()` - matrix sweep operator\n\n6. **Eigenvalues**: functions to illustrate the algorithms for calculating eigenvalues and eigenvectors and related matrix decompositions and generalizations.\n\n  - `Eigen()` - eigenvalues and eigenvectors\n  - `SVD()` - singular value decomposition, \\$mathbf{X = U D V}$\n  - `powerMethod()` - find the dominant eigenvector using the power method \n  - `showEig()` - draw eigenvectors on a 2D scatterplot with a dataEllipse\n  - `MoorePenrose()` - illustrates how the Moore-Penrose inverse can be calculated using `SVD()`\n\n7. **Vector diagrams**: functions for drawing vector diagrams in 2D and 3D\n\n  - `arrows3d()` - draw nice 3D arrows\n  - `corner()`, `arc()` -  draw a corner or arc showing the angle between two vectors in 2D/3D\n  - `pointOnLine()` - position of a point along a line\n  - `vectors()`, `vectors3d()` - plot geometric vector diagrams in 2D/3D \n  - `regvec3d()` - calculate and plot vectors representing a bivariate regression model, `lm(y ~ x1 + x2)` in mean-deviation form.\n\n8. **Matrix equations in LaTeX** \n  - `matrix2latex()`: Convert matrix to LaTeX equation\n  - `latexMatrix()`: Create and manipulate LaTeX representations of matrices\n  - `latexMatrixOperations`: Matrix operators (e.g., `%*%`, `%O%`) and functions (`matmult()`, `kronecker()`) for matrix arithmetic, but rendered in LaTeX\n  - `Eqn()`: A wrapper for equations composed from `latexMatrix()` expressions and LaTeX text, with ability to preview the results in a Viewer pane.\n\n### Vignettes and presentations\n\nA small collection of vignettes is now available.  Use `browseVignettes(\"matlib\")` to explore them.\n\n| Vignette                                                                                  | Title                                                 |\n|-------------------------------------------------------------------------------------------|-----------------------------------------------        |\n| [a1-det-ex1](http://friendly.github.io/matlib/articles/a1-det-ex1.html)                   | Properties of determinants                            |\n| [a2-det-ex2](http://friendly.github.io/matlib/articles/a2-det-ex2.html)                   | Evaluation of determinants                            |\n| [a3-inv-ex1](http://friendly.github.io/matlib/articles/a3-inv-ex1.html)                   | Inverse of a matrix                                   |\n| [a4-inv-ex2](http://friendly.github.io/matlib/articles/a4-inv-ex2.html)                   | Matrix inversion by elementary row operations         |\n| [a5-ginv](http://friendly.github.io/matlib/articles/a5-ginv.html)                         | Generalized inverse                                   |\n| [a6-inv-3d](http://friendly.github.io/matlib/articles/a6-inv-3d.html)                     | Linear transformations and matrix inverse in 3D   |\n| [a7-eigen-ex1](http://friendly.github.io/matlib/articles/a7-eigen-ex1.html)               | Eigenvalues and Eigenvectors: Properties              |\n| [a8-eigen-ex2](http://friendly.github.io/matlib/articles/a8-eigen-ex2.html)               | Eigenvalues: Spectral Decomposition                   |\n| [a9-linear-equations](http://friendly.github.io/matlib/articles/a9-linear-equations.html) | Solving Linear Equations                              |\n| [aA-gramreg](http://friendly.github.io/matlib/articles/aA-gramreg.html)                   | Gram-Schmidt Orthogonalization and Regression         |\n| [aB-data-beta](http://friendly.github.io/matlib/articles/aB-data-beta.html)               | Vector Spaces of Least Squares and Linear Equations   |\n| [latex-equations](http://friendly.github.io/matlib/articles/latex-equations.html)   | LaTeX Equations with latexMatrix, Eqn and matrix2latex|\n\n\nSee also: \n\n* Fox \u0026 Friendly, [_Visualizing Simultaneous Linear Equations, Geometric Vectors, and Least-Squares Regression with the matlib Package for R_](papers/matlib-useR2016.pdf).\nJune 2016, useR! Conference, Stanford.\n\n\u003c!-- (https://socialsciences.mcmaster.ca/jfox/Papers/matlib-useR2016.pdf), --\u003e\n\n* Ivan Savov, [Linear algebra explained in four pages](https://souravsengupta.com/cds2016/lectures/Savov_Notes.pdf)\n\n* Michael Rodriguez \u0026 Andrew Zieffler [Matrix Algebra for Educational Scientists](https://zief0002.github.io/matrix-algebra/).\nAn online book describing matrix operations and their statistical applications, with R code for many examples.\n\n\n\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffriendly%2Fmatlib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffriendly%2Fmatlib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffriendly%2Fmatlib/lists"}