#include #include #include #include "mex_func.h" #include "CommonLib/matlab_io.h" using namespace std; int main(int argc, const char** argv) { //string matFile = "D:\\x_large.mat"; //string matFile = "D:\\x.mat"; //string matFile = "D:\\Twirls\\wd_small.mat"; //string matFile = "D:\\Twirls\\wd.mat"; clock_t begin = clock(), finish; //string wd2Mat = "D:\\wd2_5w.mat"; //string dicrMat = "D:\\dicr.mat"; //string wdMat = "D:\\wd.mat"; //string dicMat = "D:\\G_dc_large.mat"; //string wdMat = "D:\\wd_large.mat"; //MATFile* pwdMat, *pwd2Mat, *pdicMat; //mxArray* prhs[4]; //pwdMat = matOpen(wdMat.c_str(), "r"); // pwd2Mat = matOpen(wd2Mat.c_str(), "r"); //pdicMat = matOpen(dicMat.c_str(), "r"); // prhs[1] = mxCreateString("D:\\Twirls\\gat1\\literatures\\temp\\wd2s.txt"); // prhs[2] = matGetVariable(pdicrMat, "dicr"); /* IsWordInDic */ // MATFile* pwdMat, * pdicMat; // mxArray* plhs[4]; // const mxArray* prhs[4]; // int nlhs = 2, nrhs = 2; // pwdMat = matOpen("D:\\wd_large.mat", "r"); // pdicMat = matOpen("D:\\G_dc_large.mat", "r"); // prhs[0] = matGetVariable(pwdMat, "wd"); //获取.mat文件里面名为matrixName的矩阵 // prhs[1] = matGetVariable(pdicMat, "dc"); /* ClusterRandSim */ // mxArray* plhs[4]; // const mxArray* prhs[4]; // int nlhs = 2, nrhs = 4; // MATFile* pMatX = matOpen("D:\\x_large.mat", "r"); // MATFile* pMatH = matOpen("D:\\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 */ // mxArray* plhs[4]; // const mxArray* prhs[4]; // int nlhs = 2, nrhs = 4; // MATFile* pMatX = matOpen("D:\\x_large.mat", "r"); // MATFile* pMatIx = matOpen("D:\\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 */ mxArray* plhs[4]; const mxArray* prhs[4]; int nlhs = 2, nrhs = 4; MATFile* pMatG = matOpen("D:\\G_large.mat", "r"); MATFile* pMatWs = matOpen("D:\\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; }