Skip to content

Instantly share code, notes, and snippets.

View egefeyzioglu's full-sized avatar

Ege Feyzioglu egefeyzioglu

View GitHub Profile
@egefeyzioglu
egefeyzioglu / displayMatrix.jl
Created November 10, 2023 11:09
Julia function to display a given matrix prettily in Markdown/KaTeX, optionally limiting the number of rows/columns shown
using Markdown;
# Displays given matrix R in Markdown using KaTeX
# Optional parameter lims sets how many rows and columns (respectively) will be shown
# \cdots, \vdots, and \ddots are used in place of skipped cells
function dispMatrix(R, lims=[Inf,Inf])
i = -1 # Start at beginIndex - 2 = 1 - 2 = -1. Minus 2 because one taken up by the \vdots, the other taken up by the last element
sizes = size(R)
show = min.(sizes,lims)
str = "\$\$\\begin{bmatrix} "
for row in eachrow(R)