From: Thomas Clark on
Possibly just the syntax error!

you assign to arg_va not to arg_val



"Feixiong " <f.liao(a)tue.nl> wrote in message <hj4cv4$nfh$1(a)fred.mathworks.com>...
> Hello,
> I am now using gateway functions to call c function to speedup the program and encounterimh some problem. I am a new to matlan and c. hope you can help me!
>
> void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]){
> ...
> long int *arg_val;
> arg_va = (long int *) mxGetPr(prhs[0]);
> ....
> }
>
> i am wondering after the type change why the content is set to be zero.
>
> Thanks
From: James Tursa on
"Feixiong " <f.liao(a)tue.nl> wrote in message <hj4he6$fra$1(a)fred.mathworks.com>...
>
> what i am intending to do is:
> prhs[0]) contains a n-length of 1-D array of integer numbers, which is the index of another 2-D array input prhs[1]).
>
> But after mxGetdata or mxGetpr, prhs[0]) was changed to double, which is can't be used as index directly.
>
> Thanks, is there any solution for this?

You still haven't directly answered my question, which was "what class is your input prhs[0]?" You say it contains integer numbers, but I think you mean it is a double class variable with integral values that are used as indexes. With this assumption:

mwSize i, j, n;
double *pr;
:
n = mxGetNumberOfElements(prhs[0]);
pr = mxGetPr(prhs[0]);
for( i=0; i<n; i++ ) {
j = pr[i]; // convert double to mwSize
// j is the index you are after
}

James Tursa
From: Feixiong on
> You still haven't directly answered my question, which was "what class is your input prhs[0]?" You say it contains integer numbers, but I think you mean it is a double class variable with integral values that are used as indexes. With this assumption:
>
> mwSize i, j, n;
> double *pr;
> :
> n = mxGetNumberOfElements(prhs[0]);
> pr = mxGetPr(prhs[0]);
> for( i=0; i<n; i++ ) {
> j = pr[i]; // convert double to mwSize
> // j is the index you are after
> }
>
> James Tursa

Re:
1. the input prhs[0] is a statistic of edge set.
for example:[1 2 15 17 ... 125, 222, 22000,..];
let pr = mxGetPr(prhs[0]);

2. then the input prhs[1] is subset of edge set,
[1 2 2.1;
2 21 10.5;
2 29 10.2;
... ]

in which pr[1]:pr[2]-1 columns edges indicate links from node 1, pr[2]:pr[3]-1 columns indicate links from node 2, and so on...

thanks
From: Feixiong on

> Re:
> 1. the input prhs[0] is a statistic of edge set.
> for example:[1 2 15 17 ... 125, 222, 22000,..];
> let pr = mxGetPr(prhs[0]);
>
> 2. then the input prhs[1] is subset of edge set,
> [1 2 2.1;
> 2 21 10.5;
> 2 29 10.2;
> ... ]
>
> in which pr[1]:pr[2]-1 columns edges indicate links from node 1, pr[2]:pr[3]-1 columns indicate links from node 2, and so on...
>
> thanks


can anyone help me?
From: James Tursa on
"Feixiong " <f.liao(a)tue.nl> wrote in message <hj7lph$1sv$1(a)fred.mathworks.com>...
>
> > Re:
> > 1. the input prhs[0] is a statistic of edge set.
> > for example:[1 2 15 17 ... 125, 222, 22000,..];
> > let pr = mxGetPr(prhs[0]);
> >
> > 2. then the input prhs[1] is subset of edge set,
> > [1 2 2.1;
> > 2 21 10.5;
> > 2 29 10.2;
> > ... ]
> >
> > in which pr[1]:pr[2]-1 columns edges indicate links from node 1, pr[2]:pr[3]-1 columns indicate links from node 2, and so on...
> >
> > thanks
>
>
> can anyone help me?

Oh ... sorry. I thought this thread was done and you had your answer. I already showed you how to get the integral values from a double into an integer type in C, which is what I thought you needed. What is the current issue?

James Tursa