92 lines
2.9 KiB
C++
92 lines
2.9 KiB
C++
#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)
|
|
{
|
|
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 = 1, nrhs = 3;
|
|
pwdMat = matOpen("D:\\tmp\\ws_small.mat", "r");
|
|
pdicMat = matOpen("D:\\tmp\\x_small.mat", "r");
|
|
prhs[0] = matGetVariable(pwdMat, "ws"); //获取.mat文件里面名为matrixName的矩阵
|
|
prhs[1] = matGetVariable(pdicMat, "x");
|
|
prhs[2] = mxCreateDoubleMatrix(1, 1, mxREAL);
|
|
*mxGetPr(prhs[2]) = 2;
|
|
|
|
/* 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;
|
|
|
|
|
|
|
|
|
|
// 调用函数进行测试
|
|
finish = clock();
|
|
cout << "Load Data time: " << (double)(finish - begin) / CLOCKS_PER_SEC << " s" << endl;
|
|
|
|
mexFunctionWrap(nlhs, &plhs[0], nrhs, &prhs[0]);
|
|
|
|
finish = clock();
|
|
cout << "mexFunction Total time: " << (double)(finish - begin) / CLOCKS_PER_SEC << " s" << endl;
|
|
|
|
return 0;
|
|
}
|