Photonic crystal waveguide for second harmonic generation: exact solution