<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/258421</link>
    <title>MATLAB Central Newsreader - mex: Compile error with mxArray</title>
    <description>Feed for thread: mex: Compile error with mxArray</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Thu, 13 Aug 2009 13:40:19 -0400</pubDate>
      <title>mex: Compile error with mxArray</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/258421#672822</link>
      <author>David  Hanau</author>
      <description>Hi,&lt;br&gt;
&lt;br&gt;
Compiling C functions with Lcc in Matlab is have the following (classic) error:&lt;br&gt;
&lt;br&gt;
Error sparsesvd_partialeig_matlab.c: 86  operands of = have illegal types `pointer to incomplete struct mxArray_tag defined at C:\MATLAB6p1\extern\include\matrix.h 154' and `int' &lt;br&gt;
&lt;br&gt;
for the last line of this code: &lt;br&gt;
&lt;br&gt;
mxArray *output[3],*input[4];&lt;br&gt;
&lt;br&gt;
mexEvalString(&quot;options.disp=0;&quot;); // for use in calling Matlab function eigs	&lt;br&gt;
mexEvalString(&quot;options.maxit=500;&quot;); // for use in calling Matlab function eigs	&lt;br&gt;
input[0] = mxCreateDoubleMatrix(n,n,mxREAL); // for use in calling Matlab function eigs&lt;br&gt;
input[1] = mxCreateDoubleMatrix(1,1,mxREAL);&lt;br&gt;
input[2]= mxCreateString(&quot;la&quot;);&lt;br&gt;
input[3]= mexGetVariable(&quot;caller&quot;,&quot;options&quot;);&lt;br&gt;
&lt;br&gt;
of course I have included mex.h in the header file.&lt;br&gt;
&lt;br&gt;
Any idea?&lt;br&gt;
&lt;br&gt;
Thanks a lot,&lt;br&gt;
&lt;br&gt;
David</description>
    </item>
    <item>
      <pubDate>Thu, 13 Aug 2009 14:58:02 -0400</pubDate>
      <title>Re: mex: Compile error with mxArray</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/258421#672895</link>
      <author>James Tursa</author>
      <description>&quot;David  Hanau&quot; &amp;lt;hanaud@gmail.com.REMTHIS&amp;gt; wrote in message &amp;lt;h61543$anv$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Compiling C functions with Lcc in Matlab is have the following (classic) error:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Error sparsesvd_partialeig_matlab.c: 86  operands of = have illegal types `pointer to incomplete struct mxArray_tag defined at C:\MATLAB6p1\extern\include\matrix.h 154' and `int' &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; for the last line of this code: &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; mxArray *output[3],*input[4];&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; mexEvalString(&quot;options.disp=0;&quot;); // for use in calling Matlab function eigs	&lt;br&gt;
&amp;gt; mexEvalString(&quot;options.maxit=500;&quot;); // for use in calling Matlab function eigs	&lt;br&gt;
&amp;gt; input[0] = mxCreateDoubleMatrix(n,n,mxREAL); // for use in calling Matlab function eigs&lt;br&gt;
&amp;gt; input[1] = mxCreateDoubleMatrix(1,1,mxREAL);&lt;br&gt;
&amp;gt; input[2]= mxCreateString(&quot;la&quot;);&lt;br&gt;
&amp;gt; input[3]= mexGetVariable(&quot;caller&quot;,&quot;options&quot;);&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
I think you will have to post your complete routine, if it isn't too long.&lt;br&gt;
&lt;br&gt;
James Tursa</description>
    </item>
    <item>
      <pubDate>Thu, 13 Aug 2009 15:10:11 -0400</pubDate>
      <title>Re: mex: Compile error with mxArray</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/258421#672899</link>
      <author>David  Hanau</author>
      <description>&quot;James Tursa&quot; &amp;lt;aclassyguy_with_a_k_not_a_c@hotmail.com&amp;gt; wrote in message &amp;lt;h619lq$hka$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;David  Hanau&quot; &amp;lt;hanaud@gmail.com.REMTHIS&amp;gt; wrote in message &amp;lt;h61543$anv$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Compiling C functions with Lcc in Matlab is have the following (classic) error:&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Error sparsesvd_partialeig_matlab.c: 86  operands of = have illegal types `pointer to incomplete struct mxArray_tag defined at C:\MATLAB6p1\extern\include\matrix.h 154' and `int' &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; for the last line of this code: &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; mxArray *output[3],*input[4];&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; mexEvalString(&quot;options.disp=0;&quot;); // for use in calling Matlab function eigs	&lt;br&gt;
&amp;gt; &amp;gt; mexEvalString(&quot;options.maxit=500;&quot;); // for use in calling Matlab function eigs	&lt;br&gt;
&amp;gt; &amp;gt; input[0] = mxCreateDoubleMatrix(n,n,mxREAL); // for use in calling Matlab function eigs&lt;br&gt;
&amp;gt; &amp;gt; input[1] = mxCreateDoubleMatrix(1,1,mxREAL);&lt;br&gt;
&amp;gt; &amp;gt; input[2]= mxCreateString(&quot;la&quot;);&lt;br&gt;
&amp;gt; &amp;gt; input[3]= mexGetVariable(&quot;caller&quot;,&quot;options&quot;);&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I think you will have to post your complete routine, if it isn't too long.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; James Tursa&lt;br&gt;
&lt;br&gt;
This code works and the last releave of MatLab bur not on my V6.1&lt;br&gt;
I post only part of my files. They are really big and I don't think the rest of the code would be relevant here.&lt;br&gt;
the sparseesvd.h:&lt;br&gt;
&lt;br&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br&gt;
#include &amp;lt;math.h&amp;gt;&lt;br&gt;
#include &amp;lt;time.h&amp;gt;&lt;br&gt;
#include &amp;lt;mex.h&amp;gt;&lt;br&gt;
#include &amp;lt;matrix.h&amp;gt;&lt;br&gt;
#include &amp;lt;string.h&amp;gt;&lt;br&gt;
&lt;br&gt;
#ifdef WIN32&lt;br&gt;
#include &amp;lt;malloc.h&amp;gt;&lt;br&gt;
extern void dsaupd();&lt;br&gt;
extern void dseupd();&lt;br&gt;
#endif&lt;br&gt;
&lt;br&gt;
the sparse_rank_one_partialeig_matlab.c&lt;br&gt;
#include &quot;sparsesvd.h&quot;&lt;br&gt;
&lt;br&gt;
void sparse_rank_one_partialeig_matlab(double *Amat, int n, double rho, double gapchange, int MaxIter, double *Xmat, double *Umat, double *uvec, double *Fmat, double *iters, int info, int numeigs, int addeigs, int checkgap, double perceigs, int check_for_more_eigs, double *dualitygap_alliter, double *cputime_alliter, double *perceigs_alliter)&lt;br&gt;
{&lt;br&gt;
	// Hard parameters&lt;br&gt;
	int Nperiod=imaxf(1,info),dspca_finished=0;&lt;br&gt;
	int work_size=3*n+n*n,changedmu=0;&lt;br&gt;
	// Working variables&lt;br&gt;
	double d1,sig1,d2,sig2,norma12,mu,Ntheo,L;&lt;br&gt;
	double alpha,gapk;&lt;br&gt;
	double dmax=0.0,fmu,lambda;&lt;br&gt;
	int n2=n*n,incx=1,precision_flag=0,iteration_flag=0,error_flag=0;&lt;br&gt;
	int lwork,inflapack,indmax,k=0,i,j;&lt;br&gt;
	double cputime,last_time=(double)clock();double start_time=(double)clock();int left_h=0,left_m=0,left_s=0;&lt;br&gt;
	char jobz[1],uplo[1];&lt;br&gt;
	double *Vmat=(double *) calloc(n*n,sizeof(double));&lt;br&gt;
	double *bufmata=(double *) calloc(n*n,sizeof(double));&lt;br&gt;
	double *bufmatb=(double *) calloc(n*n,sizeof(double));&lt;br&gt;
	double *workvec=(double *) calloc(work_size,sizeof(double));&lt;br&gt;
	double *hvec=(double *) calloc(n,sizeof(double));&lt;br&gt;
	int work_size3=8*n;&lt;br&gt;
	double *workvec2=(double *) calloc(work_size3,sizeof(double));&lt;br&gt;
	int *iwork=(int *) calloc(5*n,sizeof(int));&lt;br&gt;
	double *numeigs_matlab=(double *) calloc(1,sizeof(double));&lt;br&gt;
	double *evector_temp=(double *) calloc(n*n,sizeof(double));&lt;br&gt;
	double *evalue=(double *) calloc(n*n,sizeof(double));&lt;br&gt;
	double *evector_store=(double *) calloc(n*n,sizeof(double));&lt;br&gt;
	double eigcut,tolweight=.75,tol=.01;&lt;br&gt;
	int *count=(int *) calloc(n,sizeof(int));&lt;br&gt;
	mxArray *output[3],*input[4];&lt;br&gt;
	double *Fmattemp=(double *) calloc(n*n,sizeof(double));&lt;br&gt;
	double *Xmattemp=(double *) calloc(n*n,sizeof(double));&lt;br&gt;
	int checkgap_count=0; // added for test variables&lt;br&gt;
&lt;br&gt;
	// Start...&lt;br&gt;
	if (info&amp;gt;=1)&lt;br&gt;
	{&lt;br&gt;
		mexPrintf(&quot;DSPCA starting ... \n&quot;);&lt;br&gt;
		mexEvalString(&quot;drawnow;&quot;);&lt;br&gt;
	}&lt;br&gt;
	// Test malloc results&lt;br&gt;
	if ((Fmat==NULL) || (Vmat==NULL) || (bufmata==NULL) || (bufmatb==NULL)|| (workvec==NULL) || (hvec==NULL) ||(evector_temp==NULL)||(evector_store==NULL)||(evalue==NULL)||(iwork==NULL)||(workvec2==NULL)||(numeigs_matlab==NULL)||(Fmattemp==NULL)||(Xmattemp==NULL))&lt;br&gt;
	{&lt;br&gt;
		mexPrintf(&quot;DSPCA: memory allocation failed ... \n&quot;);&lt;br&gt;
		mexEvalString(&quot;drawnow;&quot;);return;&lt;br&gt;
	}&lt;br&gt;
	eigcut=(1-tolweight)*(tol/10)/(rho*pow(n,1.5)); // scale delta (tol/10) to get eig threshold&lt;br&gt;
	tol=tolweight*tol; // scale of .5 for partial eig precision&lt;br&gt;
	mexEvalString(&quot;options.disp=0;&quot;);           // for use in calling Matlab function eigs	&lt;br&gt;
	mexEvalString(&quot;options.maxit=500;&quot;);		 // for use in calling Matlab function eigs	&lt;br&gt;
	input[0] = mxCreateDoubleMatrix(n,n,mxREAL); // for use in calling Matlab function eigs&lt;br&gt;
	input[1] = mxCreateDoubleMatrix(1,1,mxREAL);&lt;br&gt;
	input[2]= mxCreateString(&quot;la&quot;);&lt;br&gt;
	input[3]= mexGetVariable(&quot;caller&quot;,&quot;options&quot;);&lt;br&gt;
&lt;br&gt;
	// First, compute some local params&lt;br&gt;
	d1=rho*rho*n*n/2.0;sig1=1.0;d2=log(n);sig2=0.5;norma12=1.0;mu=tol/(2.0*d2);&lt;br&gt;
	Ntheo=(4.0*norma12*sqrt(d1*d2/(sig1*sig2)))/tol;Ntheo=ceil(Ntheo);&lt;br&gt;
	L=(d2*norma12*norma12)/(2.0*sig2*tol);&lt;br&gt;
	alpha=0.0;cblas_dscal(n2,alpha,Xmat,incx);&lt;br&gt;
	&lt;br&gt;
	cputime=start_time;&lt;br&gt;
&lt;br&gt;
		*count=0;&lt;br&gt;
		// eigenvalue decomposition of A+X &lt;br&gt;
		cblas_dcopy(n2,Xmat,incx,Vmat,incx);&lt;br&gt;
		alpha=1.0; &lt;br&gt;
		cblas_daxpy(n2,alpha,Amat,incx,Vmat,incx);&lt;br&gt;
		symmetrize(Vmat,bufmata,n);	// symmetrize A+X so no precision problems		&lt;br&gt;
		// do partial eigenvalue approximation to exp(A+X)&lt;br&gt;
		cblas_dcopy(n2,bufmata,incx,Vmat,incx);		&lt;br&gt;
		*numeigs_matlab=1.0*numeigs;&lt;br&gt;
		fmu=partial_eig_matlab(n,k,mu,eigcut,bufmata,bufmatb,numeigs_matlab,&lt;br&gt;
			evector_temp,evector_store,evalue,input,output,&lt;br&gt;
			hvec,Vmat,Umat,workvec,count,dmax,addeigs,perceigs,check_for_more_eigs);&lt;br&gt;
		numeigs=(int)(*numeigs_matlab);		&lt;br&gt;
}</description>
    </item>
    <item>
      <pubDate>Thu, 13 Aug 2009 17:26:02 -0400</pubDate>
      <title>Re: mex: Compile error with mxArray</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/258421#672970</link>
      <author>James Tursa</author>
      <description>&quot;David  Hanau&quot; &amp;lt;hanaud@gmail.com.REMTHIS&amp;gt; wrote in message &amp;lt;h61acj$43k$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; This code works and the last releave of MatLab bur not on my V6.1&lt;br&gt;
&amp;gt; I post only part of my files. They are really big and I don't think the rest of the code would be relevant here.&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;:&lt;br&gt;
&amp;gt; 	mexEvalString(&quot;options.disp=0;&quot;);           // for use in calling Matlab function eigs	&lt;br&gt;
&amp;gt; 	mexEvalString(&quot;options.maxit=500;&quot;);		 // for use in calling Matlab function eigs	&lt;br&gt;
&amp;gt; 	input[0] = mxCreateDoubleMatrix(n,n,mxREAL); // for use in calling Matlab function eigs&lt;br&gt;
&amp;gt; 	input[1] = mxCreateDoubleMatrix(1,1,mxREAL);&lt;br&gt;
&amp;gt; 	input[2]= mxCreateString(&quot;la&quot;);&lt;br&gt;
&amp;gt; 	input[3]= mexGetVariable(&quot;caller&quot;,&quot;options&quot;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;:&lt;br&gt;
&lt;br&gt;
I don't have a v6.1 available, but my guess is that one or more of your mx___ or mex___ functions is not available in the older MATLAB version. If it is not available, then there will be no prototype in the mex.h or matrix.h file. So when the compiler gets to the function, absent a prototype, it makes the default assumption that the function returns an int, and of course you are assigning it to a mxArray *. Thus you get the &quot;... invalid assignment int to mxArray * ...&quot; message from the compiler.&lt;br&gt;
&lt;br&gt;
My advice is to get a list of all the mx___ and mex___ functions you use and check to see which ones are not available in the earlier version of MATLAB, and then write workarounds for these functions if you can.&lt;br&gt;
&lt;br&gt;
James Tursa</description>
    </item>
    <item>
      <pubDate>Thu, 13 Aug 2009 17:48:01 -0400</pubDate>
      <title>Re: mex: Compile error with mxArray</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/258421#672974</link>
      <author>James Tursa</author>
      <description>&quot;David  Hanau&quot; &amp;lt;hanaud@gmail.com.REMTHIS&amp;gt; wrote in message &amp;lt;h61acj$43k$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I post only part of my files. They are really big and I don't think the rest of the code would be relevant here.&lt;br&gt;
&lt;br&gt;
I notice in the code you post there are several opportunities for memory leaks. I assume you have free() calls somewhere to clean up all of your calloc calls and you snipped that out and didn't post that code??? Also, you might think of switching your calloc (and free) calls to mxCalloc (and mxFree) calls.&lt;br&gt;
&lt;br&gt;
James Tursa</description>
    </item>
    <item>
      <pubDate>Fri, 14 Aug 2009 06:39:01 -0400</pubDate>
      <title>Re: mex: Compile error with mxArray</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/258421#673122</link>
      <author>James Tursa</author>
      <description>&quot;James Tursa&quot; &amp;lt;aclassyguy_with_a_k_not_a_c@hotmail.com&amp;gt; wrote in message &amp;lt;h61iba$hft$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;David  Hanau&quot; &amp;lt;hanaud@gmail.com.REMTHIS&amp;gt; wrote in message &amp;lt;h61acj$43k$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; This code works and the last releave of MatLab bur not on my V6.1&lt;br&gt;
&amp;gt; &amp;gt; I post only part of my files. They are really big and I don't think the rest of the code would be relevant here.&lt;br&gt;
&amp;gt;                :&lt;br&gt;
&amp;gt; &amp;gt; 	mexEvalString(&quot;options.disp=0;&quot;);           // for use in calling Matlab function eigs	&lt;br&gt;
&amp;gt; &amp;gt; 	mexEvalString(&quot;options.maxit=500;&quot;);		 // for use in calling Matlab function eigs	&lt;br&gt;
&amp;gt; &amp;gt; 	input[0] = mxCreateDoubleMatrix(n,n,mxREAL); // for use in calling Matlab function eigs&lt;br&gt;
&amp;gt; &amp;gt; 	input[1] = mxCreateDoubleMatrix(1,1,mxREAL);&lt;br&gt;
&amp;gt; &amp;gt; 	input[2]= mxCreateString(&quot;la&quot;);&lt;br&gt;
&amp;gt; &amp;gt; 	input[3]= mexGetVariable(&quot;caller&quot;,&quot;options&quot;);&lt;br&gt;
&amp;gt;                     :&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I don't have a v6.1 available, but my guess is that one or more of your mx___ or mex___ functions is not available in the older MATLAB version. If it is not available, then there will be no prototype in the mex.h or matrix.h file. So when the compiler gets to the function, absent a prototype, it makes the default assumption that the function returns an int, and of course you are assigning it to a mxArray *. Thus you get the &quot;... invalid assignment int to mxArray * ...&quot; message from the compiler.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; My advice is to get a list of all the mx___ and mex___ functions you use and check to see which ones are not available in the earlier version of MATLAB, and then write workarounds for these functions if you can.&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
Looks like the culprit is indeed mexGetVariable. The older MATLAB versions have a different function called mexGetArray. The comparison prototypes are:&lt;br&gt;
&lt;br&gt;
Older versions:&lt;br&gt;
mxArray *mexGetArray(const char *name, const char *workspace);&lt;br&gt;
&lt;br&gt;
Newer versions:&lt;br&gt;
mxArray *mexGetVariable(const char *workspace, const char *varname);&lt;br&gt;
&lt;br&gt;
So the name is different, and the argument order has switched. So include this at the top of your source code when compiling using the older version of MATLAB:&lt;br&gt;
&lt;br&gt;
mxArray *mexGetVariable(const char *workspace, const char *varname)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return mexGetArray(varname, workspace);&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
James Tursa</description>
    </item>
    <item>
      <pubDate>Mon, 17 Aug 2009 12:45:18 -0400</pubDate>
      <title>Re: mex: Compile error with mxArray</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/258421#673721</link>
      <author>David  Hanau</author>
      <description>&quot;James Tursa&quot; &amp;lt;aclassyguy_with_a_k_not_a_c@hotmail.com&amp;gt; wrote in message &amp;lt;h630q5$o5b$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;James Tursa&quot; &amp;lt;aclassyguy_with_a_k_not_a_c@hotmail.com&amp;gt; wrote in message &amp;lt;h61iba$hft$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &quot;David  Hanau&quot; &amp;lt;hanaud@gmail.com.REMTHIS&amp;gt; wrote in message &amp;lt;h61acj$43k$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; This code works and the last releave of MatLab bur not on my V6.1&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; I post only part of my files. They are really big and I don't think the rest of the code would be relevant here.&lt;br&gt;
&amp;gt; &amp;gt;                :&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; 	mexEvalString(&quot;options.disp=0;&quot;);           // for use in calling Matlab function eigs	&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; 	mexEvalString(&quot;options.maxit=500;&quot;);		 // for use in calling Matlab function eigs	&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; 	input[0] = mxCreateDoubleMatrix(n,n,mxREAL); // for use in calling Matlab function eigs&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; 	input[1] = mxCreateDoubleMatrix(1,1,mxREAL);&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; 	input[2]= mxCreateString(&quot;la&quot;);&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; 	input[3]= mexGetVariable(&quot;caller&quot;,&quot;options&quot;);&lt;br&gt;
&amp;gt; &amp;gt;                     :&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; I don't have a v6.1 available, but my guess is that one or more of your mx___ or mex___ functions is not available in the older MATLAB version. If it is not available, then there will be no prototype in the mex.h or matrix.h file. So when the compiler gets to the function, absent a prototype, it makes the default assumption that the function returns an int, and of course you are assigning it to a mxArray *. Thus you get the &quot;... invalid assignment int to mxArray * ...&quot; message from the compiler.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; My advice is to get a list of all the mx___ and mex___ functions you use and check to see which ones are not available in the earlier version of MATLAB, and then write workarounds for these functions if you can.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Looks like the culprit is indeed mexGetVariable. The older MATLAB versions have a different function called mexGetArray. The comparison prototypes are:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Older versions:&lt;br&gt;
&amp;gt; mxArray *mexGetArray(const char *name, const char *workspace);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Newer versions:&lt;br&gt;
&amp;gt; mxArray *mexGetVariable(const char *workspace, const char *varname);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; So the name is different, and the argument order has switched. So include this at the top of your source code when compiling using the older version of MATLAB:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; mxArray *mexGetVariable(const char *workspace, const char *varname)&lt;br&gt;
&amp;gt; {&lt;br&gt;
&amp;gt;     return mexGetArray(varname, workspace);&lt;br&gt;
&amp;gt; }&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; James Tursa&lt;br&gt;
&lt;br&gt;
Thank you for your help. Indeed the mexGetArray do the job perfectly.&lt;br&gt;
&lt;br&gt;
No I tacke a new issue, but I think it comes from the memory allocation. &lt;br&gt;
I am going to look into it and try to debug the mex file!&lt;br&gt;
&lt;br&gt;
------------------------------------------------------------------------&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Segmentation violation detected at Mon Aug 17 14:39:10 2009&lt;br&gt;
------------------------------------------------------------------------&lt;br&gt;
&lt;br&gt;
Configuration:&lt;br&gt;
&amp;nbsp;&amp;nbsp;MATLAB Version:   6.1.0.450 (R12.1)&lt;br&gt;
&amp;nbsp;&amp;nbsp;Operating System: Microsoft Windows 2000&lt;br&gt;
&amp;nbsp;&amp;nbsp;Window System:    Version 5.1 (Build 2600: Service Pack 2)&lt;br&gt;
&amp;nbsp;&amp;nbsp;Processor ID:     x86 Family 15 Model 4 Stepping 9, GenuineIntel&lt;br&gt;
&amp;nbsp;&amp;nbsp;Virtual Machine:  Java 1.1.8 from Sun Microsystems Inc.&lt;br&gt;
&lt;br&gt;
Register State:&lt;br&gt;
&amp;nbsp;&amp;nbsp;EAX = 00000000  EBX = 00074330&lt;br&gt;
&amp;nbsp;&amp;nbsp;ECX = 00074970  EDX = 00000640&lt;br&gt;
&amp;nbsp;&amp;nbsp;ESI = 000000c8  EDI = 0000002c&lt;br&gt;
&amp;nbsp;&amp;nbsp;EBP = 00000160  ESP = 0149a1c8&lt;br&gt;
&amp;nbsp;&amp;nbsp;EIP = 02210f92  FLG = 00010287&lt;br&gt;
&lt;br&gt;
Stack Trace:&lt;br&gt;
&lt;br&gt;
This error was detected while a MEX-file was running.  If the MEX-file&lt;br&gt;
is not an official MathWorks function, please examine its source code&lt;br&gt;
for errors.  Please consult the External Interfaces Guide for information&lt;br&gt;
on debugging MEX-files.</description>
    </item>
  </channel>
</rss>

