updated source to handle scalar normalization. proper mex file compilation for printfs.