All of this code is taken from Armadillo:
https://gitlab.com/conradsnicta/armadillo-code 
