Support for sparse matrices

Changed type of A from Array to AbstractArray