Jump to content
Excelsior Forums
Sign in to follow this  
jinyt

xFunction support Matlab generated c?

Recommended Posts

Hi,

We're interesed in xFunction and would like to clarify some questions before purchasing. Currently We have a java application and would like to use the matlab functionality in the java application. We'd like to know whether xFunction could convert matlab compiler generated c program to the JNI wrapper code. Following is an example of the matlab compiler generated c program. Or xFunction could deal with .dll file generated by Matlab? Your help is greatly appreciated.

/*

* MATLAB Compiler: 3.0

* Date: Thu Feb 03 13:08:17 2005

* Arguments: "-B" "macro_default" "-O" "all" "-O" "fold_scalar_mxarrays:on"

* "-O" "fold_non_scalar_mxarrays:on" "-O" "optimize_integer_for_loops:on" "-O"

* "array_indexing:on" "-O" "optimize_conditionals:on" "-B" "sgl" "-m" "-W"

* "main" "-L" "C" "-t" "-T" "link:exe" "-h" "libmmfile.mlib" "-W" "mainhg"

* "libmwsglm.mlib" "-t" "-W" "lib:liba" "-T" "link:lib" "testm"

*/

#include "testm.h"

#include "libmatlbm.h"

#include "spaps.h"

void InitializeModule_testm(void) {

}

void TerminateModule_testm(void) {

}

static mxArray * Mtestm(int nargout_, mxArray * x, mxArray * y, mxArray * t);

_mexLocalFunctionTable _local_function_table_testm

= { 0, (mexFunctionTableEntry *)NULL };

/*

* The function "mlfTestm" contains the normal interface for the "testm"

* M-function from file "c:\matlab6p5p2\work\testlib\testm.m" (lines 1-2). This

* function processes any input arguments and passes them to the implementation

* version of the function, appearing above.

*/

mxArray * mlfTestm(mxArray * x, mxArray * y, mxArray * t) {

int nargout = 1;

mxArray * p = NULL;

mlfEnterNewContext(0, 3, x, y, t);

p = Mtestm(nargout, x, y, t);

mlfRestorePreviousContext(0, 3, x, y, t);

return mlfReturnValue(p);

}

/*

* The function "mlxTestm" contains the feval interface for the "testm"

* M-function from file "c:\matlab6p5p2\work\testlib\testm.m" (lines 1-2). The

* feval function calls the implementation version of testm through this

* function. This function processes any input arguments and passes them to the

* implementation version of the function, appearing above.

*/

void mlxTestm(int nlhs, mxArray * plhs[], int nrhs, mxArray * prhs[]) {

mxArray * mprhs[3];

mxArray * mplhs[1];

int i;

if (nlhs > 1) {

mlfError(

mxCreateString(

"Run-time Error: File: testm Line: 1 Column: 1 The function \"testm"

"\" was called with more than the declared number of outputs (1)."),

NULL);

}

if (nrhs > 3) {

mlfError(

mxCreateString(

"Run-time Error: File: testm Line: 1 Column: 1 The function \"testm"

"\" was called with more than the declared number of inputs (3)."),

NULL);

}

for (i = 0; i < 1; ++i) {

mplhs = NULL;

}

for (i = 0; i < 3 && i < nrhs; ++i) {

mprhs = prhs;

}

for (; i < 3; ++i) {

mprhs = NULL;

}

mlfEnterNewContext(0, 3, mprhs[0], mprhs[1], mprhs[2]);

mplhs[0] = Mtestm(nlhs, mprhs[0], mprhs[1], mprhs[2]);

mlfRestorePreviousContext(0, 3, mprhs[0], mprhs[1], mprhs[2]);

plhs[0] = mplhs[0];

}

/*

* The function "Mtestm" is the implementation version of the "testm"

* M-function from file "c:\matlab6p5p2\work\testlib\testm.m" (lines 1-2). It

* contains the actual compiled code for that M-function. It is a static

* function and must only be called from one of the interface functions,

* appearing below.

*/

/*

* function p = testm(x,y,t)

*/

static mxArray * Mtestm(int nargout_, mxArray * x, mxArray * y, mxArray * t) {

mexLocalFunctionTable save_local_function_table_

= mclSetCurrentLocalFunctionTable(&_local_function_table_testm);

mxArray * p = NULL;

mclCopyArray(&x);

mclCopyArray(&y);

mclCopyArray(&t);

/*

* p = spaps(x,y,t);

*/

mlfAssign(

&p,

mlfNSpaps(

1, NULL, NULL, mclVa(x, "x"), mclVa(y, "y"), mclVa(t, "t"), NULL));

mclValidateOutput(p, 1, nargout_, "p", "testm");

mxDestroyArray(t);

mxDestroyArray(y);

mxDestroyArray(x);

mclSetCurrentLocalFunctionTable(save_local_function_table_);

return p;

}

thanks,

:huh:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×