twirls/MexFunc/main.cpp

90 lines
2.8 KiB
C++
Raw Normal View History

2023-10-05 10:38:21 +08:00
#include <iostream>
#include <string>
#include <vector>
#include "mex_func.h"
#include "CommonLib/matlab_io.h"
using namespace std;
int main(int argc, const char** argv)
{
2023-10-07 04:21:54 +08:00
clock_t begin = clock(), finish;
const int argReserveNum = 10;
mxArray* plhs[argReserveNum];
const mxArray* prhs[argReserveNum];
/* SortDedup */
int nlhs = 1, nrhs = 2;
MATFile* pwdMat = matOpen("D:\\tmp\\wd_small.mat", "r");
prhs[0] = matGetVariable(pwdMat, "wd");
prhs[1] = mxCreateString("D:\\Twirls\\runtime\\output_1.dat");
prhs[2] = mxCreateDoubleMatrix(1, 1, mxREAL);
*mxGetPr(prhs[2]) = 2;
/* CalcEntropy */
// int nlhs = 2, nrhs = 4;
// MATFile* pMatAbs = matOpen("D:\\tmp\\abs_189.mat", "r");
// MATFile* pMatG = matOpen("D:\\tmp\\G_189.mat", "r");
// prhs[0] = matGetVariable(pMatAbs, "abs");
// prhs[1] = matGetVariable(pMatG, "G");
// prhs[2] = mxCreateDoubleMatrix(1, 1, mxREAL);
// *mxGetPr(prhs[2]) = 12;
// prhs[3] = mxCreateDoubleMatrix(1, 1, mxREAL);
// *mxGetPr(prhs[3]) = 2;
/* IsWordInDic */
// MATFile* pwdMat, * pdicMat;
// int nlhs = 2, nrhs = 2;
// pwdMat = matOpen("D:\\tmp\\wd_large.mat", "r");
// pdicMat = matOpen("D:\\tmp\\G_dc_large.mat", "r");
// prhs[0] = matGetVariable(pwdMat, "wd"); //获取.mat文件里面名为matrixName的矩阵
// prhs[1] = matGetVariable(pdicMat, "dc");
/* ClusterRandSim */
// int nlhs = 2, nrhs = 4;
// MATFile* pMatX = matOpen("D:\\tmp\\x_large.mat", "r");
// MATFile* pMatH = matOpen("D:\\tmp\\h_large.mat", "r");
// prhs[0] = matGetVariable(pMatX, "x");
// prhs[1] = matGetVariable(pMatH, "h3");
// prhs[2] = mxCreateDoubleMatrix(1, 1, mxREAL);
// *mxGetPr(prhs[2]) = 1;
// prhs[3] = mxCreateDoubleMatrix(1, 1, mxREAL);
// *mxGetPr(prhs[3]) = 10000;
/* AllClusterRandSim */
// int nlhs = 2, nrhs = 4;
// MATFile* pMatX = matOpen("D:\\tmp\\x_large.mat", "r");
// MATFile* pMatIx = matOpen("D:\\tmp\\ix_large.mat", "r");
// prhs[0] = matGetVariable(pMatX, "x");
// prhs[1] = matGetVariable(pMatIx, "ix");
// prhs[2] = mxCreateDoubleMatrix(1, 1, mxREAL);
// *mxGetPr(prhs[2]) = 4;
// prhs[3] = mxCreateDoubleMatrix(1, 1, mxREAL);
// *mxGetPr(prhs[3]) = 10000;
/* AllEntropyMean */
// int nlhs = 2, nrhs = 4;
// MATFile* pMatG = matOpen("D:\\tmp\\G_large.mat", "r");
// MATFile* pMatWs = matOpen("D:\\tmp\\ws_large.mat", "r");
// mxArray* pMxG = matGetVariable(pMatG, "G");
// prhs[0] = mxGetField(pMxG, 0, "ds");
// prhs[1] = mxGetField(pMxG, 0, "frr");
// prhs[2] = matGetVariable(pMatWs, "ws");
// prhs[3] = mxCreateDoubleMatrix(1, 1, mxREAL);
// *mxGetPr(prhs[3]) = 12;
2023-10-07 04:21:54 +08:00
2023-10-05 10:38:21 +08:00
// 调用函数进行测试
finish = clock();
cout << "Load Data time: " << (double)(finish - begin) / CLOCKS_PER_SEC << " s" << endl;
2023-10-05 10:38:21 +08:00
mexFunctionWrap(nlhs, &plhs[0], nrhs, &prhs[0]);
2023-10-05 10:38:21 +08:00
2023-10-07 04:21:54 +08:00
finish = clock();
cout << "mexFunction Total time: " << (double)(finish - begin) / CLOCKS_PER_SEC << " s" << endl;
2023-10-05 10:38:21 +08:00
return 0;
}