class SparseMatrix extends AbstractMatrix {

    @Override
    public void add(int i, int j, double value) {
        checkBounds(i, j);
        boolean startNewColumn = false;
        if (j == currentColumn) {
            // ok, continue to fill row
        } else if (j > currentColumn) {
            // start new column
            columnStart[j] = values.size();
            currentColumn = j;
            startNewColumn = true;
        } else {
            throw new PowsyblException("Columns have to be filled in the right order");
        }
        if (!startNewColumn && i == rowIndices.get(rowIndices.size() - 1)) {
            int vi = values.size() - 1;
            values.setQuick(vi, values.getQuick(vi) + value);
        } else {
            values.add(value);
            rowIndices.add(i);
            columnStart[columnStart.length - 1] = values.size();
            columnValueCount[j]++;
        }
    }

      SparseMatrix(int rowCount, int columnCount, int[] columnStart, int[] rowIndices, double[] values);
      SparseMatrix(int rowCount, int columnCount, int estimatedNonZeroValueCount);

}