refactored promote_scalar to allow matrix to be included after scalar/std-vector