Mexing s-function with compiler flag -fshort-double fails....
1 回表示 (過去 30 日間)
古いコメントを表示
Hello,
for numerical tests of a filter algorithm implemented in C++ (testing/simulation environment is a larger simulink project) I would like to switch to single precision variables. For the gcc/g++ the option -fshort-double seems to make switching to single precision very comfortable, because it basically shrinks doubles to the size of floats.
However I get the following warning when mexing the algorithm:
/opt/matlab/v24/simulink/include/simulink.c: In function ‘int_T ssWriteRTWParamSettings(SimStruct*, int_T, ...)’: /opt/matlab/v24/simulink/include/simulink.c:1538: warning: ‘real_T’ is promoted to ‘double’ when passed through ‘...’ /opt/matlab/v24/simulink/include/simulink.c:1538: note: (so you should pass ‘double’ not ‘real_T’ to ‘va_arg’) /opt/matlab/v24/simulink/include/simulink.c:1538: note: if this code is reached, the program will abort
As stated in the warning, the simulation doesn't run, but gives the error: Invalid sizes vector returned by MEX S-function
Can this be resolved or does anybody have an alternative way of testing an S-function with single precision.
Regards, Sebastian
2 件のコメント
Titus Edelhofer
2011 年 6 月 14 日
Hi Sebastian,
I understand you are writing a Simulink S-function? I would not use the flag for the compiler but tell the S-function to take single precision inputs/outputs and parameters...
Titus
Kaustubha Govind
2011 年 6 月 14 日
I agree with Titus. What you are doing will cause problems because the Simulink engine allocates and reads from signals and parameters that are supposedly double, but when it dispatched a call to MEX, it is really accessing single variables.
回答 (1 件)
Wendy Fullam
2012 年 9 月 25 日
Answered in comments by Titus
Hi Sebastian,
I understand you are writing a Simulink S-function? I would not use the flag for the compiler but tell the S-function to take single precision inputs/outputs and parameters...
Titus
0 件のコメント
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!