Hi everyone,
I have a numerical model for some thermodynamical process. Its computations takes a long time and I found a possibility to do a mex file that sufficiently speeds up my problem. However, I obtain results that does not match with experimental results, however I am almost sure about good code implementation and a problem is grid-independent. Can the mex file reduce somehow precision of a variables?
Or another question. When i multiply two double-precise number is their multiplication also double-precision number?
Thx for any ideas

 채택된 답변

James Tursa
James Tursa 2017년 5월 22일
편집: James Tursa 2017년 5월 22일

0 개 추천

Can the mex file reduce somehow precision of a variables?
No. Double precision in a mex routine is the same as double precision at the m-file level. You don't lose precision by doing the double precision calculation in a mex routine.
When i multiply two double-precise number is their multiplication also double-precision number?
Yes. The actual calculation may be done at higher precision, and then down-converted to double precision when stored. But it will not be done with less precision.
Both of those answers are related to the low level double precision calculations. But how the mex routine was written can certainly affect the final answer. So mex code that implements an algorithm differently from its m-file counterpart can certainly get a different answer even if both implementations are using double precision.

댓글 수: 4

Albert Pilos
Albert Pilos 2017년 5월 22일
thank you, James:) however, I hoped for an anwer that would confirm my thoughts. Well, in that way i'm going to do my best to find that mistake
James Tursa
James Tursa 2017년 5월 22일
How was the mex routine generated? Did you hand write the source code?
Albert Pilos
Albert Pilos 2017년 5월 22일
no just wrote "coder" into a command window and defined input variables
James Tursa
James Tursa 2017년 5월 22일
How much different are the results?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Write C Functions Callable from MATLAB (MEX Files)에 대해 자세히 알아보기

질문:

2017년 5월 22일

댓글:

2017년 5월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by