An iterative algorithm for the optimal control of continuous–time switched linear systems