0
我有以下函数f(x):muparser可以用不同的域定义不同的函数吗?
f(x) = fun1(x) if x<a
f(x) = fun2(x) if a<=x and if x<b
f(x) = fun3(x) if b<=x
是否有语法,这样我可以写这个函数为这样的字符串26.5将被muparser如何理解?
我有以下函数f(x):muparser可以用不同的域定义不同的函数吗?
f(x) = fun1(x) if x<a
f(x) = fun2(x) if a<=x and if x<b
f(x) = fun3(x) if b<=x
是否有语法,这样我可以写这个函数为这样的字符串26.5将被muparser如何理解?
muParser理解?:
运算符,如在C/C++和其他衍生物中一样。所以,你可以写的f(x)
因为身体:
x<a ? fun1(x) : x<b ? fun2(x) : fun3(x)
我不知道如果这真正抓住你想要什么,但它会工作,因为?:
短路(以便第一:
隐含了条件!(x<a)
)
是的,这正是我想要的。万分感谢! – jmborr 2013-04-23 13:29:29