Go to the documentation of this file.00001
00007
00008
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_probe_or(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
00031 {
00032 int i;
00033 grpc_sessionid_t sessionId;
00034 grpc_error_t retval;
00035 int mrows, ncols;
00036 grpc_sessionid_t *sessionId_array = NULL;
00037
00038 if (nrhs != 2 || nlhs != 2) {
00039 mexErrMsgTxt("Usage: [status, sessionId] = gs_probe_or(sessionId_array)\n");
00040 for (i=0;i<nlhs;i++) plhs[i] = mxCreateDoubleMatrix(0,0,mxREAL);
00041 return;
00042 }
00043
00044
00045 matlab_gs_error_num = 0;
00046 matlab_gs_minor_errno = 256;
00047
00048
00049 retval = grpc_initialize(NULL);
00050 if ((retval != GRPC_NO_ERROR) && (retval != GRPC_ALREADY_INITIALIZED))
00051 DO_ERROR_MACRO(retval);
00052
00053
00054 mrows = (int)mxGetM(prhs[1]);
00055 ncols = (int)mxGetN(prhs[1]);
00056 sessionId_array = (int *)malloc(sizeof(grpc_sessionid_t)*mrows*ncols);
00057 for (i=0; i<mrows*ncols; i++)
00058 sessionId_array[i] = (int)mxGetPr(prhs[1])[i];
00059
00060
00061 retval = grpc_probe_or(sessionId_array, mrows*ncols, &sessionId);
00062
00063
00064 if (sessionId_array) free(sessionId_array);
00065
00066
00067 if ((retval != GRPC_NO_ERROR) & (retval != GRPC_NONE_COMPLETED))
00068 DO_ERROR_MACRO(retval);
00069
00070
00071 plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL);
00072 plhs[1] = mxCreateDoubleMatrix(1,1,mxREAL);
00073 mxGetPr(plhs[0])[0] = (double)retval;
00074 mxGetPr(plhs[1])[0] = (double)sessionId;
00075
00076 return;
00077
00078
00079 error:
00080 plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL);
00081 plhs[1] = mxCreateDoubleMatrix(1,1,mxREAL);
00082 mxGetPr(plhs[0])[0] = (double)-1;
00083 mxGetPr(plhs[1])[0] = (double)-1;
00084 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));
00085 return;
00086
00087 }