Gradient optimization for SC CW accelerators