如何编写单元测试以确保 C 科学计算中的数值准确性? [英] How do I write unit tests for ensuring numerical accuracy in scientific computation in C?
本文介绍了如何编写单元测试以确保 C 科学计算中的数值准确性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在探索 C 和 R 的接口(使用 R 的 .Call 来提高速度).我只将 C 用于微不足道的整数计算和文本处理应用程序,而且我从来不必担心浮点变量、下溢等问题.我可以为函数编写哪些测试来确保数值精度?
I'm currently exploring interfacing C and R (using R's .Call for speed). I've only used C for trivial integer computation and text processing applications, and I've never had to worry about issues with float variables, underflow, etc. What tests can I write for functions to ensure numerical accuracy?
推荐答案
有关可能的边缘情况的详细概述,请参阅此 维基百科文章.
For a great overview of possible edge cases, see this Wikipedia article.
然后对于单元测试,请参阅验证浮点计算的陷阱.
Then for unit tests see The pitfalls of verifying floating-point computations.
这篇关于如何编写单元测试以确保 C 科学计算中的数值准确性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文