Fixed globalphase to use sparse matrix