From: popo Date: Sun, 10 Apr 2011 14:57:03 +0000 (+0000) Subject: Remove mxIsSparse(prhs[1]) in do_predict(...) in matlab/predict.c. Sparse format... X-Git-Tag: v190~20 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=544400bb16d868ecc9c4bae53c893a9521317e26;p=liblinear Remove mxIsSparse(prhs[1]) in do_predict(...) in matlab/predict.c. Sparse format is checked in mexFunction(...). --- diff --git a/matlab/predict.c b/matlab/predict.c index 66c03be..2704d36 100644 --- a/matlab/predict.c +++ b/matlab/predict.c @@ -102,26 +102,19 @@ void do_predict(mxArray *plhs[], const mxArray *prhs[], struct model *model_, co ptr_label = mxGetPr(prhs[0]); // transpose instance matrix - if(mxIsSparse(prhs[1])) + if(col_format_flag) + pplhs[0] = (mxArray *)prhs[1]; + else { - if(col_format_flag) - { - pplhs[0] = (mxArray *)prhs[1]; - } - else + mxArray *pprhs[1]; + pprhs[0] = mxDuplicateArray(prhs[1]); + if(mexCallMATLAB(1, pplhs, 1, pprhs, "transpose")) { - mxArray *pprhs[1]; - pprhs[0] = mxDuplicateArray(prhs[1]); - if(mexCallMATLAB(1, pplhs, 1, pprhs, "transpose")) - { - mexPrintf("Error: cannot transpose testing instance matrix\n"); - fake_answer(plhs); - return; - } + mexPrintf("Error: cannot transpose testing instance matrix\n"); + fake_answer(plhs); + return; } } - else - mexPrintf("Testing_instance_matrix must be sparse\n"); prob_estimates = Malloc(double, nr_class); @@ -283,7 +276,8 @@ void mexFunction( int nlhs, mxArray *plhs[], do_predict(plhs, prhs, model_, prob_estimate_flag); else { - mexPrintf("Testing_instance_matrix must be sparse\n"); + mexPrintf("Testing_instance_matrix must be sparse; " + "use sparse(Testing_instance_matrix) first\n"); fake_answer(plhs); } diff --git a/matlab/train.c b/matlab/train.c index cad8a9a..b0b2b52 100644 --- a/matlab/train.c +++ b/matlab/train.c @@ -304,7 +304,8 @@ void mexFunction( int nlhs, mxArray *plhs[], err = read_problem_sparse(prhs[0], prhs[1]); else { - mexPrintf("Training_instance_matrix must be sparse\n"); + mexPrintf("Training_instance_matrix must be sparse; " + "use sparse(Training_instance_matrix) first\n"); destroy_param(¶m); fake_answer(plhs); return;