twirls/MexFunc/main.cpp

61 lines
1.7 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
//string matFile = "D:\\x_large.mat";
2023-10-05 10:38:21 +08:00
//string matFile = "D:\\x.mat";
2023-10-07 04:21:54 +08:00
//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";
2023-10-05 10:38:21 +08:00
//string dicMat = "D:\\G_dc_large.mat";
2023-10-07 04:21:54 +08:00
//string wdMat = "D:\\wd_large.mat";
//MATFile* pwdMat, *pwd2Mat, *pdicMat;
//mxArray* prhs[4];
2023-10-07 04:21:54 +08:00
//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");
2023-10-07 04:21:54 +08:00
/* */
//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, "h");
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;
}