Skip to content

Instantly share code, notes, and snippets.

View bryan-lunt's full-sized avatar

Bryan Lunt bryan-lunt

  • Department of Computer Science, UC San Diego
  • Urbana, Illinois
View GitHub Profile
@bryan-lunt
bryan-lunt / FindGBench.cmake
Last active February 11, 2022 22:12
CMake find_package file to find Google Benchmark. Just sets up targets, does not download. Only tested on Linux.
#Copyright 2022 Bryan J. Lunt <bryan.j.lunt@gmail.com>
#
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
@bryan-lunt
bryan-lunt / Picard.ipynb
Last active December 8, 2021 09:36
Simple Picard Iteration Example
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bryan-lunt
bryan-lunt / parallel_subjob_test.slurm
Last active September 19, 2021 05:42
Example for submitting multiple steps within a SLURM batch file, those steps should execute in parallel if possible.
#!/bin/bash
#SBATCH --time=04:00:00
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=12
#SBATCH --exclusive
#SBATCH --job-name subjob-sched-test
#SBATCH -p secondary
module load openmpi/4.1.0-gcc-7.2.0-pmi2 gcc cmake
@bryan-lunt
bryan-lunt / lu_fact.py
Created September 17, 2021 19:36
Simple LU factorization examples in Python
import numpy as np
def LU_recursive(A):
"""LU factorization without pivoting. Will fail if any diagonal is 0.
Recursive implementation.
"""
L = np.zeros_like(A,dtype=np.float_)
U = np.eye(*A.shape,dtype=np.float_)
a = A[0,0]
@bryan-lunt
bryan-lunt / sieve.cpp
Created February 7, 2019 21:56
Sieve of Eratosthenese
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <random>
#include <omp.h>
@bryan-lunt
bryan-lunt / MPI_benchmark_example
Created December 25, 2018 15:09 — forked from mdavezac/ MPI_benchmark_example
google/benchmark example with MPI
# for gist naming purposes
\documentclass[12pt]{amsart}
\usepackage{geometry} % see geometry.pdf on how to lay out the page. There's lots.
\geometry{a4paper} % or letter or a5paper or ... etc
% \geometry{landscape} % rotated page geometry
% See the ``Article customise'' template for come common customisations
\title{An example of using bibtex}
\author{Bryan Lunt}
\date{2017-6-20} % delete this line to display the current date
@bryan-lunt
bryan-lunt / bezier_curves.py
Created March 26, 2017 00:59 — forked from astrojuanlu/bezier_curves.py
Interactive Bézier curves with Python using just matplotlib.
import matplotlib
matplotlib.use('webagg')
import numpy as np
from scipy.special import binom
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
@bryan-lunt
bryan-lunt / flow_grid_layout.py
Created March 8, 2017 18:12
Simple Flow Layout for matplotlib
class FigHolder(object):
"""Base class for all the figure holders we might implement."""
def __init__(self, thefig):
self.fig = thefig
def add_subplot(self):
pass
def show(self):
self.fig.tight_layout()
@bryan-lunt
bryan-lunt / noise_injector.py
Created February 26, 2016 17:22
Noise Injection
#!/usr/bin/env python
import argparse
from gemstat.matrix import *
import sys
import scipy as S
parser = argparse.ArgumentParser()