Here's a collection of older codes I have written for various general or
specific scientific applications,
generally in Matlab or C/C++, and usually with enough documentation
to be useful.
Most codes are instead now on my `github`

page or that of Flatiron.

List of codes with links (`*.m`

files are Matlab;
otherwise it's C code which compiles under linux):

`FINUFFT`

: Flatiron Institute non-uniform fast Fourier transform (co-authors: J. Magland, L. af Klinteberg).`validspike`

: Spike-sorting and validation metric codes in MATLAB/MEX/C (co-author: J. Magland).`mwrapdemo`

: Minimally-complete example for interfacing C/Fortran to MATLAB via MEX+MWrap.`lsc2d`

(with Bowei Wu, Oct 2014): Spectrally-accurate quadratures for evaluation of 2D Cauchy, Laplace, and Stokes single- and double-layer potentials arbitrarily close to a smooth curve, interior or exterior.`lhelmfs`

(with Brad Nelson and Matt Mahoney, Sept 2014: fundamental solution evaluation for 2D Helmholtz equation with linear potential (gravity).`MPSpack`

: Object-oriented MATLAB toolbox for solution of 2D Helmholtz/Laplace boundary-value problems and eigenvalue problems. Fully documented with 80+ pages of tutorial and manual.`LP2D`

: self-interaction of Helmholtz layer-potentials on smooth planar curves (Alpert quadratures + uses FMMLIB2D). Mostly a helper for MPSpack.`localexp3d`

; 3D Helmholtz local expansion (spherical harmonic) evaluation, matrices, and S2L, D2L, with MEX interfaces (uses FMMLIB3D). Used for QBX and periodizing in 3D.`rpw2d`

: Fast generator of 2D Random Plane Waves at constant wavenumber magnitude.`vergini`

: Scaling method for Dirichlet eigenmodes in a variety of 2D domains`eigenmode`

: Method of Particular Solutions for Neumann eigenmodes of polygons (obsolete).- Various Nystrom BIE test codes in MATLAB: 2D convergence of Laplace BVPs in corner domains, all cases.
`fparamin`

: 1D minimization algorithm for Method of Particular Solutions (obsolete; see`MPSpack`

)`tfwd`

: Time-dependent photon migration package for voxellized 3D tissue geometries (diffusion, Monte Carlo, viewer)`slab`

: Time-dependent 3D diffusion equation for surface measurements on multi-layered media`glSpect`

: Real-time scrolling audio spectrogram (linux, OpenGL, ALSA). (Updated Jan 2016)`viewer`

: Interactive OpenGL oscilloscope-style viewer for multiple functions of 1,2 variables (eg vergini output)`pview`

: Interactive OpenGL animated viewer for particles in 3D`taylor`

: Demo of complex Taylor series with color (needs`show_zser.m`

)`ray`

: Simple ray-tracing code for generating photorealistic images of geometric solids-
`pdf2djvu`

: Unix shell script to convert multipage PDF files to the excellent, highly-compressed DjVu format, via PBM. - My Matlab file exchange contributions:
`legnum`

which annotates plots (5 star rating).

*Some of this material is based upon work supported by the National
Science Foundation under Grant Nos. DMS-0507614, 0811005, and 1216656*

- Luis Camunas-Mesa's
`NeuroCube`

(54 MB gzipped tar), a MATLAB GUI for generating realistic synthetic spike sorting timeseries including tens of thousands of distant neurons. This version is adjusted not to require the Stats Toolbox. However, the Parallel Toolbox is recommended due to the run time, which seems to be about 10 times longer than real time for a tetrode.

Layer Potentials in Two Dimensions. This links against the recent FMMLIB2D library of Greengard-Gimbutas 2011 to compute the self-interation of 2D Helmholtz SLP and DLP on potentials and normal derivatives on a single smooth closed curve. The curve is specified by equally-spaced quadrature nodes in the curve parametrization, the normals at the nodes, and the parametric speed at the nodes. The main content here is applying Alpert corrections in an efficient manner for the S, D, D^T operators. (The codes also apply them to the T operator, but this would only be meaningful when the difference of T_1-T_2 is taken at two wavenumbers.) The code also allows for the interaction of nearest-neighbor copies of the curve to be included, useful for periodic grating scattering problems. Thanks to Mike O'Neil and Zydrunas Gimbutas for pieces of their code.

This is needed if one wants to use FMM + GMRES iteration as a BVP solution technique in MPSpack

Download here the version of 10/17/12, and see README and Installation instructions.

(Obsolete; see `MPSpack`

in particular `@evp.solvespectrum`

method 'ms')

`fparamin`

is Matlab code to find a complete list of
local minima of a function of one variable lying in an interval,
in the style of
`fminbnd`

. The twist is that the function may return a vector
of values, all of which are used to find the minima (of
the smallest entry of the vector) more reliably. This is designed
for the Method of Particular Solutions (MPS), where the minima of
a vector of (generalized)
singular values are sought. Download gzipped
tar file
(0.5MB), which contains m-files to place in your matlab path,
and documentation (the PDF file).
Version 0.9; 14 Aug 2006.

`viewer`

is an interactive scientific data viewer for
multiple 1d and 2d real arrays, sampled on regular grids. It provides
natural `oscilloscope-like' modes of zoom and pan in 2d, and
rotation with free-spinning animation in 3d.
Arrays are read from a text file. (One day I plan to have arrays accessed in
memory and updated in real time using a forked process - let me know if you
hear of existence of similar display library).
It was written in 1999-2000, in C and OpenGL/GLUT,
and hasn't changed much since.
Go to the viewer page.

Most output files are in *viewer* format so can be immediately
displayed with the above software package.
A set of documented MATLAB M-files is included to perform basic I/O
in this format, plot billiard and basis geometries,
also driver routines which perform repeated system calls to
*vergini* and collect the result into MATLAB data structures.

The code is in continual development, according to my needs, from 1999-2004.
It is in C++ but makes minor use of ++ features, the object-orientation
coming from sensible use of C `struct`

s and modules.
The Makefile has options to sense architecture, and currently compiles
on Linux/i386, SGI/IRIX, Sun/Solaris platforms. Math library locations
(heavy use of BLAS/LAPACK is made) may need to be adjusted for your machine.

Download version of 9/18/12: gzipped tarball here,
or ZIP archive here.
Compilation once expanded is done by executing `make`

.

Numerical simulations of photon migration in complex segmented 3D
geometries.
*tfwd* stands for **t**ime-dependent **f**or**w**ar**d**
models.
The two physical models are

- Radiative transport via Monte Carlo simulation (with David Boas and Jon Stott), an update of code described here, and
- Diffusion approximation via finite-difference time evolution, described and used here.

The complete package, download here (512kB), also provides minimal documentation, example files, and Makefile for compilation on Linux systems. To install, untar then use make with no options. (The slab package below is included; untar it from inside slab directory). tFDimg.c source should be altered for single (default) or double precision.

It stands at version 6 (Monte Carlo v.6 and Finite Difference v.3), Nov 2004.

Fast numerical simulation of time-dependent diffusion (heat equation) in multi-layered 3D slab geometry, either of finite or infinite total thickness. Used for simulation of photon migration in layered tissue such as the cranial surface of the human head. The method actually is applicable to arbitrary depth profiles of absorption and scattering coefficients. The method is described this preprint.

The algorithm is efficient. For example it currently takes of order 0.1 sec to run for relative errors of 1%, a minimum desired measurement time of 100 ps, in a medium of reduced scattering coefficients about 1 per mm. It is still in development, and uses variable timestepping. The package is written as a C library with a MEX interface which allows it to be called from Matlab, or it may be linked and called directly from C or Fortran. Documentation is provided.

Download the package here (170kB).
To install, untar then compile within Matlab via `mex slab.c`

.
Test with Matlab code `test.m`

(undocumented). Matlab codes
`fig_*.m`

can be used to generate the figures from the accompanying paper.
The `matlab-free' way to use it is by calling the
routine from C or Fortran. An example driver `main.c`

is provided
which can be built by the `Makefile`

. Requires BLAS/LAPACK
libraries (adjust the makefile for your library locations).

It stands at version 1.5, July 2003, interface updated May 2006.

Interactive viewer for point particles in 3D. Options for solid spheres,
points, numbers. Uses OpenGL and GLUT libraries.
Useful to modify for your application. Contains crude 1st-order
Newtonian dynamics with regularized Coulomb interaction (this routine,
`evolve()`

should be replaced by your own). Coordinate arrays are global variables
for added
crudeness! Download tar file (30kB).
(last updated Aug 2004).

Written in 1993 (during a boring summer internship in Manchester, UK) in the now-obsolete IRISGL predecessor to OpenGL, this program reads a human-readable scene description file (*.r) and generates a ray-traced image of the scene. It originally had interactive click and rotate interface to choose view direction with a wireframe model, menus, etc. I haven't ported that aspect to OpenGL. However I have extracted the computational core, which is here: r8_core.c. Compile against math library only. It implements multiple lights, reflection, refraction, bump-mapping, environment-mapping, quasi-random fractal textures (note the marble around the pool; I later discovered these had already been invented by Ken Perlin). The image is output as raw floats and can be read into matlab using imgread.m.

Here are example generated images (the scene files are pool.r and bob.r). They take around 1 minute each to compute: