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!