<commit_before>#include <matrix.hpp>

	Matrix :: Matrix(){};

	Matrix :: Matrix(int a, int b)
	{
		columns = b;
		strings = a;
		matrix = new int*[a];

		for (int i = 0; i < a; i++)
		{
			matrix[i] = new int[b]{0};
		}
	};

	void Matrix :: input(string filen)
	{
		ifstream file;
		file.open(filen);
		

		matrix[i] = new *int [strings];
		for (int i = 0; i < strings; i++)
		{
			matrix[i] = new *int [columns];
			for (int j = 0; j < columns; j++)
			{
				file >> matrix[i][j];
			}
		}
		file.close();
	};

	void Matrix :: set(int x, int y, int z)
	{
		matrix[x][y] = z;
	};

	int Matrix :: get(int x, int y) const
	{
		return matrix[x][y];
	};

	Matrix Matrix:: operator+ (Matrix a) const
	{
		Matrix c(strings, columns);


		for (int i = 0; i < strings; i++)
		{
			for (int j = 0; j < columns; j++)
			{
				c.set(i, j, a.get(i, j) + get(i, j));
			}
		}
		return c;
	};

	Matrix Matrix :: operator* (Matrix a) const
	{
		Matrix c(strings, a.columns);

		for (int i = 0; i < strings; i++)
		{
			for (int j = 0; j < a.columns; j++)
			{
				int temp = 0;
				for (int k = 0; k < strings; k++)
				{
					temp += get(i, k) * a.get(k, j);
				}
				c.set(i, j, temp);
			}
		}

		return c;
	};

	Matrix& Matrix :: operator= (Matrix &other) 
	{
		if (this != &other)
		{
			for (int i = 0; i < strings; i++)
			{
				delete[] matrix[i];
			}

			delete[] matrix;

			columns = other.columns;
			strings = other.strings;

			matrix = new int*[strings];

			for (int i = 0; i < strings; i++)
			{
				matrix[i] = new int[columns]{0};
			}

			matrix = other.matrix;
		}
		return *this;
	};

	bool Matrix :: operator== (Matrix &a) const
	{
		bool k = false;

		for (int i = 0; i < strings; i++){

			for (int j = 0; j < columns; j++){

				if (matrix[i][j] == a.matrix[i][j])

					k = true;

			}

		}

		return k;
	}

	istream& operator>> (istream& file, const Matrix& result)

	{

		for (int i = 0; i < result.strings; i++)

			for (int j = 0; j < result.columns; j++)

				file >> result.matrix[i][j];

		return file;

	}

	 ostream& operator<< (ostream& os, const Matrix& a)
	{
		for (int i = 0; i < a.strings; i++)
		{
			for (int j = 0; j < a.columns; j++)
			{
				os << a.matrix[i][j] << " ";
			}
			os << endl;
		}
		os << endl;
		return os;
	}


	Matrix :: ~Matrix()
	{
		/*for (int i = 0; i < strings; i++)
		{
			delete[] matrix[i];
		}

		delete[] matrix;*/
	};


<commit_msg>Update matrix.cpp<commit_after>#include "matrix.hpp"

int Matrix::Columns_() const
{
	return Columns;
}

int Matrix::Strings_() const
{
	return Strings;
}

Matrix::Matrix()
{
	Columns = 0;
	Strings = 0;
	matrix = new int*[Strings];
	for (int i = 0; i < Strings; i++)
	{
		matrix[i] = new int[Columns];
	}
}

Matrix::Matrix(int _Columns, int _Strings)
{
	Columns = _Columns;
	Strings = _Strings;
	matrix = new int*[Strings];
	for (int i = 0; i < Strings; ++i)
	{
		matrix[i] = new int[Columns];
		for (int j = 0; j < Columns; ++j)
		{
			matrix[i][j] = 0;
		}
	}
}

Matrix::Matrix(const Matrix& res)
{
	Columns = res.Columns;
	Strings = res.Strings;
	matrix = new int*[Strings];
	
	for (int i = 0; i < Strings; ++i)
	{
		matrix[i] = new int[Columns];
		for (int j = 0; j < Columns; ++j)
		{
			matrix[i][j] = res.matrix[i][j];
		}
	}
}

Matrix::~Matrix()
{
	for (int i = 0; i < Strings; ++i)
	{
		delete[]matrix[i];
	}
	delete[]matrix;
}

istream& operator >> (istream& infile, const Matrix& res) const
{
	for (int i = 0; i < res.Strings; i++)
	for (int j = 0; j < res.Columns; j++)
		infile >> res.matrix[i][j];
	return infile;
}

void Matrix::search(string filen) const
{
	ifstream file;
	file.open(filen);
	if (!file.is_open())
		cout << "Error! Try again!" << endl;
	else
	{
		matrix = new int*[Strings];
		for (int i = 0; i < Strings; i++)
		{
			matrix[i] = new int[Columns];
			for (int j = 0; j < Columns; j++)
			{
				file >> matrix[i][j];
			}
		}
	}
	file.close();
}

ostream& operator << (ostream& outfile, const Matrix& resu)
{
	for (int i = 0; i < res.Strings; i++)
	{
		for (int j = 0; j < resu.Columns; j++)
		{
			outfile << res.matrix[i][j] << " ";
		}
	}
	outfile << endl;
	return outfile;
}

bool Matrix::operator == (const Matrix& m2) const
{
	bool k = false;
	for (int i = 0; i < Strings; i++)
	{
		for (int j = 0; j < Columns; j++)
		{
			if (matrix[i][j] == m2.matrix[i][j])
				k = true;
		}
	}
	return k;
}

Matrix Matrix::operator + (const Matrix& m2) const
{
	if ((Columns != m2.Columns) || (Strings != m2.Strings)) 
	{
		cout << "Error!";
	}
	else 
	{
		Matrix result(Columns, Strings);
		for (int i = 0; i < Strings; ++i)
		{
			for (int j = 0; j < Columns; ++j)
			{
				result.matrix[i][j] = matrix[i][j] + m2.matrix[i][j];
			}
		}
		return result;
	}
}

Matrix Matrix::operator * (const Matrix& m2) const
{
	if (m2.Strings != Columns)
	{
		cout << "Error!";
	}
	else 
	{
		Matrix res(Strings, m2.Columns);
		
		for (int i = 0; i < Strings; i++)
		{
			for (int j = 0; j < m2.Columns; j++)
			{
				for (int k = 0; k < Columns; k++)
				{
					res.matrix[i][j] += matrix[i][k] * m2.matrix[k][j];
				}
			}
		}
		return result;
	}
}

Matrix& Matrix::operator = (const Matrix& res)
{
	if (&result != this)
	{
		for (int i = 0; i < Strings; i++)
		{
			delete[] matrix[i];
		}
		delete[] matrix;
	}
	Strings = res.Strings;
	Columns = res.Columns;
	
	matrix = new int*[Strings];
	
	for (int i = 0; i < Strings; i++)
	{
		matrix[i] = new int[Columns];
		for (int j = 0; j < Columns; j++)
		{
			matrix[i][j] = res.matrix[i][j];
		}
	}
	return *this;


{'fraction_non_alphanumeric': 0.20043851635300566, 'fraction_numerical': 0.010232048236798831, 'mean_word_length': 2.545336787564767, 'pattern_counts': {'":': 0, '<': 69, '<?xml version=': 0, '>': 16, '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': '1830707', 'n_tokens_mistral': 2624, 'n_tokens_neox': 2282, 'n_words': 633}