Hardcoded Integers in C code generated by Matlab Coder
이전 댓글 표시
x = A\B
was converted to C code using Matlab coder. There are few lines in the generated code with hard coded integers. Like..
if (rankR <= 1.4903363393874656E-8)
// Some internal function calls
else
// Usage of standard sqrt
or
500.0 * fabs(A[0]) * 2.2206044429501313E-16
What is the purpose of these hard coded integers ? How are they useful for left matrix division ?
댓글 수: 3
Adam
2016년 7월 22일
I would imagine they are 'epsilon' type parameters that are there to catch situations where you would end up dividing by zero or doing similarly ill-defined operations.
Sean de Wolski
2016년 7월 22일
Adam, that should be an answer!
format long
>> eps
ans =
2.220446049250313e-16
>>
Adam
2016년 7월 22일
Done!
답변 (1개)
I would imagine they are 'epsilon' type parameters that are there to catch situations where you would end up dividing by zero or doing similarly ill-defined operations.
I've not seen the output of Matlab Coder myself yet though we do use it where I work, I just stay on the research end in Matlab itself personally.
By preference though I don't like seeing 'magic' numbers in code like that so I agree with your asking of the question because it is the type of question that magic numbers always throw up.
Nowadays I will always put a named constant in my file and use that instead.
카테고리
도움말 센터 및 File Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!