matlab_gs_get_last_error.c

Go to the documentation of this file.
00001 
00007 /* $Id: matlab_gs_get_last_error.c,v 1.5 2006/05/09 20:19:44 yarkhan Exp $ */
00008 /* $UTK_Copyright: $ */
00009 
00010 #include <stdio.h>
00011 #include <string.h>
00012 
00013 #include <matrix.h>
00014 #include <mex.h>
00015 
00016 #include "grpc.h"
00017 #include "matlab_gs.h"
00018 
00019 
00029 void 
00030 matlab_gs_get_last_error(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
00031 {
00032   int i;
00033 
00034   if ((nlhs != 1)||(nrhs != 1)) {
00035     mexErrMsgTxt("Usage: num = gridsolve_errno\n");
00036     goto error;
00037   }
00038 
00039   plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL);
00040 
00041   /* Use Matlab global error number */
00042   mxGetPr(plhs[0])[0] = (double)matlab_gs_error_num;
00043 
00044   return; 
00045 
00046  error:
00047   for (i=0;i<nlhs;i++) plhs[i] = mxCreateDoubleMatrix(0,0,mxREAL); 
00048   mexPrintf("Warning: GridSolve call failed: %d:%d: %s; %s\n", grpc_errno, grpc_minor_errno, grpc_error_string(grpc_errno), grpc_minor_error_string(grpc_minor_errno));  
00049   return;
00050 
00051 }