# Computation

Is your research software correct?

## (Macro)Economics

(Macro)Economics

- Wouter den Haan's notes
- Jesus Fernandez-Villaverde's nodes
- Quantitative Economics, lecture notes by Sargent and Stachurski, Python and Julia
- Open Source Macroeconomics Laboratory Bootcamp (BFI, University of Chicago)
- A Practical Guide to Parallelization in Economics, Fernández-Villaverde and Valencia (Julia, C++, R, MATLAB, Python, GPUs)
- Center for Macroeconomics software listing
- Heterogenous Agents Resources & toolKit using Python/Anaconda
- Code appendices for papers published in RED, mostly Matlab and Fortran

## Fortran

Fortran

### Compilers and IDEs

Compilers and IDEs

For Linux and OS X (via Homebrew?), the obvious choice is gfortran. For Windows, there are a few options...

- For
*students*, the Intel compiler is freely available as part of Parallel Studio XE (Windows, Linux, and Mac) - Free ("gratis") compiler with MPI and OpenACC: PGI CE (from Nvidia, with optional GPGPU features, for all major OSs)
- SimplyFortran (commercial) with a MS-MPI Package
- Cygwin or MSYS2, general purpose Linux-y/GNU-y environments for Windows, for gcc and gfortran
- Windows 10's Windows Subsystem for Linux (then
`sudo apt install gfortran`

)

### Language and Libraries

Language and Libraries

- Fortran Best Practices. I dislike the case convention and style guide, but otherwise an excellent resource.
- Grey Gordon's notes on Computational Macro with Fortran (exceptionally great!)
- The Fortran Wiki
- F95 Self-study handout (pdf) by Padman
- Fortran for C Programmers
- Fortran and Gauss code for the Heer and Maussner textbook
- Coarrays over MPI with gfortran 5 or newer
- bsplines, 1-D to 6-D, with optional object-oriented interface
- Minpack, for systems of equations (including Powell's hybrid method)
- NLopt, for constrained, (derivative-free) local and global maximization

## Julia

Julia

- Maximization: JuMP with NLopt.jl
- QuantEcon.jl code, with documentation (time series, dynamic programming, LQ, etc.)
- Root-finding and systems of equations: NLsolve.jl
- Interpolation: Interpolations, ApproxFun.jl and Dierckx.jl (fast, but 1- and 2-D only)
- Calling Fortran from Julia

## MATLAB and GPUs

MATLAB and GPUs

- Examples of GPU usage with MATLAB:
- gpuIFP.m The "income fluctuations problem" and its stationary distribution
- sovDef.zip Canonical sovereign default model with short-term debt and quadratic penalty function

- Local methods, deterministic/perfect foresight, filtering and more with Dynare
- Occasionally-binding constraints with OccBin (Guerrieri-Iacoviello)
- The RISE Toolbox: Solution and estimation of Markov Switching Rational Expectations / DSGE Models
- Lilia Maliar's MATLAB codes
- Robert Kirkby's Intro to Chebyshev Polynomials & Smolyak in MATLAB
- The Chebfun toolkit for approximating functions

## C++

C++

- The wiki reference for C++ and the STL
- Multidimensional array templates: Boost::Multi_Array, Armadillo
- Optimization and Root-Finding: NLopt, IMSL (commercial), dlib, Ceres Solver
- Akima splines 1- to 3-D, with gradients
- How-to mix C++11 and Fortran 2008
- ClangFormat for consistent code style

## Typesetting with LaTeX and Vector Graphics

Typesetting with LaTeX and Vector Graphics

- Embed MATLAB plots as TikZ figures with matlab2tikz
- TikzEdt, a largely WYSIWYG editor for TikZ diagrams
- The Ipe extensible drawing editor, LaTeX-based
- Find the name of any symbol or character by sketching it, with Detexify
- The Excel2LaTeX add-in, for table layout mockups. Better output with booktabs
- Split and merge PDF files with PDFtk (command line or GUI)

## Stata

Stata

- Installation of Stata on Linux and fixes for common issues
- Run Stata in a Jupyter notebook
- Stata module for the Hamilton filter