public static HashMap<CellIndex,Double> convert2DDoubleArrayToHashMap(double[][] matrix){
  HashMap<CellIndex,Double> hmMatrix=new HashMap<CellIndex,Double>();
  for (int i=0; i < matrix.length; i++) {
    for (int j=0; j < matrix[i].length; j++) {
      if (matrix[i][j] != 0)       hmMatrix.put(new CellIndex(i + 1,j + 1),matrix[i][j]);
    }
  }
  return hmMatrix;
}

public static HashMap < CellIndex , Double > convert2DDoubleArrayToHashMap ( double [ ] [ ] matrix ) { HashMap < CellIndex , Double > hmMatrix = new HashMap < CellIndex , Double > ( ) ; for ( int i = 0 ; i < matrix . length ; i ++ ) { for ( int j = 0 ; j < matrix [ i ] . length ; j ++ ) { if ( matrix [ i ] [ j ] != 0 ) hmMatrix . put ( new CellIndex ( i + 1 , j + 1 ) , matrix [ i ] [ j ] ) ; } } return hmMatrix ; }
converts a 2d array into a sparse hashmap matrix .
