fixes to pdmat & add unwhiten_winv