How to change the class of mxArray double to int in c mex ?

7 ビュー (過去 30 日間)
wei zhang
wei zhang 2021 年 2 月 14 日
コメント済み: Walter Roberson 2021 年 2 月 15 日
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 件のコメント
wei zhang
wei zhang 2021 年 2 月 15 日
@Walter Roberson Thank you for your comment. 1. The uint32 is good to convert data type. 2. I use find function to convert sparse matrix A into COO format. My final goal is to use HYB format of sparse matrix in conjugated gradient method solving Ax = b.To convert matrix A to HYB format, I plan ot use cusparseXcoo2csr and cusparseDcsr2hyb function in cusparse, which transfer sparse matrix from COO to CSR, then to HYB. That is why I need the indices. If you have any suggestion, I would like to know. Cudamex coding is some hard for me.
Walter Roberson
Walter Roberson 2021 年 2 月 15 日
Sorry, I am not familiar with those routines.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeWrite C Functions Callable from MATLAB (MEX Files) についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by