Reverted to double types for matrices