use mdivide_right_spd instead of inverse to test gradients.