#include "bench_funcs_blas.h"
#include <cblas.h>

double dot_cblas(const std::vector<double>& x, const std::vector<double>& y) {
    return cblas_ddot((int)x.size(), x.data(), 1, y.data(), 1);
}

void matvec_cblas(const std::vector<double>& A, std::size_t M, std::size_t N,
                  const std::vector<double>& x, std::vector<double>& b) {
    b.resize(M);
    cblas_dgemv(CblasRowMajor, CblasNoTrans,
                (int)M, (int)N,
                1.0, A.data(), (int)N,
                x.data(), 1,
                0.0, b.data(), 1);
}

void matmul_cblas(const std::vector<double>& A, std::size_t M, std::size_t L,
                  const std::vector<double>& B, std::size_t N,
                  std::vector<double>& C) {
    C.resize(M * N);
    cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans,
                (int)M, (int)N, (int)L,
                1.0, A.data(), (int)L,
                B.data(), (int)N,
                0.0, C.data(), (int)N);
}
