Skip to content

Instantly share code, notes, and snippets.

@lukeolson
lukeolson / makediff.sh
Created October 7, 2022 20:13
latexdiff helper script
#!/bin/bash
set -e
# run latexdiff
# --disable-auto-mbox
# fixes issue with underling the current citations
# --config="PICTUREENV=(?:picture|DIFnomarkup|tabular)[\w\d*@]*"
# does not diff tabular environments
latexdiff --disable-auto-mbox\
@lukeolson
lukeolson / wacolors.py
Created May 12, 2022 19:23
Wes Anderson color pallete, matplotlib
# colors from here (MIT):
# https://github.com/karthik/wesanderson/blob/master/R/colors.R
# example from here:
# https://matplotlib.org/3.5.0/gallery/color/custom_cmap.html
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib.colors import LinearSegmentedColormap
@lukeolson
lukeolson / arraytotex.py
Created May 5, 2020 13:57
convert a numpy array to latex array
def totex(A):
m, n = A.shape
rstr = "".join(['r' for i in range(n)])
print('\\left[\\begin{array}{' + rstr + r'}')
for i in range(m):
for j in range(n):
if A[i,j] == 0:
print(' ', end='')
else:
a = A[i,j]
@lukeolson
lukeolson / test-pinv-speed.py
Last active February 1, 2018 19:37
test pinv speed
import scipy.linalg as sla
import numpy as np
from pyamg.util.linalg import pinv_array
from scipy.linalg.lapack import get_lapack_funcs
from scipy.linalg.lapack import _compute_lwork
import time
import matplotlib.pyplot as plt
%matplotlib inline
nt = 10
@lukeolson
lukeolson / .gitignore
Last active October 26, 2017 20:04
MG Cycle
.*.swp
@lukeolson
lukeolson / README.md
Last active August 29, 2015 14:16
basicmesh

There are two mesh files here.

mesh.e

This is an ne x 3 list of triangles. The three values are indices pointing to the thre vertices of the ne triangles.

mesh.v

@lukeolson
lukeolson / cspy.py
Last active July 8, 2019 16:23
matplotlib like color spy
def fastspy(A, ax, cmap=None):
""""
Parameters
----------
A : coo matrix
ax : axis
"""