[math-fun] Algorithm for matrix 'companionization'