Skip to content

Instantly share code, notes, and snippets.

View eric-tramel's full-sized avatar
👷
🏗️ ⚒️ 🔧 🏛️

Eric W. Tramel eric-tramel

👷
🏗️ ⚒️ 🔧 🏛️
View GitHub Profile
@eric-tramel
eric-tramel / test_script.py
Created March 5, 2017 21:00
Test code for MLPhys Python 3 Environment
import scipy as sci
## Check Python Version
import sys
assert sys.version.find('3.6') > -1
## Check numpy
import numpy as np
from math import sqrt
@eric-tramel
eric-tramel / queue.c
Created May 28, 2016 19:37
My weird way of practicing C...covers a bunch of bases.
/*
In this program we will review the queue data structre from the perspective
of C.
However, technically, the implementation here is for a *circular array*
which we can access from either end, as well as popping from either end.
The main feature of this implementation is the fact that the framework is
general to the type of variable to be stored within the circular array.
Obviously, one might attempt an implementation using linked lists, which
@eric-tramel
eric-tramel / wcell2mat.m
Created February 9, 2016 14:48
wcell2mat.m
function wmat = wcell2mat(wcell)
L = length(wcell);
bb = wcell{end};
[rlo,clo] = size(bb);
wmat = bb;
for i=(L-1):-1:1
wmat = [wmat, wcell{i}{1};
@eric-tramel
eric-tramel / ConvertCIFAR.m
Created February 9, 2016 13:41
Script for converting all CIFAR to wavelet coefficients.
clear;
%% File Paths
fname = 'AllCIFAR.h5';
addpath(genpath('/Google Drive/Research/code/matlab/toolboxes/WaveletSoftware'));
%% Read in the HDF5 information
hi = hdf5info(fname);
X = hdf5read(hi.GroupHierarchy(1).Datasets(1));
@eric-tramel
eric-tramel / generate_synthetic_tomo_data.m
Created November 24, 2015 15:32
Synthetic Binary Tomo Data
function X = generate_synthetic_tomo_data(N,p,seed)
% GENERATE_SYNTHETIC_TOMO_DATA Create an NxN circle-masked synthetic image based
% on E.G.'s BP for Tomography package: https://github.com/eddam/bp-for-tomo.
% def generate_synthetic_data(l_x=128, seed=None, crop=True, n_pts=25):
% """
% Generate synthetic binary data looking like phase separation
% Parameters
% ----------
@eric-tramel
eric-tramel / Testing CUBLAS.ipynb.json
Last active September 28, 2015 09:49
Testing CUDArt.jl and CUBLAS.jl on Julia
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Testing CuBLAS and CUDArt for Julia\n",
"After finally getting NVCC to work on OSX, we can start using the CUDA-themed BLAS packages written for Julia. In this notebook we will document how to utilize the necessary datatypes and show comparisons between the CPU and GPU implementations of common BLAS functions."
]
},
2015-09-21 13:23:35 +0200
make
-C
contrib
-f
repackage_system_suitesparse4.make
prefix=/usr/local/Cellar/julia/HEAD
USE_BLAS64=0
FC=/usr/local/bin/gfortran
@eric-tramel
eric-tramel / eric_positive_armijo.m
Created December 19, 2014 16:10
Positive Constrained Minimization
function x = eric_positive_armijo(x0,f,g,h)
% Calculate a Newton-Step type minimization using the given
% f function, its gradient g, and its hessian (second order)
% h.
scalar_mode = false;
if isscalar(x0)
scalar_mode = true;
end
@eric-tramel
eric-tramel / gist:9125302
Created February 20, 2014 23:12
Jean's Panoply of Priors
classdef Prior
% This class contains all the prior-dependent functions including learnings
properties
av_mess; av_mess_old; var_mess; var_mess_old; R; S2; rho; learn; N; alpha; func; dump_learn; t; method; param_1; param_2; param_3; param_4;
% Gaussian sparse prior : p(x) ~ (1 - rho) * delta(x) + rho / sqrt(2 * pi * var_gauss) * exp(-(x - m_gauss)^2 / (2 * var_gauss) ) : param_1 = m_gauss; param_2 = var_gauss;
% Gaussian sparse prior enforcing value inside a symetric interval : p(x) ~ [(1 - rho) * delta(x) + rho / sqrt(2 * pi * var_gauss) * exp(-(x - m_gauss)^2 / (2 * var_gauss) )] * I(|x| < cut) : param_1 = m_gauss; param_2 = var_gauss; param_3 = cut;
% Positive Gaussian sparse prior : p(x) ~ (1 - rho) * delta(x) + rho / sqrt(2 * pi * var_gauss) * exp(-(x - m_gauss)^2 / (2 * var) ) * I(x > 0) : param_1 = m_gauss; param_2 = var_gauss;
% Mixture of two gaussians : p(x) ~ (1 - rho) * exp(-(x - m_1)^2 / (2 * var_1) ) / sqrt(2 * pi * var_1) + rho * exp(-(x - m_
@eric-tramel
eric-tramel / matrix_image_conv.m
Last active August 29, 2015 13:56
2D Convolution Matrix in Matlab
% Specify image
im_size = [128,128];
X = double(imread('peppers.png'));
X = imresize(X,im_size);
% Grab some kind of filter/PSF
PSF_dim = [4,4];
PSF = ones(PSF_dim);
PSF = PSF ./ norm(PSF(:));