Description | Julia vs Python vs Fortran comparison using "Numerical Recipes" |
Author | aqreed [email protected] |
Version | 0.0.1 |
Python Version | 3.6 |
Python Requires | Numpy, Numba, Scipy |
Julia Version | 1.1 |
Julia Requires | HypothesisTests, Test |
Is Julia as fast as Fortran, and as easy as Python?
I will try to answer this question using the algorithms found in Press, W. H., Flannery, B. P., Teukolsky, S. A., Vetterling, W. T., 1986, Numerical Recipes. The Art of Scientific Computing, Cambridge University Press, 818 p
Each algorithm will have a separated directory containing source code and speed test in the compiled language (Fortran), Julia and Python. The naming criteria is:
- [algorithm].f90
- speed_[algorithm].f90
- [algorithm].jl
- [algorithm].py
Also two Jupyter notebooks will compare Julia and Python scripts time execution against the compiled language:
- [algorithm]_julia.ipynb
- [algorithm]_python.ipynb
The Fortran source code will be compiled along the necessary libs using a Python script:
- compile_fortran.py
This script will be called at the beginning of each notebook. Finally the results will be summarized in a readme file.
Install package numericalrecipes
(from the top directory) in development mode with:
$ pip install -e .
Then, functions may be called as:
import numericalrecipes as nr
nr.gammaln(1)
Run tests (from the top directory) with:
$ pytest
To install package NumericalRecipes
open the Julia console:
$ julia
Press "]" to enter pkg
mode. Then activate the pkg:
(v1.1) pkg> activate .
(NumericalRecipes) pkg>
Then, return to normal mode to import functions, which may be called as:
julia> using NumericalRecipes
julia> gammaln(1)
Run tests with:
julia> using Pkg
julia> Pkg.test("NumericalRecipes")