public static double[] concatenate(double[][] vectors){
  int numVectors=vectors.length;
  int length=vectors[0].length;
  double[] concat=new double[numVectors * length];
  for (int i=0; i < vectors.length; i++) {
    System.arraycopy(vectors[i],0,concat,i * length,length);
  }
  return concat;
}

public static double [ ] concatenate ( double [ ] [ ] vectors ) { int numVectors = vectors . length ; int length = vectors [ 0 ] . length ; double [ ] concat = new double [ numVectors * length ] ; for ( int i = 0 ; i < vectors . length ; i ++ ) { System . arraycopy ( vectors [ i ] , 0 , concat , i * length , length ) ; } return concat ; }
concatenates the vectors rows [ i ] , i = 0 . . . rows . length , into a single vector .
