Algebraic objects and C++

One of the first things that engineers notice when they are exposed to the C++ programming language is the lack of built-in support for matrices and vectors, specially those who had worked previously with Fortran. I immediately started evaluating third-party libraries that I could use in my coding projects, and in the end I decided to craft my own implementation for matrices and vectors to reduce dependencies. When I finally coded my first Vector and Matrix classes, I was shocked to see its poor performance when compared to the BLAS implementation. This endeavor then turned into coding an interface to the BLAS interface, as one can find a finely tuned implementation of the BLAS interface in every scientific computing environment.

The introduction of the C++11 set of requirements opened a world of possibilities. Thus, instead of having different Vector and Matrix classes, I implemented a unique Array class template that can be used to instantiate vectors, matrices, and even higher-order rank tensors. The class template wraps a one-dimensional array, and member functions that depend on the rank of the array use variadic templates to handle the rank-dependent behavior. Finally, an entire framework was developed around the concepts of expression templates and operator overloading, providing the final user with Matlab-like mathematical syntax when dealing with algebraic objects. The resulting framework can run on both CPU and GPU, the latter by using the NVIDIA CUBLAS library.

Related publications

  • A. M. Aragón. "A C++11 implementation of arbitrary-rank tensors for high-performance computing." Computer Physics Communications 185.6 (2014), pp. 1681–1696