help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Wrong type argument error from compiled mex function


From: Paul Koufalas
Subject: Re: Wrong type argument error from compiled mex function
Date: Sun, 02 Jul 2006 19:08:58 +0930
User-agent: Mozilla Thunderbird 1.0.7 (X11/20051013)

I found this code fragment in the m-file that calls the MEX function:



% Set up to call MEX function
parent=int32(parent);
dim=int16(dim);
S=int16(S);
parameters=[epsilon;fopt;tol;minind];
intarray=[nevals;it;ns;ibest;0; ...
  maxit;ShowIters;n;maxeval;maxs;minevals;minsize;oneeach;greedy];
% Call  MEX function



The MEX function has the three parameters of the same name declared as
shown below:



/* MATLAB Gateway function
   */
void mexFunction(
   int nlhs, mxArray *plhs[],
   int nrhs, const mxArray *prhs[])
{
double  *xrange, *X, *F, *d, *f, *parameters, *intarray;
double *w, *x, *xmid, *len, *lengths;
short *S, *dim;
int *parent;



If integer matrices aren't properly handled yet by mex then this
explains the behaviour I'm seeing.

Is it correct to

1. Remove the int32() and int16() from the m-file
2. Declare parent, dim and S as pointers to double in the MEX file
3. Declare parent_, dim_ and S_ as pointers to int, short and short
resp., and allocate memory for them (using mxCalloc(), knowing their
dimensions)
4. In a for loop, assign parent_[i]=(int)*(parent+i),
S_[i]=(short)*(S+i) and dim_[i]=(short)*(dim+i)
5. Use parent_, S_ and dim_ in function calls from the MEX gateway to C
functions, as these expect to be passed int* short* and short* resp.?

Cheers

>
>John W. Eaton wrote:
>
>  
>
>>On  1-Jul-2006, Paul Koufalas wrote:
>>
>>| G'day all
>>| 
>>| I successfully compiled a 3rd party MEX function (bound constrained
>>| global optimisation code) using Octave's mex utility.
>>| 
>>| However, I get this error message when trying to use the compiled function:
>>| 
>>| error: octave_base_value::matrix_value(): wrong type argument `int32 matrix'
>>| error: octave_base_value::matrix_value(): wrong type argument `int16 matrix'
>>| error: octave_base_value::matrix_value(): wrong type argument `int16 matrix'
>>| 
>>| Depending on the arguments I pass to it (standard optimisation test
>>| functions and bounds), I either get the Octave prompt or a seg fault and
>>| the Bash prompt.
>>| 
>>| I'm not sure where to start looking for the offending MEX function
>>| code...nothing in the MEX function code stands out to me.
>>
>>I don't think integer matrices are properly handled by the mex code
>>in Octave yet.  But you haven't provided enough information to allow
>>anyone to say more than that.  If you want help with debugging, you
>>have to provide something to debug.
>>
>>jwe
>>
>> 
>>
>>    
>>
>
>
>  
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]