Why does my FORTRAN code produce a different answer outside of MATLAB than inside of my MEX-file?
1 次查看(过去 30 天)
显示 更早的评论
When I run my FORTRAN code as a standalone executable, I receive a different answer than when the same code is called from inside my MEX-file.
采纳的回答
MathWorks Support Team
2009-6-27
This is due to how MATLAB sets up the floating-point operations in the CPU at startup, and is not a bug in MATLAB.
If you use the following C code in your FORTRAN program, you should see the same answers:
void ResetFPU()
{
const static int CtrlWord=0x123f;
__asm fninit //initialize fpu
__asm fnclex // clear fpu exceptions
__asm fldcw CtrlWord // Load_FPU_Control_Word;
}
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Fortran with MATLAB 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!