如何看待 std::linalg?

发布时间:
2024-09-04 13:00
阅读量:
7

别抱太大希望。好多功能也就是先占个位置,谈不上好用。


例如C++17引入了贝塞尔函数cyl_bessel_j,但只保证128阶以下的结果是对的,128阶以上的看编译器良心。原话是这么写的

Errors may be reported as specified in math_errhandling.
If the argument is NaN, NaN is returned and domain error is not reported
If ν>=128, the behavior is implementation-defined

g++好像是负责到180多阶。超过这个也不报错,也不给出NaN或者Inf,但结果就是不对。


“If ν>=128, the behavior is implementation-defined ”意味着有的情形下正常,有的情形下才会出错。出错也不一定是NaN或者Inf这样一眼就能看出来的,可能非常隐晦。不同编译器触发条件还不一样。不知道要浪费多少时间去调试,缺大德了简直是,还不如直接抛个异常呢。

END