<commit_before>#ifndef _LINALG_HPP_
#define _LINALG_HPP_

#include <assert.h>
#include <math.h>

#include <iostream>

extern "C" {
    void dgemm_(char *transa, char *transb, int *m, int *n, int *k,
                double *alpha, double *a, int *lda, double *b, int *ldb,
                double *beta, double *c, int *ldc);
    void sgemm_(char *transa, char *transb, int *m, int *n, int *k,
                float *alpha, float *a, int *lda, float *b, int *ldb,
                float *beta, float *c, int *ldc);
}

// This is a basic templated matrix class.
// It stores the matrix data, the stride, and the dimensions.
// The variable is_view indicates whether or not the data is owned
// by this instance.
template <typename Scalar>
class Matrix {
public:
    // Copy constructor
    Matrix(Matrix<Scalar>& that) {
	m_ = that.m();
	n_ = that.n();
	stride_ = that.stride();
	allocate();
	Scalar *that_data = that.data();
	for (int i = 0; i < m_ * n_; ++i) {
	    data_[i] = that_data[i];
	}
    }

    Matrix() : m_(0), n_(0), stride_(0), data_(NULL), is_view_(false) {}

    // copy assignment
    Matrix<Scalar>& operator=(Matrix<Scalar> that) {
	swap(*this, that);
	return *this;
    }

    friend void swap(Matrix<Scalar>& first, Matrix<Scalar>& second) {
	std::swap(first.m_, second.m_);
	std::swap(first.n_, second.n_);
	std::swap(first.stride_, second.stride_);
	std::swap(first.is_view_, second.is_view_);
	std::swap(first.data_, second.data_);
    }

    Matrix(Scalar *data, int stride, int m, int n):
        data_(data), stride_(stride), m_(m), n_(n), is_view_(true) {}

    Matrix(int n) : m_(n), n_(n), stride_(n), is_view_(false) {
        allocate();
    }
<commit_msg>fix copy assignment operator<commit_after>#ifndef _LINALG_HPP_
#define _LINALG_HPP_

#include <assert.h>
#include <math.h>

#include <iostream>

extern "C" {
    void dgemm_(char *transa, char *transb, int *m, int *n, int *k,
                double *alpha, double *a, int *lda, double *b, int *ldb,
                double *beta, double *c, int *ldc);
    void sgemm_(char *transa, char *transb, int *m, int *n, int *k,
                float *alpha, float *a, int *lda, float *b, int *ldb,
                float *beta, float *c, int *ldc);
}

// This is a basic templated matrix class.
// It stores the matrix data, the stride, and the dimensions.
// The variable is_view indicates whether or not the data is owned
// by this instance.
template <typename Scalar>
class Matrix {
public:
    // Copy constructor
    Matrix(Matrix<Scalar>& that) {
	m_ = that.m();
	n_ = that.n();
	stride_ = that.stride();
	allocate();
	Scalar *that_data = that.data();
	for (int i = 0; i < m_ * n_; ++i) {
	    data_[i] = that_data[i];
	}
    }

    Matrix() : m_(0), n_(0), stride_(0), data_(NULL), is_view_(false) {}

    // copy assignment
    Matrix<Scalar>& operator=(Matrix<Scalar> that) {
	Matrix<Scalar> temp(that);
	swap(*this, temp);
	return *this;
    }

    friend void swap(Matrix<Scalar>& first, Matrix<Scalar>& second) {
	std::swap(first.m_, second.m_);
	std::swap(first.n_, second.n_);
	std::swap(first.stride_, second.stride_);
	std::swap(first.is_view_, second.is_view_);
	std::swap(first.data_, second.data_);
    }

    Matrix(Scalar *data, int stride, int m, int n):
        data_(data), stride_(stride), m_(m), n_(n), is_view_(true) {}

    Matrix(int n) : m_(n), n_(n), stride_(n), is_view_(false) {
        allocate();
    }

{'fraction_non_alphanumeric': 0.16193265007320645, 'fraction_numerical': 0.002342606149341142, 'mean_word_length': 3.191411042944785, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 22, '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': '3245003', 'n_tokens_mistral': 1234, 'n_tokens_neox': 1205, 'n_words': 361}