A new algorithm for the design of uniform and nonuniform arrays of coupled optical waveguides