How do I pass data of pointer to output without factory.createArray() in mex c++?

3 ビュー (過去 30 日間)
Jaehong Lee
Jaehong Lee 2019 年 9 月 20 日
コメント済み: Denis Riedijk 2021 年 3 月 4 日
I want to use c++ based program processing large data by pointer on matlab workspace.
So I've made mex c++ function like
TypedArray<std::complex<double>> complexArray = std::move(inputs[0]);
//get pointer of input
std::complex<double> *temp = complexArray.release().release();
//some processing using *temp
//under 0.7sec
//processing end
//almost 7 sec
outputs[0] = factory.createArray<std::complex<double>>({dimensionX,dimensionY}, temp, temp+dimensionX*dimensionY);
but this way is too slow where factory.createArray()
processing time is almost under 0.7sec, but elapsed time of of createArray is 7sec
I also have used factory.createBuffer() and factory.createArrayFromBuffer(). This way is much faster than createArray, but slower than processing yet.
I want to make output from pointer without the overhead of creating Array

回答 (1 件)

Kritika Bansal
Kritika Bansal 2020 年 1 月 10 日
Hi,
You can use the function mxCreateDoubleMatrix to create a 2D matrix. One of the parameters is ComplexFlag which needs to be set to true if you need a complex double array.
For more information, you can refer the documentation here: https://www.mathworks.com/help/matlab/apiref/mxcreatedoublematrix.html
  1 件のコメント
Denis Riedijk
Denis Riedijk 2021 年 3 月 4 日
mxCreateDoubleMatrix is the C API, not the C++ API, so I am afraid this will not help. (trying to solve an issue I am having I came across this question and answer)

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

カテゴリ

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

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by