fix pivot index to use core.matrix functions correctly