A general Z-scan theory