Automatic algorithm derivation and exploration in linear algebra for parallelism and locality