<commit_before>#include "matrix_ops.hpp"
#include <vector>
#include <iostream>

// Code copied and adapted (int to float mainly) from:
// https://www.geeksforgeeks.org/c-program-multiply-two-matrices/
// https://www.geeksforgeeks.org/adjoint-inverse-matrix/


// This function multiplies
// firstMatrix and secondMatrix, and
// stores the result in res=

std::vector<std::vector<float>> mat_mul(std::vector<std::vector<float>>& firstMatrix, 
                                        std::vector<std::vector<float>>& secondMatrix)
{
    std::vector<std::vector<float>> res;

    if(firstMatrix[0].size() != secondMatrix.size()){
        std::cerr << "Number of column of the first matrix should match with the number of rows of the second matrix " << std::endl;
        abort();
    }
        
	// Initializing elements of matrix mult to 0.
	for(int i = 0; i < firstMatrix.size(); ++i)
	{   std::vector<float> col_vec(secondMatrix[0].size(), 0);
        res.push_back(col_vec);
	}

	// Multiplying matrix firstMatrix and secondMatrix and storing in array mult.
	for(int i = 0; i < firstMatrix.size(); ++i)
	{
		for(int j = 0; j < secondMatrix[0].size(); ++j)
		{
			for(int k=0; k<firstMatrix[0].size(); ++k)<commit_msg>Do not crash when mat_mul fails, return an empty vector instead. Fixes a host app crash when the device calib data is full-zero. Was reproducible by writing to EEPROM a calib file generated by:     dd if=/dev/zero of=resources/depthai.calib bs=1 count=445<commit_after>#include "matrix_ops.hpp"
#include <vector>
#include <iostream>

// Code copied and adapted (int to float mainly) from:
// https://www.geeksforgeeks.org/c-program-multiply-two-matrices/
// https://www.geeksforgeeks.org/adjoint-inverse-matrix/


// This function multiplies
// firstMatrix and secondMatrix, and
// stores the result in res=

std::vector<std::vector<float>> mat_mul(std::vector<std::vector<float>>& firstMatrix, 
                                        std::vector<std::vector<float>>& secondMatrix)
{
    std::vector<std::vector<float>> res;

    if(firstMatrix[0].size() != secondMatrix.size()){
        std::cerr << "Number of column of the first matrix should match with the number of rows of the second matrix " << std::endl;
        // Return an empty vector
        return res;
    }
        
	// Initializing elements of matrix mult to 0.
	for(int i = 0; i < firstMatrix.size(); ++i)
	{   std::vector<float> col_vec(secondMatrix[0].size(), 0);
        res.push_back(col_vec);
	}

	// Multiplying matrix firstMatrix and secondMatrix and storing in array mult.
	for(int i = 0; i < firstMatrix.size(); ++i)
	{
		for(int j = 0; j < secondMatrix[0].size(); ++j)
		{
			for(int k=0; k<firstMatrix[0].size(); ++k)
{'fraction_non_alphanumeric': 0.14622467771639042, 'fraction_numerical': 0.008839779005524863, 'mean_word_length': 3.3665594855305465, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 25, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4849090', 'n_tokens_mistral': 896, 'n_tokens_neox': 849, 'n_words': 246}