public void addRow(List<Double> row) {
        if (row.size() != getNumCols()) {
            throw new MLException(String.format(
                    "Cannot add a row with mismatching number of columns to matrix. Expected: %d, Got: %d",
                    getNumCols(), row.size()));
        }
        for (Double value : row) {
            if (value == null) {
                throw new MLException("Cannot add a row with a null Double value");
            }
        }
        data.add(row);
    }