#include #include #include #include "mex.h" #ifdef MX_API_VER #if MX_API_VER < 0x07030000 typedef int mwIndex; #endif #endif void exit_with_help() { mexPrintf( "Usage: libsvmwrite('filename', label_vector, instance_matrix);\n" ); } static void fake_answer(int nlhs, mxArray *plhs[]) { int i; for(i=0;i 0) { exit_with_help(); fake_answer(nlhs, plhs); return; } // Transform the input Matrix to libsvm format if(nrhs == 3) { char filename[256]; if(!mxIsDouble(prhs[1]) || !mxIsDouble(prhs[2])) { mexPrintf("Error: label vector and instance matrix must be double\n"); return; } mxGetString(prhs[0], filename, mxGetN(prhs[0])+1); if(mxIsSparse(prhs[2])) libsvmwrite(filename, prhs[1], prhs[2]); else { mexPrintf("Instance_matrix must be sparse\n"); return; } } else { exit_with_help(); return; } }