Skip to content

Commit 1688cce

Browse files
authored
Fix LaTeX formatting in matrices.md
1 parent e939628 commit 1688cce

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

notes/matrices.md

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ $$
132132
**Mathematical formula (3×3)**
133133

134134
$$
135-
(A^{\mathsf T})_{r,c}=A_{c,r},\quad 0\le r,c<3.
135+
(A^T)_{r,c}=A_{c,r},\quad 0\le r,c<3
136136
$$
137137

138138
**Pseudocode (square, in-place)**
@@ -168,7 +168,7 @@ $$
168168
**Mathematical formula (2×3 → 3×2)**
169169

170170
$$
171-
(A^{\mathsf T})_{r,c}=A_{c,r},\quad 0\le r<3,\ 0\le c<2.
171+
(A^{\mathsf T})_{r,c}=A_{c,r},\quad 0\le r<3,\ 0\le c<2
172172
$$
173173

174174
**Pseudocode (rectangular, new matrix)**
@@ -213,7 +213,7 @@ $$
213213
**Mathematical formula (2×3)**
214214

215215
$$
216-
B_{r,c}=A_{r,\ C-1-c},\quad 0\le r<2,\ 0\le c<3.
216+
B_{r,c}=A_{r,\ C-1-c},\quad 0\le r<2,\ 0\le c<3
217217
$$
218218

219219
**Pseudocode (in-place)**
@@ -255,7 +255,7 @@ $$
255255
**Mathematical formula (3×3)**
256256

257257
$$
258-
B_{r,c}=A_{R-1-r,\ c},\quad 0\le r,c<3.
258+
B_{r,c}=A_{R-1-r,\ c},\quad 0\le r,c<3
259259
$$
260260

261261
**Pseudocode (in-place)**
@@ -301,7 +301,7 @@ $$
301301
**Mathematical formula (n×n)**
302302

303303
$$
304-
B_{r,c}=A_{n-1-c,\ r},\quad 0\le r,c<n.
304+
B_{r,c}=A_{n-1-c,\ r},\quad 0\le r,c<n
305305
$$
306306

307307
**Pseudocode (square, in-place via basics)**
@@ -338,7 +338,7 @@ $$
338338
**Mathematical formula (R×C → C×R)**
339339

340340
$$
341-
B_{r,c}=A_{R-1-c,\ r},\quad 0\le r<C,\ 0\le c<R\ \ (R{=}2,\ C{=}3).
341+
B_{r,c}=A_{R-1-c,\ r},\quad 0\le r<C,\ 0\le c<R\ \ (R{=}2,\ C{=}3)
342342
$$
343343

344344
**Pseudocode (rectangular, direct mapping)**
@@ -385,7 +385,7 @@ $$
385385
**Mathematical formula (n×n)**
386386

387387
$$
388-
B_{r,c}=A_{c,\ n-1-r},\quad 0\le r,c<n.
388+
B_{r,c}=A_{c,\ n-1-r},\quad 0\le r,c<n
389389
$$
390390

391391
**Pseudocode (square, via basics)**
@@ -446,7 +446,7 @@ $$
446446
**Mathematical formula (R×C → R×C)**
447447

448448
$$
449-
B_{r,c}=A_{R-1-r,\ C-1-c},\quad 0\le r<R,\ 0\le c<C.
449+
B_{r,c}=A_{R-1-r,\ C-1-c},\quad 0\le r<R,\ 0\le c<C
450450
$$
451451

452452
**Pseudocode (in-place via two flips)**
@@ -526,7 +526,7 @@ top ← left, left ← bottom, bottom ← right, right ← top
526526
For an $n\times n$ matrix and a position $(r,c)$ on layer $\ell$, a 90° CW rotation sends
527527

528528
$$
529-
(r,c)\ \mapsto\ (c,\ n-1-r)\ \mapsto\ (n-1-r,\ n-1-c)\ \mapsto\ (n-1-c,\ r).
529+
(r,c)\ \mapsto\ (c,\ n-1-r)\ \mapsto\ (n-1-r,\ n-1-c)\ \mapsto\ (n-1-c,\ r)
530530
$$
531531

532532
**Pseudocode (explicit loops, in-place)**
@@ -586,7 +586,7 @@ $$
586586
Let the matrix indices be $(r,c)$ with $0\le r<R,\ 0\le c<C$. For layer $\ell=0,1,\dots,L-1$ where $L=\left\lceil \tfrac{\min(R,C)}{2}\right\rceil$, set
587587

588588
$$
589-
t=\ell,\quad b=R-1-\ell,\quad left=\ell,\quad rgt=C-1-\ell .
589+
t=\ell,\quad b=R-1-\ell,\quad left=\ell,\quad rgt=C-1-\ell
590590
$$
591591

592592
Visit, in order:
@@ -660,11 +660,15 @@ $$
660660
Let $s=r+c$. For $s=0,1,\dots,R+C-2$, define
661661

662662
$$
663-
r_{\min}(s)=\max\!\big(0,\ s-(C-1)\big),\qquad
664-
r_{\max}(s)=\min\!\big(R-1,\ s\big).
663+
r_{\min}(s)=\max\!\big(0,\ s-(C-1)\big)
664+
$$
665+
666+
$$
667+
r_{\max}(s)=\min\!\big(R-1,\ s\big)
665668
$$
666669

667670
The diagonal set is $\{(r,s-r)\mid r_{\min}(s)\le r\le r_{\max}(s)\}$.
671+
668672
Traverse with alternating direction:
669673

670674
$$
@@ -708,6 +712,7 @@ Each cell is a node; edges connect neighboring walkable cells.
708712
**Grid-as-graph view (4-dir edges).** Each cell is a node; edges connect neighbors that are “passable”. Great for BFS shortest paths on unweighted grids.
709713

710714
**Example map (walls `#`, free `.`, start `S`, target `T`).**
715+
711716
Left: the map. Right: BFS distances (4-dir) from `S` until `T` is reached.
712717

713718
```
@@ -772,7 +777,8 @@ $$
772777

773778
Push S to a queue, expand in 4-dir layers, track distance/visited; stop when T is dequeued.
774779

775-
* Time: $O(R\cdot C)$; Space: $O(R\cdot C)$.
780+
* Time: $O(R\cdot C)$
781+
* Space: $O(R\cdot C)$
776782

777783
#### Connected Components (Islands)
778784

0 commit comments

Comments
 (0)