In this thesis, I explore an approach called "active libraries". These are libraries that take
part in their own optimisation, enabling both high-performance code and the presentation of
intuitive abstractions.
I investigate the use of active libraries in two domains. Firstly, dense and sparse linear algebra,
particularly, the solution of linear systems of equations. Secondly, the specification and solution
of finite element problems.
Extending my earlier (MEng) thesis work, I describe the modifications to my linear algebra
library "Desola" required to perform sparse-matrix code generation. I show that optimisations
easily applied in the dense case using code-transformation must be applied at a higher level of
abstraction in the sparse case. I present performance results for sparse linear system solvers
generated using Desola and compare against an implementation using the Intel Math Kernel
Library. I also present improved dense linear-algebra performance results.
Next, I explore the active-library approach by developing a finite element library that captures
runtime representations of basis functions, variational forms and sequences of operations between
discretised operators and fields. Using captured representations of variational forms and
basis functions, I demonstrate optimisations to cell-local integral assembly that this approach
enables, and compare against the state of the art.
As part of my work on optimising local assembly, I extend the work of Hosangadi et al. on
common sub-expression elimination and factorisation of polynomials. I improve the weight
function presented by Hosangadi et al., increasing the number of factorisations found. I present
an implementation of an optimised branch-and-bound algorithm inspired by reformulating the
original matrix-covering problem as a maximal graph biclique search problem. I evaluate the
algorithm's effectiveness on the expressions generated by our finite element solver