You can move X and Xcsr out of the loop.