使用最新版本的sympy(0.7.6),在确定支持[0,y)的函数的积分时,得到以下错误结果:
from sympy import *
a,b,c,x,z = symbols("a,b,c,x,z",real = True)
y = Symbol("y",real=True,positive=True)
inner = Piecewise((0,(x>=y)|(x<0)|(b>c)),(a,True))
I = Integral(inner,(x,0,z))
Eq(I,I.doit())
Run Code Online (Sandbox Code Playgroud)
http://mathurl.com/l8wrjcn.png
这是不正确的,因为实际结果应该交换最后两个案例.这可以通过检查衍生物来确认:
Derivative(I.doit(),z).doit().simplify().subs(z,x)
Run Code Online (Sandbox Code Playgroud)
http://mathurl.com/mg4zpts.png
到处都减少到0.
有趣的是,当(b>c)通过替换inner = Piecewise((0,(x>=y)|(x<0)),(a,True))I得到一个TypeError来删除条件时:
TypeError: cannot determine truth value of
-oo < y
Run Code Online (Sandbox Code Playgroud)
我是否错误地使用了该库,或者这实际上是一个严重的症状错误?
以下显然有效的代码使用UndefinedBehaviorSanitizer sanitiser产生错位的地址运行时错误.
#include <memory>
#include <functional>
struct A{
std::function<void()> data; // seems to occur only if data is a std::function
} ;
struct B{
char data; // occurs only if B contains a member variable
};
struct C:public virtual A,public B{
};
struct D:public virtual C{
};
void test(){
std::make_shared<D>();
}
int main(){
test();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
在macbook上编译和执行
clang++ -fsanitize=undefined --std=c++11 ./test.cpp && ./a.out
产生输出
runtime error: constructor call on misaligned address 0x7fe584500028 for type 'C', which requires 16 byte …