# Mathematica stuff

On this page I collected some Mathematica-related projects. This page is still under construction until everything is migrated from the old site. If you are looking for content from the old page, also check out the Mathematica-related blog posts!

# Packages

### BoolEval

This is a package that allows a simple notation for doing MATLAB-style vectorized computations on numerical arrays. For example, to count the number of array elements greater than 0.5, one might write `Count[arr, x_ /; x > 0.5]`. This is clean and readable, but there’s an orders of magnitude faster way to do the same thing when working with a large packed numerical array:

``````Total@UnitStep[0.5 - arr]
``````

Unfortunately this is not vey readable, and for complex conditions and comparisons it becomes very unwieldy to write. The package provides an alternative notation,

``````BoolCount[arr > 0.5]
``````

There are functions for element selection, counting, and other similar operations, e.g.

``````BoolPick[arr, 0.5 < arr < 0.6]
``````

which would take the much more complex `Pick[arr, (1 - UnitStep[0.5 - arr]) UnitStep[0.6 - arr], 1]` to write by hand.

Get the code here.

### IGraphR

This package makes it easy to call the igraph graph manipulation library from Mathematica. This is useful both for graph operations that Mathematica doesn’t support and verifying results obtained with Mathematica.

Get the code here

### Mathematica on the Notre Dame CRC cluster

This package greatly simplifies running parallel Mathematica jobs on Notre Dame’s HPC cluster. Just include the package, which auto-detects the number of cores and hosts usable by the jobs and sets up Mathematica’s parallel tools appropriately.

Get the code here.

• See my blog posts tagged with `mathematica`.

• Mathematca at StackExchange — for help and questions about working with Mathematica.

• These are some of my favourite programming tricks and techniques, recommended for the intermediate Mathematica programmer:

• Mathematica plugin for IntelliJ IDEA — this makes IntelliJ IDEA into an excellent Mathematica code editor with smart syntax highlighting, auto-completion and source navigation.

• The Spelunking package makes it very easy to read the definitions of in-memory symbols. It can be used to see how some builtin or package functions work. I often use it on package functions even when the package source is available.

• SciDraw by Mark Caprio is a package for creating publication quality figures. It makes it easy to create figure grids and subfigures and provides fine grained control over many aspects of the figure. The tradeoff is that it takes more code to create figures than standard Mathematica and it takes a while to learn the syntax. Highly recommended for publication figures or situations where output quality is important, but not for everyday visualization.

• One of the first things I do when installing or upgrading Mathematica is set up shortcut keys for typingand 〛. Find the file `SystemFiles/FrontEnd/TextResources/Macintosh/KeyEventTranslations.tr` and add the following right after the line `EventTranslations[{`. Do make a backup before editing this file!

``````Item[KeyEvent["[", Modifiers -> {Command}],
FrontEndExecute[{FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],
"\[LeftDoubleBracket]", After]}]],

Item[KeyEvent["]", Modifiers -> {Command}],
FrontEndExecute[{FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],
"\[RightDoubleBracket]", After]}]],
``````

Now it’s possible to type 〚 and 〛 using Command-[ and Command-]. Using these special brackets makes the code much easier to read than `[[` and `]]`. On Windows or Linux replace `Command` with `Control`.