this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add row vectors and non-square matrices to grammar

Replaces hardcoded 2x2/3x3 matrix branch with a shape table covering
1x2, 1x3, 1x4 (row vectors), 2x2, 2x3, 3x2, 3x3. Column vectors
excluded since vec() already handles those. Shape is chosen via weighted
sample; rows assembled generically so adding new shapes is trivial.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

+8 -8
+8 -8
src/generate_typeset.py
··· 135 135 v, lo, hi = _atom(rng), _atom(rng), _atom(rng) 136 136 return f"product_({v} = {lo})^{hi} {_expr(rng, depth+1)}" 137 137 elif c < 0.70: 138 - if rng.random() < 0.35: 139 - e = [_atom(rng) for _ in range(9)] 140 - return (f"mat({e[0]}, {e[1]}, {e[2]}; " 141 - f"{e[3]}, {e[4]}, {e[5]}; " 142 - f"{e[6]}, {e[7]}, {e[8]})") 143 - else: 144 - e = [_atom(rng) for _ in range(4)] 145 - return f"mat({e[0]}, {e[1]}; {e[2]}, {e[3]})" 138 + # Matrix / row-vector shapes; column vectors handled by vec() instead 139 + nrows, ncols = rng.choices( 140 + [(1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (3, 2), (3, 3)], 141 + weights=[12, 12, 6, 20, 15, 10, 25], 142 + )[0] 143 + rows = [", ".join(_atom(rng) for _ in range(ncols)) 144 + for _ in range(nrows)] 145 + return f"mat({'; '.join(rows)})" 146 146 elif c < 0.73: 147 147 f_var = rng.choice(_VARS) 148 148 x_var = rng.choice(_VARS)