<commit_before>#ifndef _YS_MATRIX_TOOL_H_
#define _YS_MATRIX_TOOL_H_

#include "ys_matrix.h"

namespace ys {      // namespace for yue sivan

template <typename T> class Matrixs {
public:
    static DMatrix<T>* add(const DMatrix<T>& A, const DMatrix<T>& B);
    static DMatrix<T>* mul(const DMatrix<T>& A, const DMatrix<T>& B);
    static DMatrix<T>* sub(const DMatrix<T>& A, const DMatrix<T>& B);
    static T mulLine(const DMatrix<T>& A, const DMatrix<T>& B, int r, int c);
};

/*
 *Summary: sum matrix A and matrix B
 *
 *Parameters:
 *
 *   const Matrix<T>& A : matrix A    
 *
 *   const Matrix<T>& B : matrix B
 *
 *Return : The pointer of the result matrix, a new object is allocated in 
 *
 *      this function, it must be release by caller!!!!!
 *
 */
template <typename T>
static DMatrix<T>* Matrixs<T>::add(const DMatrix<T>& A, const DMatrix<T>& B) {
    if (A.getDimX() != B.getDimX() || A.getDimY() != B.getDimY()) {
        return 0;
    }
    int dimX = A.getDimX();
    int dimY = A.getDimY();
    DMatrix<T>* result = new DMatrix<T>(dimX, dimY);
    for (int i = 0; i < dimX; ++i) {
    for (int j = 0; j < dimY; ++j) {
        (*result)[i][j] = A[i][j] + B[i][j];
    }
    }
    return result;
}

/*
 *Summary: multiply matrix A and matrix B
 *
 *Parameters:
 *
 *   const Matrix<T>& A : matrix A    
 *
 *   const Matrix<T>& B : matrix B
 *
 *Return : The pointer of the result matrix, a new object is allocated in 

 *      this function, it must be release by caller!!!!!
 */
template <typename T>
static DMatrix<T>* Matrixs<T>::mul(const DMatrix<T>& A, const DMatrix<T>& B) {
    if (A.getDimY() != B.getDimX()) {
        return 0;
    }
    int dimX = A.getDimX();
    int dimY = B.getDimY();
    int dimK = A.getDimY();
    DMatrix<T>* result = new DMatrix<T>(dimX, dimY);
    for (int i = 0; i < dimX; ++i) {
    for (int j = 0; j < dimY; ++j) {
        int sum = 0;
        for (int k = 0; k < dimK; ++k) {
            sum += A[i][k] * B[k][j];
        }
        (*result)[i][j] = sum;
    }
    }
    return result;
}

/*
 *Summary: matrix A minus matrix B
 *
 *Parameters:
 *
 *   const Matrix<T>& A : matrix A    
 *
 *   const Matrix<T>& B : matrix B
 *
 *Return : The pointer of the result matrix, a new object is allocated in 

 *      this function, it must be release by caller!!!!!
 */
template <typename T>
static DMatrix<T>* Matrixs<T>::sub(const DMatrix<T>& A, const DMatrix<T>& B) {
    if (A.getDimX() != B.getDimX() || A.getDimY() != B.getDimY()) {
        return 0;
    }
    int dimX = A.getDimX();
    int dimY = A.getDimY();
    DMatrix<T>* result = new DMatrix<T>(dimX, dimY);
    for (int i = 0; i < dimX; ++i) {
    for (int j = 0; j < dimY; ++j) {
        (*result)[i][j] = A[i][j] - B[i][j];
    }
    }
    return result;
}

/*
 *Summary: matrix A minus matrix B
 *
 *Parameters:
 *
 *   const Matrix<T>& A : matrix A    
 *
 *   const Matrix<T>& B : matrix B
 *
 *Return : The pointer of the result matrix, a new object is allocated in 

 *      this function, it must be release by caller!!!!!
 */
template <typename T>
static T Matrixs<T>::mulLine(const DMatrix<T>& A, const DMatrix<T>& B, int r, int c) {
    if (A.getDimY() != B.getDimX()) {
        throw r;
    }
    int dimK = A.getDimY();
    int result = 0;
    for (int i = 0; i < dimK; ++i) {
        result += A[r][i] * B[i][c];
    }
    return result;
}

};

#endif //_YS_MATRIX_TOOL_H_<commit_msg>modify<commit_after>#ifndef _YS_MATRIX_TOOL_H_
#define _YS_MATRIX_TOOL_H_

#include "ys_matrix.h"

namespace ys {      // namespace for yue sivan

template <typename T> class Matrixs {
public:
    static DMatrix<T>* add(const DMatrix<T>& A, const DMatrix<T>& B);
    static DMatrix<T>* mul(const DMatrix<T>& A, const DMatrix<T>& B);
    static DMatrix<T>* sub(const DMatrix<T>& A, const DMatrix<T>& B);
    static T mulLine(const DMatrix<T>& A, const DMatrix<T>& B, int r, int c);
};

/*
 *Summary: sum matrix A and matrix B
 *
 *Parameters:
 *
 *   const Matrix<T>& A : matrix A    
 *
 *   const Matrix<T>& B : matrix B
 *
 *Return : The pointer of the result matrix, a new object is allocated in 
 *
 *      this function, it must be release by caller!!!!!
 *
 */
template <typename T>
inline DMatrix<T>* Matrixs<T>::add(const DMatrix<T>& A, const DMatrix<T>& B) {
    if (A.getDimX() != B.getDimX() || A.getDimY() != B.getDimY()) {
        return 0;
    }
    int dimX = A.getDimX();
    int dimY = A.getDimY();
    DMatrix<T>* result = new DMatrix<T>(dimX, dimY);
    for (int i = 0; i < dimX; ++i) {
    for (int j = 0; j < dimY; ++j) {
        (*result)[i][j] = A[i][j] + B[i][j];
    }
    }
    return result;
}

/*
 *Summary: multiply matrix A and matrix B
 *
 *Parameters:
 *
 *   const Matrix<T>& A : matrix A    
 *
 *   const Matrix<T>& B : matrix B
 *
 *Return : The pointer of the result matrix, a new object is allocated in 

 *      this function, it must be release by caller!!!!!
 */
template <typename T>
inline DMatrix<T>* Matrixs<T>::mul(const DMatrix<T>& A, const DMatrix<T>& B) {
    if (A.getDimY() != B.getDimX()) {
        return 0;
    }
    int dimX = A.getDimX();
    int dimY = B.getDimY();
    int dimK = A.getDimY();
    DMatrix<T>* result = new DMatrix<T>(dimX, dimY);
    for (int i = 0; i < dimX; ++i) {
    for (int j = 0; j < dimY; ++j) {
        int sum = 0;
        for (int k = 0; k < dimK; ++k) {
            sum += A[i][k] * B[k][j];
        }
        (*result)[i][j] = sum;
    }
    }
    return result;
}

/*
 *Summary: matrix A minus matrix B
 *
 *Parameters:
 *
 *   const Matrix<T>& A : matrix A    
 *
 *   const Matrix<T>& B : matrix B
 *
 *Return : The pointer of the result matrix, a new object is allocated in 

 *      this function, it must be release by caller!!!!!
 */
template <typename T>
inline DMatrix<T>* Matrixs<T>::sub(const DMatrix<T>& A, const DMatrix<T>& B) {
    if (A.getDimX() != B.getDimX() || A.getDimY() != B.getDimY()) {
        return 0;
    }
    int dimX = A.getDimX();
    int dimY = A.getDimY();
    DMatrix<T>* result = new DMatrix<T>(dimX, dimY);
    for (int i = 0; i < dimX; ++i) {
    for (int j = 0; j < dimY; ++j) {
        (*result)[i][j] = A[i][j] - B[i][j];
    }
    }
    return result;
}

/*
 *Summary: matrix A minus matrix B
 *
 *Parameters:
 *
 *   const Matrix<T>& A : matrix A    
 *
 *   const Matrix<T>& B : matrix B
 *
 *Return : The pointer of the result matrix, a new object is allocated in 

 *      this function, it must be release by caller!!!!!
 */
template <typename T>
inline T Matrixs<T>::mulLine(const DMatrix<T>& A, const DMatrix<T>& B, int r, int c) {
    if (A.getDimY() != B.getDimX()) {
        throw r;
    }
    int dimK = A.getDimY();
    int result = 0;
    for (int i = 0; i < dimK; ++i) {
        result += A[r][i] * B[i][c];
    }
    return result;
}

};

#endif //_YS_MATRIX_TOOL_H_
{'fraction_non_alphanumeric': 0.17054945054945056, 'fraction_numerical': 0.0038095238095238095, 'mean_word_length': 2.560772039645279, 'pattern_counts': {'":': 0, '<': 109, '<?xml version=': 0, '>': 93, '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': '1652936', 'n_tokens_mistral': 2638, 'n_tokens_neox': 2579, 'n_words': 809}