Use `similar` instead of `Array` when allocating new arrays.

This change makes it possible to use home made arrays and still get a home made array in return when using the linear algebra functions.