Solutions of quasi-phase-matching three-wave mixing (TWM) for a nonuniform grating structure with phase-shifted segments are derived by use of a matrix operator, for the first time to the authors' knowledge, under the small-signal approximation. Compared with iterative methods of coupled-mode equations, using these expressions can significantly shorten the calculation time, and they can be effectively applied to all-optical signal processing in TWM. The signal and pump bandwidths of wavelength conversion in difference-frequency mixing, as well as the all-optical gating bandwidth in sum-frequency mixing, are optimized with the matrix solutions. By comparison with loss-free waveguide, the propagation loss a of the waveguide decreases the conversion efficiency /spl eta/, but has little influence on the bandwidth. Numerical results show that /spl alpha/ can be ignored for nonlinear lengths L<20 mm, and the optimal bandwidth /spl Delta//spl lambda/ is sensitive to /spl eta/ and the variation in the grating period, but not to /spl alpha/.