フィルターのクリア

Mex with Function Pointers?

1 回表示 (過去 30 日間)
Sam Butler
Sam Butler 2013 年 9 月 21 日
回答済み: Sam Butler 2013 年 11 月 20 日
I want to build most of my code in MatLab, but there is one routine that needs to be sped up in C++ (and made to use the GPU; highly parallel problem). The thing is, that problem requires a function pointer.
If I use mex "naively", passing in a function handle to the C interface, can I access this function from C or are there known issues with doing this?
(If it makes a difference, the function was defined using the f = @(x,y) sin(x).*cos(y); syntax for defining functions.)

回答 (1 件)

Sam Butler
Sam Butler 2013 年 11 月 20 日
I got this code to work properly using a mix of C++ objects and MatLab objects, by tracking the function pointer's 64-bit integer value in MatLab and having the MatLab class extend handle (so it gets deleted automatically, to call the C++ code to delete).

カテゴリ

Help Center および File ExchangeCall C++ from MATLAB についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by