Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ To use the offline documentation:
2. Extract the ZIP to a folder
3. Open `index.html` in your browser

A quick reference guide is also available as a function in the library:
```python
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:
Expand Down
1,053 changes: 1,048 additions & 5 deletions docs/tutorials/tut01.ipynb

Large diffs are not rendered by default.

134 changes: 0 additions & 134 deletions docs/tutorials/tut03.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1528,140 +1528,6 @@
"# Therefore, det has only been scaled by a factor of 1 + x**3"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "b8678a5d",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Modified matrix for column 1:\n"
]
},
{
"data": {
"text/latex": [
"$\\displaystyle \\left[\\begin{array}{ccc}1 & 5 & 3\\\\2 & 2 & -2\\\\0 & 1 & 3\\end{array}\\right]$"
],
"text/plain": [
"Matrix([\n",
"[1, 5, 3]\n",
"[2, 2, -2]\n",
"[0, 1, 3]\n",
"])"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/latex": [
"$\\displaystyle \\text{Determinant for column }1: -2$"
],
"text/plain": [
"<IPython.core.display.Math object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Modified matrix for column 2:\n"
]
},
{
"data": {
"text/latex": [
"$\\displaystyle \\left[\\begin{array}{ccc}1 & 1 & 3\\\\0 & 2 & -2\\\\0 & 0 & 3\\end{array}\\right]$"
],
"text/plain": [
"Matrix([\n",
"[1, 1, 3]\n",
"[0, 2, -2]\n",
"[0, 0, 3]\n",
"])"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/latex": [
"$\\displaystyle \\text{Determinant for column }2: \\frac{3}{4}$"
],
"text/plain": [
"<IPython.core.display.Math object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Modified matrix for column 3:\n"
]
},
{
"data": {
"text/latex": [
"$\\displaystyle \\left[\\begin{array}{ccc}1 & 5 & 1\\\\0 & 2 & 2\\\\0 & 1 & 0\\end{array}\\right]$"
],
"text/plain": [
"Matrix([\n",
"[1, 5, 1]\n",
"[0, 2, 2]\n",
"[0, 1, 0]\n",
"])"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/latex": [
"$\\displaystyle \\text{Determinant for column }3: - \\frac{1}{4}$"
],
"text/plain": [
"<IPython.core.display.Math object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/latex": [
"$\\displaystyle \\left[\\begin{array}{c}-2\\\\\\frac{3}{4}\\\\- \\frac{1}{4}\\end{array}\\right]$"
],
"text/plain": [
"Matrix([\n",
"[ -2]\n",
"[ 3/4]\n",
"[-1/4]\n",
"])"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Matrix.from_str(\"1 5 3; 0 2 -2; 0 1 3\").cramer_solve(Matrix.from_str(\"1; 2; 0\"))\n",
"\n"
]
},
{
"cell_type": "markdown",
"id": "344bf798",
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/tut07.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "db1d293b",
"metadata": {},
"outputs": [
Expand All @@ -135,7 +135,7 @@
}
],
"source": [
"sol = mat.solve(aug)\n",
"sol = mat.solve(aug)[0]\n",
"sol"
]
},
Expand Down
9 changes: 5 additions & 4 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ site_author: Yee Shin Teng
site_url: https://yeeshin504.github.io/linear-algebra/
repo_url: https://github.com/YeeShin504/linear-algebra
repo_name: YeeShin504/linear-algebra
watch: [mkdocs.yml, README.md]
watch: [ mkdocs.yml, README.md ]
copyright: Copyright &copy; 2025 Yee Shin Teng

nav:
Expand Down Expand Up @@ -77,7 +77,7 @@ plugins:
- mkdocs-jupyter:
ignore_h1_titles: True
# live notebooks to be processed using jupyterlite plugin
ignore: ["live/*.ipynb"]
ignore: [ "live/*.ipynb" ]
execute: true
- jupyterlite:
notebook_patterns:
Expand All @@ -90,7 +90,7 @@ plugins:
default_handler: python_xref
handlers:
python_xref:
paths: [src]
paths: [ src ]
inventories:
- https://docs.python.org/3/objects.inv
- https://docs.sympy.org/latest/objects.inv
Expand Down Expand Up @@ -142,8 +142,9 @@ markdown_extensions:
custom_fences:
- name: mermaid
class: mermaid
format: !!python/name:pymdownx.superfences.fence_code_format
format:

!!python/name:pymdownx.superfences.fence_code_format
- toc:
permalink: true

Expand Down
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dev = [
"build>=1.2.2.post1",
"twine>=6.2.0",
"pytest-cov>=7.0.0",
"ma1522-linear-algebra",
]

docs = [
Expand All @@ -52,6 +53,14 @@ docs = [
[tool.uv]
default-groups = ["dev", "docs"]

[tool.uv.workspace]
members = [
".",
]

[tool.uv.sources]
ma1522-linear-algebra = { workspace = true, editable = true }

[tool.setuptools]
license-files = []

Expand Down
3 changes: 2 additions & 1 deletion src/ma1522/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .utils import display
from .utils import display, sympy_commands

from .custom_types import (
Shape,
Expand Down Expand Up @@ -30,4 +30,5 @@
"SVD",
"NumSVD",
"Matrix",
"sympy_commands",
]
12 changes: 8 additions & 4 deletions src/ma1522/custom_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
from typing import TYPE_CHECKING, NamedTuple

import sympy as sym
from sympy.matrices.exceptions import NonInvertibleMatrixError
from sympy.printing.latex import LatexPrinter

from .utils import _gen_latex_repr, _textify
# from ma1522 import utils

if TYPE_CHECKING:
from typing import Literal
Expand Down Expand Up @@ -407,10 +407,14 @@ class PDP(Printable):
def _latex(self, printer=None) -> str:
try:
P_inv = self.P.inv() # inv exists and is unique
# Normalize inverse to Matrix subclass so custom latex uses array formatting.
P_inv_fmt = self.P.__class__(P_inv, aug_pos=set())
return (
self.P._latex(printer) + self.D._latex(printer) + P_inv._latex(printer)
) # type: ignore
except Exception:
self.P._latex(printer)
+ self.D._latex(printer)
+ P_inv_fmt._latex(printer)
)
except NonInvertibleMatrixError:
return (
self.P._latex(printer)
+ self.D._latex(printer)
Expand Down
Loading
Loading