#pragma once
#include <cmath>
#include <vector>
#include <numeric>

namespace arith {

float sqrt(float x);
float mean(const std::vector<int>& x);

template<typename T>
void mm(const std::vector<T>& a, const std::vector<T>& b, std::vector<T>& c, size_t m, size_t k, size_t n) {
    // 补全这里，谢谢
    c.resize(m * n);

    std::fill(c.begin(), c.end(), static_cast<T>(0));

    for (size_t i = 0; i < m; ++i) {
        for (size_t j = 0; j < n; ++j) {
            for (size_t p = 0; p < k; ++p) {
                c[i * n + j] += a[i * k + p] * b[p * n + j];
            }
        }
    }
}

template<typename T>
void vector_scalar_max(const std::vector<T>& a, std::vector<T> &b, T scalar) {
    // 补全这里，谢谢
    b.resize(a.size());

    for (size_t i = 0; i < a.size(); ++i) {
        b[i] = (a[i] > scalar) ? a[i] : scalar;
    }
}
}