code: protected PCMDirection detectDirection(ImportMatrix matrix) {
  
          // Compute homogeneity of rows
          double sumHomogeneityOfRow = 0;
          for (int row = 0; row < matrix.getNumberOfRows(); row++) {
  
              Map<String, Integer> types = new HashMap<>();
  
              // Retrieve types of values
              for (int column = 0; column < matrix.getNumberOfColumns(); column++) {
                  countType(matrix, row, column, types);
              }
  
              // Get the maximum proportion of a same type
              if (!types.isEmpty()) {
                  double homogeneityOfRow = Collections.max(types.values()) / (double) matrix.getNumberOfColumns();
                  sumHomogeneityOfRow += homogeneityOfRow;
              }
          }
  
          // Compute homogeneity of columns
          double homogeneityOfColumns = 0;
          for (int column = 0; column < matrix.getNumberOfColumns(); column++) {
              Map<String, Integer> types = new HashMap<>();
  
              for (int row = 0; row < matrix.getNumberOfRows(); row++) {
                  countType(matrix, row, column, types);
              }
  
              // Get the maximum proportion of a same type
              if (!types.isEmpty()) {
                  double homogeneityOfColumn = Collections.max(types.values()) / (double) matrix.getNumberOfRows();
                  homogeneityOfColumns += homogeneityOfColumn;
              }
  
          }
  
          if (sumHomogeneityOfRow / matrix.getNumberOfRows() > homogeneityOfColumns / matrix.getNumberOfColumns()) {
              return PCMDirection.PRODUCTS_AS_COLUMNS;
          } else {
              return PCMDirection.PRODUCTS_AS_LINES;
          }
  
      }
docs: Detect if products are represented by a line or a column
  @param matrix matrix
  @return direction of the matrix