26 #ifndef CASADI_GENERIC_EXPRESSION_HPP
27 #define CASADI_GENERIC_EXPRESSION_HPP
29 #include "calculus.hpp"
50 template<
typename ExType>
54 inline const ExType&
self()
const {
return static_cast<const ExType&
>(*this); }
55 inline ExType&
self() {
return static_cast<ExType&
>(*this); }
161 static ExType
plus(
const ExType &x,
const ExType &y) {
162 return ExType::binary(
OP_ADD, x, y);
164 friend inline ExType
plus(
const ExType &x,
const ExType &y) {
165 return ExType::plus(x, y);
167 friend inline ExType
operator+(
const ExType &x,
const ExType &y) {
170 inline ExType&
operator+=(
const ExType &y) {
return self() =
self() + y; }
221 static ExType
minus(
const ExType &x,
const ExType &y) {
222 return ExType::binary(
OP_SUB, x, y);
224 friend inline ExType
minus(
const ExType &x,
const ExType &y) {
225 return ExType::minus(x, y);
227 friend inline ExType
operator-(
const ExType &x,
const ExType &y) {
230 inline ExType&
operator-=(
const ExType &y) {
return self() =
self() - y; }
289 static ExType
times(
const ExType &x,
const ExType &y) {
290 return ExType::binary(
OP_MUL, x, y);
292 friend inline ExType
times(
const ExType &x,
const ExType &y) {
293 return ExType::times(x, y);
295 friend inline ExType
operator*(
const ExType &x,
const ExType &y) {
298 inline ExType&
operator*=(
const ExType &y) {
return self() =
self() * y;}
360 static ExType
rdivide(
const ExType &x,
const ExType &y) {
361 return ExType::binary(
OP_DIV, x, y);
363 friend inline ExType
rdivide(
const ExType &x,
const ExType &y) {
364 return ExType::rdivide(x, y);
366 friend inline ExType
operator/(
const ExType &x,
const ExType &y) {
369 inline ExType&
operator/=(
const ExType &y) {
return self() =
self() / y;}
428 static ExType
lt(
const ExType &x,
const ExType &y) {
429 return ExType::binary(
OP_LT, x, y);
431 friend inline ExType
lt(
const ExType &x,
const ExType &y) {
432 return ExType::lt(x, y);
434 friend inline ExType
operator<(
const ExType &x,
const ExType &y) {
478 static ExType
le(
const ExType &x,
const ExType &y) {
479 return ExType::binary(
OP_LE, x, y);
481 friend inline ExType
le(
const ExType &x,
const ExType &y) {
482 return ExType::le(x, y);
484 friend inline ExType
operator<=(
const ExType &x,
const ExType &y) {
525 static ExType
gt(
const ExType &x,
const ExType &y) {
526 return ExType::lt(y, x);
528 friend inline ExType
gt(
const ExType &x,
const ExType &y) {
529 return ExType::gt(x, y);
531 friend inline ExType
operator>(
const ExType &x,
const ExType &y) {
571 static ExType
ge(
const ExType &x,
const ExType &y) {
572 return ExType::le(y, x);
574 friend inline ExType
ge(
const ExType &x,
const ExType &y) {
575 return ExType::ge(x, y);
577 friend inline ExType
operator>=(
const ExType &x,
const ExType &y) {
641 static ExType
eq(
const ExType &x,
const ExType &y) {
642 return ExType::binary(
OP_EQ, x, y);
644 friend inline ExType
eq(
const ExType &x,
const ExType &y) {
645 return ExType::eq(x, y);
647 friend inline ExType
operator==(
const ExType &x,
const ExType &y) {
691 static ExType
ne(
const ExType &x,
const ExType &y) {
692 return ExType::binary(
OP_NE, x, y);
694 friend inline ExType
ne(
const ExType &x,
const ExType &y) {
695 return ExType::ne(x, y);
697 friend inline ExType
operator!=(
const ExType &x,
const ExType &y) {
753 static ExType
logic_and(
const ExType &x,
const ExType &y) {
754 return ExType::binary(
OP_AND, x, y);
756 friend inline ExType
logic_and(
const ExType &x,
const ExType &y) {
757 return ExType::logic_and(x, y);
759 friend inline ExType
operator&&(
const ExType &x,
const ExType &y) {
802 static ExType
logic_or(
const ExType &x,
const ExType &y) {
803 return ExType::binary(
OP_OR, x, y);
805 friend inline ExType
logic_or(
const ExType &x,
const ExType &y) {
806 return ExType::logic_or(x, y);
808 friend inline ExType
operator||(
const ExType &x,
const ExType &y) {
864 return ExType::unary(
OP_NOT, x);
867 return ExType::logic_not(x);
925 static ExType
abs(
const ExType& x) {
926 return ExType::unary(
OP_FABS, x);
928 friend inline ExType
abs(
const ExType& x) {
929 return ExType::abs(x);
931 friend inline ExType
fabs(
const ExType& x) {
972 static ExType
sqrt(
const ExType& x) {
973 return ExType::unary(
OP_SQRT, x);
975 friend inline ExType
sqrt(
const ExType& x) {
976 return ExType::sqrt(x);
1010 static ExType
sq(
const ExType& x) {
1011 return ExType::unary(
OP_SQ, x);
1013 friend inline ExType
sq(
const ExType& x) {
1014 return ExType::sq(x);
1058 static ExType
sin(
const ExType& x) {
1059 return ExType::unary(
OP_SIN, x);
1061 friend inline ExType
sin(
const ExType& x) {
1062 return ExType::sin(x);
1112 static ExType
cos(
const ExType& x) {
1113 return ExType::unary(
OP_COS, x);
1115 friend inline ExType
cos(
const ExType& x) {
1116 return ExType::cos(x);
1149 static ExType
tan(
const ExType& x) {
1150 return ExType::unary(
OP_TAN, x);
1152 friend inline ExType
tan(
const ExType& x) {
1153 return ExType::tan(x);
1187 static ExType
atan(
const ExType& x) {
1188 return ExType::unary(
OP_ATAN, x);
1190 friend inline ExType
atan(
const ExType& x) {
1191 return ExType::atan(x);
1224 static ExType
asin(
const ExType& x) {
1225 return ExType::unary(
OP_ASIN, x);
1227 friend inline ExType
asin(
const ExType& x) {
1228 return ExType::asin(x);
1261 static ExType
acos(
const ExType& x) {
1262 return ExType::unary(
OP_ACOS, x);
1264 friend inline ExType
acos(
const ExType& x) {
1265 return ExType::acos(x);
1298 static ExType
tanh(
const ExType& x) {
1299 return ExType::unary(
OP_TANH, x);
1301 friend inline ExType
tanh(
const ExType& x) {
1302 return ExType::tanh(x);
1335 static ExType
sinh(
const ExType& x) {
1336 return ExType::unary(
OP_SINH, x);
1338 friend inline ExType
sinh(
const ExType& x) {
1339 return ExType::sinh(x);
1372 static ExType
cosh(
const ExType& x) {
1373 return ExType::unary(
OP_COSH, x);
1375 friend inline ExType
cosh(
const ExType& x) {
1376 return ExType::cosh(x);
1412 friend inline ExType
atanh(
const ExType& x) {
1413 return ExType::atanh(x);
1449 friend inline ExType
asinh(
const ExType& x) {
1450 return ExType::asinh(x);
1486 friend inline ExType
acosh(
const ExType& x) {
1487 return ExType::acosh(x);
1531 static ExType
exp(
const ExType& x) {
1532 return ExType::unary(
OP_EXP, x);
1534 friend inline ExType
exp(
const ExType& x) {
1535 return ExType::exp(x);
1575 static ExType
log(
const ExType& x) {
1576 return ExType::unary(
OP_LOG, x);
1578 friend inline ExType
log(
const ExType& x) {
1579 return ExType::log(x);
1620 return log(x)*(1/std::log(10.));
1622 friend inline ExType
log10(
const ExType& x) {
1623 return ExType::log10(x);
1666 friend inline ExType
log1p(
const ExType& x) {
1667 return ExType::log1p(x);
1704 friend inline ExType
expm1(
const ExType& x) {
1705 return ExType::expm1(x);
1754 friend inline ExType
floor(
const ExType& x) {
1755 return ExType::floor(x);
1789 static ExType
ceil(
const ExType& x) {
1790 return ExType::unary(
OP_CEIL, x);
1792 friend inline ExType
ceil(
const ExType& x) {
1793 return ExType::ceil(x);
1826 static ExType
erf(
const ExType& x) {
1827 return ExType::unary(
OP_ERF, x);
1829 friend inline ExType
erf(
const ExType& x) {
1830 return ExType::erf(x);
1867 friend inline ExType
erfinv(
const ExType& x) {
1868 return ExType::erfinv(x);
1912 static ExType
sign(
const ExType& x) {
1913 return ExType::unary(
OP_SIGN, x);
1915 friend inline ExType
sign(
const ExType& x) {
1916 return ExType::sign(x);
1978 static ExType
pow(
const ExType& x,
const ExType& y) {
1979 return ExType::binary(
OP_POW, x, y);
1981 friend inline ExType
pow(
const ExType& x,
const ExType& y) {
1982 return ExType::pow(x, y);
2036 static ExType
mod(
const ExType& x,
const ExType& y) {
2037 return ExType::binary(
OP_FMOD, x, y);
2039 friend inline ExType
mod(
const ExType& x,
const ExType& y) {
2040 return ExType::mod(x, y);
2042 friend inline ExType
fmod(
const ExType& x,
const ExType& y) {
2102 friend inline ExType
remainder(
const ExType& x,
const ExType& y) {
2103 return ExType::remainder(x, y);
2146 static ExType
atan2(
const ExType& y,
const ExType& x) {
2147 return ExType::binary(
OP_ATAN2, y, x);
2149 friend inline ExType
atan2(
const ExType& y,
const ExType& x) {
2150 return ExType::atan2(y, x);
2170 return ExType::if_else_zero(x, y);
2232 static ExType
fmin(
const ExType& x,
const ExType& y) {
2233 return ExType::binary(
OP_FMIN, x, y);
2235 friend inline ExType
fmin(
const ExType& x,
const ExType& y) {
2236 return ExType::fmin(x, y);
2289 static ExType
fmax(
const ExType& x,
const ExType& y) {
2290 return ExType::binary(
OP_FMAX, x, y);
2292 friend inline ExType
fmax(
const ExType& x,
const ExType& y) {
2293 return ExType::fmax(x, y);
2369 friend inline bool is_equal(
const ExType& x,
const ExType& y, casadi_int depth=0) {
2370 return ExType::is_equal(x, y, depth);
2417 static ExType
copysign(
const ExType& x,
const ExType& y) {
2420 friend inline ExType
copysign(
const ExType& x,
const ExType& y) {
2421 return ExType::copysign(x, y);
2467 static ExType
constpow(
const ExType& x,
const ExType& y) {
2470 friend inline ExType
constpow(
const ExType& x,
const ExType& y) {
2471 return ExType::constpow(x, y);
2515 static ExType
printme(
const ExType& x,
const ExType& y) {
2518 friend inline ExType
printme(
const ExType& x,
const ExType& y) {
2565 static ExType
hypot(
const ExType& x,
const ExType& y) {
2566 return ExType::binary(
OP_HYPOT, x, y);
2568 friend inline ExType
hypot(
const ExType& x,
const ExType& y) {
2569 return ExType::hypot(x, y);