Python scripts for NUS MA1522 Linear Algebra for Computing
Project description
linear-algebra
About
This project builds on SymPy's Matrix class and is designed for students taking NUS MA1522 Linear Algebra for Computing. It has implementations of most of the algorithms taught during the course (as of Sem 1 AY24/25).
Key Features
- Import matrices directly from $\rm\LaTeX$ or string/list representations.
- Step-by-step workings for most algorithms (including LU Factorisation, SVD, QR, diagonalization, and more).
- Enhanced symbolic matrix class with:
- Matrix creation from lists, $\rm\LaTeX$, or random values.
- Matrix decompositions: REF, RREF, LU, QR, SVD, diagonalization.
- Vector space operations: orthogonalization, projections, basis manipulation, subspace intersection, and more.
- Eigenvalue/eigenvector computations and characteristic polynomials.
- Custom pretty-printing and $\rm\LaTeX$ formatting, including augmented matrices.
- Support for both exact symbolic and numerical computations.
- Utilities for displaying results in Jupyter/IPython or standard Python.
- Follows MA1522 syllabus conventions for linear algebra and provides detailed, educational output.
- Rich set of custom types for representing decompositions, solutions, and factorizations.
Installation and Usage
Installation
Prerequisites
This project is best supported in a Jupyter Notebook environment with Python 3.10+. You can download Python from here.
Alternatively, you can use a minimal GUI developed by @MarcusMa06-code here.
Install Dependencies
It is recommended to use a virtual environment for managing dependencies.
-
Create a virtual environment:
python -m venv venv
-
Activate the virtual environment:
- On Windows:
venv\Scripts\activate
- On macOS/Linux:
source venv/bin/activate
- On Windows:
-
Install the library:
pip install ma1522-linear-algebra
It is recommended to use a Jupyter Notebook environment to run the code.
pip install notebook
Usage
Create a Jupyter Notebook test.ipynb. Within the notebook, run the following code.
from ma1522 import *
# Create Matrix objects
A = Matrix([[1, 2, 3],
[4, 5, 5],
[7, 8, 9]])
b = Matrix([[1],
[2],
[3]])
# Join matrices along the columns via `row_join`.
augmented_matrix = A.aug_line().row_join(b)
# `aug_line` adds a visual line that can be seen using `display`
display(augmented_matrix)
# Solution to the matrix equation Ax = b can be found using `solve`.
A.solve(rhs=b)
# Alternatively, the full steps with LU Factorisation can be found using `ref` with the appropriate options.
augmented_matrix.ref(verbosity=2)
Documentation of more functions can be found here.
More usage examples can be found under tutorials.
Live demonstration of the library can be found here.
Offline Documentation
An offline version of the documentation is available for download from the Releases page. This is useful for exam when you may not have internet access.
To use the offline documentation:
- Download
linear-algebra-docs-offline.zipfrom the latest release - Extract the ZIP to a folder
- Open
index.htmlin your browser
A quick reference guide is also available as a function in the library:
from ma1522 import sympy_commands
sympy_commands()
Building from Source
If the offline ZIP is not available in the releases, you can build it yourself:
-
Clone the repository:
git clone https://github.com/YeeShin504/linear-algebra.git cd linear-algebra
-
Install documentation dependencies:
pip install mkdocs-material mkdocs-jupyter
-
Build the documentation:
mkdocs build -
The documentation will be in the
site/folder. Opensite/index.htmlin your browser.
Credits
I would like to thank @DenseLance for his contributions.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ma1522_linear_algebra-1.2.0.tar.gz.
File metadata
- Download URL: ma1522_linear_algebra-1.2.0.tar.gz
- Upload date:
- Size: 59.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae5d2a94f21745bbeab2dbae035214395483edd2bba46afbd4799c63a4e6c70c
|
|
| MD5 |
dc12074e5c4e44681cd8b723e7d77359
|
|
| BLAKE2b-256 |
9f81a217c1ecb700145c7d0bf96a6c925eef9aa9dbbaab5d5658a6fa85768c74
|
Provenance
The following attestation bundles were made for ma1522_linear_algebra-1.2.0.tar.gz:
Publisher:
release.yml on YeeShin504/linear-algebra
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ma1522_linear_algebra-1.2.0.tar.gz -
Subject digest:
ae5d2a94f21745bbeab2dbae035214395483edd2bba46afbd4799c63a4e6c70c - Sigstore transparency entry: 1341040499
- Sigstore integration time:
-
Permalink:
YeeShin504/linear-algebra@76f5865a10029c8cca733bad8a61f17a29daf361 -
Branch / Tag:
refs/tags/v1.2.0 - Owner: https://github.com/YeeShin504
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@76f5865a10029c8cca733bad8a61f17a29daf361 -
Trigger Event:
release
-
Statement type:
File details
Details for the file ma1522_linear_algebra-1.2.0-py3-none-any.whl.
File metadata
- Download URL: ma1522_linear_algebra-1.2.0-py3-none-any.whl
- Upload date:
- Size: 50.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e581116f99ee5f0c15554166b180507f8ec070bf68efe8943ec9f0318eb99577
|
|
| MD5 |
e79d3dad36784730ec02e7d5cdfd29e2
|
|
| BLAKE2b-256 |
8d626429b91755b056e3eb8bb9dc3003d42f6d2a7aef8a8d8045b611b4c815f8
|
Provenance
The following attestation bundles were made for ma1522_linear_algebra-1.2.0-py3-none-any.whl:
Publisher:
release.yml on YeeShin504/linear-algebra
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ma1522_linear_algebra-1.2.0-py3-none-any.whl -
Subject digest:
e581116f99ee5f0c15554166b180507f8ec070bf68efe8943ec9f0318eb99577 - Sigstore transparency entry: 1341040555
- Sigstore integration time:
-
Permalink:
YeeShin504/linear-algebra@76f5865a10029c8cca733bad8a61f17a29daf361 -
Branch / Tag:
refs/tags/v1.2.0 - Owner: https://github.com/YeeShin504
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@76f5865a10029c8cca733bad8a61f17a29daf361 -
Trigger Event:
release
-
Statement type: