#include <opencv2/core/core.hpp>
#include <iostream>
#include <cblas.h>
#include <cstdlib>
using namespace std;
using namespace cv;
int main(int argc, char* argv[]) {
clock_t start_time;
RNG &rng = theRNG();
float alpha = 1.f, gamma = 0;
float time_openblas;
int m = 1000000, p = 600, n = 1;
Mat_<float> A(m, p, CV_32F), B(p, n, CV_32F);
Mat C = Mat(m, n, CV_32F, 0.0);
rng.fill(A, RNG::NORMAL, 1, 100);
rng.fill(B, RNG::NORMAL, 2, 50);
float *src1, *src2, *src3;
src1 = (float *) A.data;
src2 = (float *) B.data;
src3 = (float *) C.data;
start_time = clock();
cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, m, n, p,
alpha, src1, p, src2, n, beta, src3, n);
float duration = (clock() - start_time) / (CLOCKS_PER_SEC / 1000.0);
cout << "cblas_sgemm: " << duration << " ms" << endl;
start_time = clock();
cblas_sgemv(CblasRowMajor, CblasNoTrans, m, p, alpha, src1, p, src2, 1, beta, src3, 1);
duration = (clock() - start_time) / (CLOCKS_PER_SEC / 1000.0);
cout << "cblas_sgemv: " << duration << " ms" << endl;
return 0;
}