import from MLFIT
modified to compile with gcc, use vdt and eventually vectorize