General CSP algorithm implementation for spatial filter construction