Here's a collection of 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.
If you use any of these, I'd really appreciate it if you do let me know
at
List of codes with links (*.m files are Matlab;
otherwise it's C code which compiles under linux):
MPSpack:
Object-oriented MATLAB toolbox for solution of Helmholtz/Laplace
boundary-value problems. Co-authored with Timo Betcke. Version 1.0
released Aug 2009. Fully documented plus 31-page tutorial.
(This will eventually supercede the following 3 codes, and more...)
vergini: Scaling method for
Dirichlet eigenmodes in a variety of 2D cavities
eigenmode:
Method of Particular Solutions for Neumann eigenmodes of polygons
(under development)
fparamin: 1D minimization
algorithm for Method of Particular Solutions
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
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)
rpw2d: Fast generator of 2D
Random Plane Waves at constant wavenumber magnitude
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.
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 and 0811005
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 structs 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 Gzipped tarball here. Compilation
once expanded is done by executing make.
Numerical simulations of photon migration in complex segmented 3D gometries. tfwd stands for time-dependent forward models. The two physical models are
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: