How to change the class of mxArray double to int in c mex ?
Show older comments
Hi,
I am trying to convert a double class mxArray to int. I don't know how to do that. My c code is like below. I would like to create the mxGPUArray "row" in int class, which is the row index of matrix A. In my code, the type of "row" is double.
#include "mex.h"
#include "gpu/mxGPUArray.h"
#define A prhs[0]
void mexFunction(int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[])
{
mxArray *tmp[3];
mexCallMATLAB(3,tmp,1,&A,"find");
mxGPUArray const *row = mxGPUCreateFromMxArray(tmp[1]);
}
3 Comments
Walter Roberson
on 14 Feb 2021
You could mexCallMATLAB "uint32" or as appropriate.
I noticed though that you are using find(). It seems most likely that you intend to use the results as indices. Array Indexing in GPU is not efficient. Logical indexing should be faster in most cases, if I understand correctly.
wei zhang
on 15 Feb 2021
Walter Roberson
on 15 Feb 2021
Sorry, I am not familiar with those routines.
Answers (0)
Categories
Find more on Write C Functions Callable from MATLAB (MEX Files) in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!