private double[] projectSparse(SparseNumberVector in,double[] ret){
  Arrays.fill(ret,0);
  for (int iter=in.iter(); in.iterValid(iter); iter=in.iterAdvance(iter)) {
    final int i=in.iterDim(iter);
    final double val=in.iterDoubleValue(iter);
    for (int o=0; o < ret.length; o++) {
      ret[o]+=val * matrix[o][i];
    }
  }
  return ret;
}

private double [ ] projectSparse ( SparseNumberVector in , double [ ] ret ) { Arrays . fill ( ret , 0 ) ; for ( int iter = in . iter ( ) ; in . iterValid ( iter ) ; iter = in . iterAdvance ( iter ) ) { final int i = in . iterDim ( iter ) ; final double val = in . iterDoubleValue ( iter ) ; for ( int o = 0 ; o < ret . length ; o ++ ) { ret [ o ] += val * matrix [ o ] [ i ] ; } } return ret ; }
project , exploiting sparsity ; but the transposed matrix layout would have been better . for projections where you expect sparse input , consider the opposite .
