<commit_before>package sw705e15.wi.parsing;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class SparseMatrix<T extends Number>
{
	private final List<HashMap<Integer, T>> rowColumnsRepresentation;
	private final List<HashMap<Integer, T>> columnRowsRepresentation;

	public SparseMatrix(final int newRows, final int newColumns)
	{
		rowColumnsRepresentation = new ArrayList<>(newRows);

		for (int columnCounter = 0; columnCounter < newColumns; columnCounter++)
		{
			rowColumnsRepresentation.add(new HashMap<>());
		}

		columnRowsRepresentation = new ArrayList<>(newColumns);

		for (int rowCounter = 0; rowCounter < newRows; rowCounter++)
		{
			columnRowsRepresentation.add(new HashMap<>());
		}
	}

	public int rowSize()
	{
		return rowColumnsRepresentation.size();
	}
	
	public int columnSize()
	{
		return columnRowsRepresentation.size();
	}
	
	public void set(final int rowIndex, final int columnIndex, T value)
	{
		rowColumnsRepresentation.get(rowIndex).put(columnIndex, value);
		columnRowsRepresentation.get(columnIndex).put(rowIndex, value);
	}
	
	public T get(final int rowIndex, final int columnIndex)
	{
		return rowColumnsRepresentation.get(rowIndex).get(columnIndex);
	}
	
	public SparseMatrix<T> sub(final SparseMatrix<T> subtrahend)
	{
		if(subtrahend == null)
		{
			throw new IllegalArgumentException("Argument was null");
		}
		else if(this.rowSize() != subtrahend.rowSize() || this.columnSize() != subtrahend.columnSize())
		{
			throw new IllegalArgumentException("Matrix sizes did not match");
		}
		
		final SparseMatrix<T> resultMatrix = new SparseMatrix<>(rowSize(), columnSize());
		
		
		for(int rowCounter = 0; rowCounter < rowColumnsRepresentation.size(); rowCounter++)
		{
			
			//HashMap<Integer, T> column 
			
			//resultMatrix.put
		}
		
		return null;
	}
	
	public SparseMatrix<T> add(final SparseMatrix<T> addend)
	{
		if(addend == null)
		{
			throw new IllegalArgumentException("Argument was null");
		}
		else if(this.rowSize() != addend.rowSize() || this.columnSize() != addend.columnSize())
		{
			throw new IllegalArgumentException("Matrix sizes did not match");
		}
		
		return null;
	}
}<commit_msg>Added addition and subtraction operators<commit_after>package sw705e15.wi.parsing;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;

public class SparseMatrix
{
	private final List<HashMap<Integer, Double>> rowColumnsRepresentation;
	private final List<HashMap<Integer, Double>> columnRowsRepresentation;

	public SparseMatrix(final int newRows, final int newColumns)
	{
		rowColumnsRepresentation = new ArrayList<>(newRows);

		for (int columnCounter = 0; columnCounter < newColumns; columnCounter++)
		{
			rowColumnsRepresentation.add(new HashMap<>());
		}

		columnRowsRepresentation = new ArrayList<>(newColumns);

		for (int rowCounter = 0; rowCounter < newRows; rowCounter++)
		{
			columnRowsRepresentation.add(new HashMap<>());
		}
	}

	public int rowSize()
	{
		return rowColumnsRepresentation.size();
	}
	
	public int columnSize()
	{
		return columnRowsRepresentation.size();
	}
	
	public void set(final int rowIndex, final int columnIndex, Double value)
	{
		rowColumnsRepresentation.get(rowIndex).put(columnIndex, value);
		columnRowsRepresentation.get(columnIndex).put(rowIndex, value);
	}
	
	public Double get(final int rowIndex, final int columnIndex)
	{
		return rowColumnsRepresentation.get(rowIndex).get(columnIndex);
	}
	
	public SparseMatrix sub(final SparseMatrix subtrahend)
	{
		if(subtrahend == null)
		{
			throw new IllegalArgumentException("Argument was null");
		}
		else if(this.rowSize() != subtrahend.rowSize() || this.columnSize() != subtrahend.columnSize())
		{
			throw new IllegalArgumentException("Matrix sizes did not match");
		}
		
		final SparseMatrix resultMatrix = new SparseMatrix(rowSize(), columnSize());
		
		for(int rowCounter = 0; rowCounter < rowColumnsRepresentation.size(); rowCounter++)
		{
			final HashMap<Integer, Double> row = rowColumnsRepresentation.get(rowCounter);
			
			for(Entry<Integer, Double> entry : row.entrySet())
			{
				resultMatrix.set(rowCounter, entry.getKey(), entry.getValue() - subtrahend.get(rowCounter, entry.getKey()) );
			}
		}
		
		return resultMatrix;
	}
	
	public SparseMatrix add(final SparseMatrix addend)
	{
		if(addend == null)
		{
			throw new IllegalArgumentException("Argument was null");
		}
		else if(this.rowSize() != addend.rowSize() || this.columnSize() != addend.columnSize())
		{
			throw new IllegalArgumentException("Matrix sizes did not match");
		}
		
		final SparseMatrix resultMatrix = new SparseMatrix(rowSize(), columnSize());
		
		for(int rowCounter = 0; rowCounter < rowColumnsRepresentation.size(); rowCounter++)
		{
			final HashMap<Integer, Double> row = rowColumnsRepresentation.get(rowCounter);
			
			for(Entry<Integer, Double> entry : row.entrySet())
			{
				resultMatrix.set(rowCounter, entry.getKey(), entry.getValue() + addend.get(rowCounter, entry.getKey()));
			}
		}
		
		return resultMatrix;
	}
}
{'fraction_non_alphanumeric': 0.11962100276352151, 'fraction_numerical': 0.003355704697986577, 'mean_word_length': 4.790857142857143, 'pattern_counts': {'":': 0, '<': 38, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '964845', 'n_tokens_mistral': 1702, 'n_tokens_neox': 1511, 'n_words': 352}