Created
May 22, 2013 01:03
-
-
Save yansyaf/5624514 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "mex.h" | |
#include <string.h> | |
void mexAdder( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ); | |
void mexMult( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ); | |
void mexFunction( int nlhs, mxArray *plhs[], | |
int nrhs, const mxArray *prhs[] ) | |
{ | |
char *functionName; | |
int functionNameLen; | |
/* Get the length of the function name string. */ | |
functionNameLen = (mxGetM(prhs[0]) * mxGetN(prhs[0])) + 1; | |
/* Allocate memory for input strings. */ | |
functionName = (char *) mxCalloc(functionNameLen, sizeof(char)); | |
/* Copy the string to functionName. */ | |
functionName = mxArrayToString(prhs[0]); | |
if ( !strcmp(functionName,"adder") ) { | |
mexAdder(nlhs, plhs, nrhs-1, &(prhs[1])); | |
} else if ( !strcmp(functionName,"mult") ) { | |
mexMult(nlhs, plhs, nrhs-1, &(prhs[1])); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment