slight modification of R's lda package