26 template<jit::
float_scalar T,
bool SAFE_MATH=false>
70 if (
ac->is(0) ||
ac->is(1)) {
85 ap2->get_num_columns(),
95 if (
am->get_left()->is_constant()) {
97 return sqrt(
am->get_left()) *
100 if (!
am->get_left()->evaluate().is_negative()) {
101 return sqrt(
am->get_left()) *
112 return sqrt(
am->get_left()) *
115 }
else if (
amrp.get()) {
118 return sqrt(
am->get_left()) *
128 if (
alm.get() &&
alm->get_left()->is_constant()) {
136 ad->get_left()->is_constant() ||
138 ad->get_right()->is_constant()) {
139 return sqrt(
ad->get_left()) /
160 const size_t hash =
reinterpret_cast<size_t> (x.get());
182 if (registers.find(
this) == registers.end()) {
183 auto a = this->
arg->compile(stream, registers,
188 jit::add_type<T> (stream);
189 stream <<
" " << registers[
this] <<
" = sqrt("
190 << registers[
a.get()] <<
")";
204 if (
this == x.get()) {
210 return this->
arg->is_match(
x_cast->get_arg());
220 std::cout <<
"\\sqrt{";
221 this->
arg->to_latex();
259 return sqrt(this->
arg->remove_pseudo());
273 if (registers.find(
this) == registers.end()) {
275 registers[
this] =
name;
276 stream <<
" " <<
name
277 <<
" [label = \"sqrt\", shape = oval, style = filled, fillcolor = blue, fontcolor = white];" << std::endl;
279 auto a = this->
arg->to_vizgraph(stream, registers);
280 stream <<
" " <<
name <<
" -- " << registers[
a.get()] <<
";" << std::endl;
296 template<jit::
float_scalar T,
bool SAFE_MATH=false>
298 auto temp = std::make_shared<sqrt_node<T, SAFE_MATH>> (x)->reduce();
300 for (
size_t i =
temp->get_hash();
310#if defined(__clang__) || defined(__GNUC__)
313 assert(
false &&
"Should never reach.");
318 template<jit::
float_scalar T,
bool SAFE_MATH=false>
330 template<jit::
float_scalar T,
bool SAFE_MATH=false>
332 return std::dynamic_pointer_cast<sqrt_node<T, SAFE_MATH>> (x);
346 template<jit::
float_scalar T,
bool SAFE_MATH=false>
400 ap2->get_num_columns(),
427 const size_t hash =
reinterpret_cast<size_t> (x.get());
448 if (registers.find(
this) == registers.end()) {
449 auto a = this->
arg->compile(stream, registers,
454 jit::add_type<T> (stream);
455 stream <<
" " << registers[
this] <<
" = ";
460 stream << registers[
a.get()];
464 stream <<
" < 709.8 ? ";
466 stream <<
"exp(" << registers[
a.get()] <<
")";
470 jit::add_type<T> (stream);
492 if (
this == x.get()) {
498 return this->
arg->is_match(
x_cast->get_arg());
508 std::cout <<
"e^{\\left(";
509 this->
arg->to_latex();
510 std::cout <<
"\\right)}";
520 return exp(this->
arg->remove_pseudo());
534 if (registers.find(
this) == registers.end()) {
536 registers[
this] =
name;
537 stream <<
" " <<
name
538 <<
" [label = \"exp\", shape = oval, style = filled, fillcolor = blue, fontcolor = white];" << std::endl;
540 auto a = this->
arg->to_vizgraph(stream, registers);
541 stream <<
" " <<
name <<
" -- " << registers[
a.get()] <<
";" << std::endl;
557 template<jit::
float_scalar T,
bool SAFE_MATH=false>
559 auto temp = std::make_shared<exp_node<T, SAFE_MATH>> (x)->reduce();
561 for (
size_t i =
temp->get_hash();
571#if defined(__clang__) || defined(__GNUC__)
574 assert(
false &&
"Should never reach.");
579 template<jit::
float_scalar T,
bool SAFE_MATH=false>
591 template<jit::
float_scalar T,
bool SAFE_MATH=false>
593 return std::dynamic_pointer_cast<exp_node<T, SAFE_MATH>> (x);
607 template<jit::
float_scalar T,
bool SAFE_MATH=false>
661 ap2->get_num_columns(),
688 const size_t hash =
reinterpret_cast<size_t> (x.get());
709 if (registers.find(
this) == registers.end()) {
710 auto a = this->
arg->compile(stream, registers,
715 jit::add_type<T> (stream);
716 stream <<
" " << registers[
this] <<
" = log("
717 << registers[
a.get()] <<
")";
731 if (
this == x.get()) {
737 return this->
arg->is_match(
x_cast->get_arg());
747 std::cout <<
"\\ln{\\left(";
748 this->
arg->to_latex();
749 std::cout <<
"\\right)}";
759 return log(this->
arg->remove_pseudo());
773 if (registers.find(
this) == registers.end()) {
775 registers[
this] =
name;
776 stream <<
" " <<
name
777 <<
" [label = \"log\", shape = oval, style = filled, fillcolor = blue, fontcolor = white];" << std::endl;
779 auto a = this->
arg->to_vizgraph(stream, registers);
780 stream <<
" " <<
name <<
" -- " << registers[
a.get()] <<
";" << std::endl;
796 template<jit::
float_scalar T,
bool SAFE_MATH=false>
798 auto temp = std::make_shared<log_node<T, SAFE_MATH>> (x)->reduce();
809#if defined(__clang__) || defined(__GNUC__)
812 assert(
false &&
"Should never reach.");
817 template<jit::
float_scalar T,
bool SAFE_MATH=false>
829 template<jit::
float_scalar T,
bool SAFE_MATH=false>
831 return std::dynamic_pointer_cast<log_node<T, SAFE_MATH>> (x);
845 template<jit::
float_scalar T,
bool SAFE_MATH=false>
895 if (
rc.get() &&
rc->is(0)) {
897 }
else if (
rc.get() &&
rc->is(1)) {
899 }
else if (
rc.get() &&
rc->is(0.5)) {
901 }
else if (
rc.get() &&
rc->is(2)){
904 return sq->get_arg();
908 if (
lc.get() &&
rc.get()) {
914 if (
pl1.get() && (
rc.get() ||
pl1->is_arg_match(
this->right))) {
916 }
else if (
pr1.get() && (
lc.get() ||
pr1->is_arg_match(
this->left))) {
922 if (
pl2.get() && (
rc.get() ||
pl2->is_arg_match(
this->right))) {
924 pl2->get_num_columns(),
927 }
else if (
pr2.get() && (
lc.get() ||
pr2->is_arg_match(
this->left))) {
929 pr2->get_num_columns(),
935 if (
pr2.get() &&
pr2->is_row_match(
this->left)) {
939 pr2->get_num_columns(),
942 }
else if (
pr2.get() &&
pr2->is_col_match(
this->left)) {
946 pr2->get_num_columns(),
949 }
else if (
pl2.get() &&
pl2->is_row_match(
this->right)) {
953 pl2->get_num_columns(),
956 }
else if (
pl2.get() &&
pl2->is_col_match(
this->right)) {
960 pl2->get_num_columns(),
967 if (
lp.get() &&
rc.get() &&
rc->is_integer()) {
968 return pow(
lp->get_left(),
lp->get_right()*
this->right);
974 if (
lm.get() &&
rc.get()) {
975 if (
lm->get_left()->is_constant() ||
976 lm->get_right()->is_constant() ||
981 return pow(
lm->get_left(),
this->right) *
989 if (
lmlm->get_left()->is_constant() ||
990 lmlm->get_right()->is_constant() ||
1004 if (
ld.get() &&
rc.get()) {
1010 rc->evaluate().is_even()) {
1011 if (
ldlm->get_left()->is_constant()) {
1017 if (
ldlm->get_left()->is_constant() ||
1018 ldlm->get_right()->is_constant() ||
1030 if (
ldlmlm->get_left()->is_constant() ||
1031 ldlmlm->get_right()->is_constant() ||
1045 if (
ldlmrm->get_left()->is_constant() ||
1046 ldlmrm->get_right()->is_constant() ||
1060 if (
ld->get_left()->is_constant() ||
1061 ld->get_right()->is_constant() ||
1066 return pow(
ld->get_left(),
this->right) /
1073 if (
ldrm->get_left()->is_constant() ||
1074 ldrm->get_right()->is_constant() ||
1079 return pow(
ld->get_left(),
this->right) /
1086 if (
ldrmlm->get_left()->is_constant() ||
1087 ldrmlm->get_right()->is_constant() ||
1092 return pow(
ld->get_left(),
this->right) /
1101 if (
ldrmrm->get_left()->is_constant() ||
1102 ldrmrm->get_right()->is_constant() ||
1107 return pow(
ld->get_left(),
this->right) /
1117 return pow(
ld->get_left()->get_power_base(),
1118 this->right*(
ld->get_left()->get_power_exponent() -
1119 ld->get_right()->get_power_exponent()));
1126 ldrmlm->get_right()->get_power_base())) {
1132 ldrmlm->get_left()->get_power_base())) {
1138 ldrmlm->get_right()->get_power_base()) ||
1140 ldrmlm->get_left()->get_power_base())) {
1141 return pow(
ld->get_left()/
ldrm->get_right(),
1153 return pow(
lsq->get_arg(),
1159 if (
temp.get() &&
rc.get() &&
rc->is_integer()) {
1163 if constexpr (std::floating_point<T>) {
1166 if (
lhp.get() &&
rc.get() &&
rc->is(2)) {
1173 if (
ld.get() &&
rc.get() &&
rc->is(2)) {
1177 return (
pow(
ldlhp->get_left(),
static_cast<T
> (2)) +
1178 pow(
ldlhp->get_right(),
static_cast<T
> (2))) /
1179 pow(
ld->get_right(),
static_cast<T
> (2));
1180 }
else if (
ldrhp.get()) {
1181 return pow(
ld->get_left(),
static_cast<T
> (2)) /
1182 (
pow(
ldrhp->get_left(),
static_cast<T
> (2)) +
1183 pow(
ldrhp->get_right(),
static_cast<T
> (2)));
1205 const size_t hash =
reinterpret_cast<size_t> (x.get());
1228 if (registers.find(
this) == registers.end()) {
1233 if (!
temp.get() || !
temp->is_integer()) {
1234 r = this->
right->compile(stream, registers,
1239 stream <<
" const ";
1240 jit::add_type<T> (stream);
1241 stream <<
" " << registers[
this] <<
" = ";
1242 if (
temp.get() &&
temp->is_integer()) {
1243 stream << registers[l.get()];
1244 const size_t end =
static_cast<size_t> (std::real(this->
right->evaluate().at(0)));
1245 for (
size_t i = 1;
i < end;
i++) {
1246 stream <<
"*" << registers[l.get()];
1250 << registers[l.get()] <<
", "
1251 << registers[
r.get()] <<
")";
1266 if (
this == x.get()) {
1272 return this->
left->is_match(
x_cast->get_left()) &&
1287 std::cout <<
"\\left(";
1289 this->
left->to_latex();
1291 std::cout <<
"\\right)";
1294 this->
right->to_latex();
1307 if (registers.find(
this) == registers.end()) {
1309 registers[
this] =
name;
1310 stream <<
" " <<
name
1311 <<
" [label = \"pow\", shape = oval, style = filled, fillcolor = blue, fontcolor = white];" << std::endl;
1314 stream <<
" " <<
name <<
" -- " << registers[l.get()] <<
";" << std::endl;
1315 auto r = this->
right->to_vizgraph(stream, registers);
1316 stream <<
" " <<
name <<
" -- " << registers[
r.get()] <<
";" << std::endl;
1328 return this->
left->is_all_variables() &&
1329 (this->
right->is_all_variables() ||
1367 return pow(this->
left->remove_pseudo(),
1368 this->right->remove_pseudo());
1383 template<jit::
float_scalar T,
bool SAFE_MATH=false>
1386 auto temp = std::make_shared<pow_node<T, SAFE_MATH>> (l,
r)->reduce();
1388 for (
size_t i =
temp->get_hash();
1398#if defined(__clang__) || defined(__GNUC__)
1401 assert(
false &&
"Should never reach.");
1415 template<jit::
float_scalar T, jit::
float_scalar L,
bool SAFE_MATH=false>
1431 template<jit::
float_scalar T, jit::
float_scalar R,
bool SAFE_MATH=false>
1438 template<jit::
float_scalar T,
bool SAFE_MATH=false>
1447 template<jit::
float_scalar T,
bool SAFE_MATH=false>
1449 return std::dynamic_pointer_cast<pow_node<T, SAFE_MATH>> (x);
1463 template<std::
floating_po
int T,
bool SAFE_MATH=false>
1517 ap2->get_num_columns(),
1538 const size_t hash =
reinterpret_cast<size_t> (x.get());
1541 * std::numbers::inv_sqrtpi_v<T>
1542 *
exp(this->
arg*this->
arg)*this->arg->df(x);
1561 if (registers.find(
this) == registers.end()) {
1562 auto a = this->
arg->compile(stream, registers,
1566 stream <<
" const ";
1567 jit::add_type<T> (stream);
1568 stream <<
" " << registers[
this] <<
" = erf("
1569 << registers[
a.get()] <<
")";
1583 if (
this == x.get()) {
1589 return this->
arg->is_match(
x_cast->get_arg());
1599 std::cout <<
"erf\\left(";
1600 this->
arg->to_latex();
1601 std::cout <<
"\\right)";
1611 return erf(this->
arg->remove_pseudo());
1625 if (registers.find(
this) == registers.end()) {
1627 registers[
this] =
name;
1628 stream <<
" " <<
name
1629 <<
" [label = \"erf\", shape = oval, style = filled, fillcolor = blue, fontcolor = white];" << std::endl;
1631 auto a = this->
arg->to_vizgraph(stream, registers);
1632 stream <<
" " <<
name <<
" -- " << registers[
a.get()] <<
";" << std::endl;
1648 template<std::
floating_po
int T,
bool SAFE_MATH=false>
1650 auto temp = std::make_shared<erf_node<T, SAFE_MATH>> (x)->reduce();
1652 for (
size_t i =
temp->get_hash();
1662#if defined(__clang__) || defined(__GNUC__)
1665 assert(
false &&
"Should never reach.");
1670 template<std::
floating_po
int T,
bool SAFE_MATH=false>
1682 template<std::
floating_po
int T,
bool SAFE_MATH=false>
1684 return std::dynamic_pointer_cast<erf_node<T, SAFE_MATH>> (x);
1698 template<jit::complex_scalar T,
bool SAFE_MATH=false>
1752 ap2->get_num_columns(),
1773 const size_t hash =
reinterpret_cast<size_t> (x.get());
1776 if constexpr(std::same_as<T, std::complex<float>>) {
1777 invsqpi = std::numbers::inv_sqrtpi_v<float>;
1779 invsqpi = std::numbers::inv_sqrtpi_v<double>;
1783 *
exp(this->
arg*this->
arg)*this->arg->df(x);
1802 if (registers.find(
this) == registers.end()) {
1803 auto a = this->
arg->compile(stream, registers,
1807 stream <<
" const ";
1808 jit::add_type<T> (stream);
1809 stream <<
" " << registers[
this] <<
" = special::erfi("
1810 << registers[
a.get()] <<
")";
1824 if (
this == x.get()) {
1830 return this->
arg->is_match(
x_cast->get_arg());
1840 std::cout <<
"erfi\\left(";
1841 this->
arg->to_latex();
1842 std::cout <<
"\\right)";
1852 return erfi(this->
arg->remove_pseudo());
1866 if (registers.find(
this) == registers.end()) {
1868 registers[
this] =
name;
1869 stream <<
" " <<
name
1870 <<
" [label = \"erfi\", shape = oval, style = filled, fillcolor = blue, fontcolor = white];" << std::endl;
1872 auto a = this->
arg->to_vizgraph(stream, registers);
1873 stream <<
" " <<
name <<
" -- " << registers[
a.get()] <<
";" << std::endl;
1889 template<jit::complex_scalar T,
bool SAFE_MATH=false>
1891 auto temp = std::make_shared<erfi_node<T, SAFE_MATH>> (x)->reduce();
1893 for (
size_t i =
temp->get_hash();
1903#if defined(__clang__) || defined(__GNUC__)
1906 assert(
false &&
"Should never reach.");
1911 template<jit::complex_scalar T,
bool SAFE_MATH=false>
1923 template<jit::complex_scalar T,
bool SAFE_MATH=false>
1925 return std::dynamic_pointer_cast<erfi_node<T, SAFE_MATH>> (x);
1939 template<std::
floating_po
int T,
bool SAFE_MATH=false>
1989 if (
rc.get() &&
rc->is(0)) {
1991 }
else if (
lc.get() &&
lc->is(0)) {
1993 }
else if (
rc.get() &&
lc.get()) {
1999 if (
pl1.get() && (
rc.get() ||
pl1->is_arg_match(
this->right))) {
2001 }
else if (
pr1.get() && (
lc.get() ||
pr1->is_arg_match(
this->left))) {
2007 if (
pl2.get() && (
rc.get() ||
pl2->is_arg_match(
this->right))) {
2009 pl2->get_num_columns(),
2012 }
else if (
pr2.get() && (
lc.get() ||
pr2->is_arg_match(
this->left))) {
2014 pr2->get_num_columns(),
2020 if (
pr2.get() &&
pr2->is_row_match(
this->left)) {
2024 pr2->get_num_columns(),
2027 }
else if (
pr2.get() &&
pr2->is_col_match(
this->left)) {
2031 pr2->get_num_columns(),
2034 }
else if (
pl2.get() &&
pl2->is_row_match(
this->right)) {
2038 pl2->get_num_columns(),
2041 }
else if (
pl2.get() &&
pl2->is_col_match(
this->right)) {
2045 pl2->get_num_columns(),
2055 if (
sql.get() &&
sqr.get()) {
2056 return sqrt(
sql->get_arg() +
sqr->get_arg());
2057 }
else if (
sql.get()) {
2059 static_cast<T
> (2)));
2060 }
else if (
sqr.get()) {
2062 static_cast<T
> (2)));
2066 if (this->
left->is_match(
this->right)) {
2067 return std::numbers::sqrt2_v<T>*
sqrt(
pow(this->
left,
2068 static_cast<T
> (2)));
2088 const size_t hash =
reinterpret_cast<size_t> (x.get());
2111 if (registers.find(
this) == registers.end()) {
2114 auto r = this->
right->compile(stream, registers,
2118 stream <<
" const ";
2119 jit::add_type<T> (stream);
2120 stream <<
" " << registers[
this] <<
" = ";
2121 if constexpr (jit::use_metal<T> ()) {
2122 stream <<
"length({";
2126 stream << registers[l.get()] <<
", " << registers[
r.get()];
2127 if constexpr (jit::use_metal<T> ()) {
2146 if (
this == x.get()) {
2153 return (this->
left->is_match(
x_cast->get_left()) &&
2154 this->right->is_match(
x_cast->get_right())) ||
2166 std::cout <<
"hypot\\left(";
2167 this->
left->to_latex();
2169 this->
right->to_latex();
2170 std::cout <<
"\\right)";
2180 return hypot(this->
left->remove_pseudo(),
2181 this->right->remove_pseudo());
2195 if (registers.find(
this) == registers.end()) {
2197 registers[
this] =
name;
2198 stream <<
" " <<
name
2199 <<
" [label = \"hypot\", shape = oval, style = filled, fillcolor = blue, fontcolor = white];" << std::endl;
2202 stream <<
" " <<
name <<
" -- " << registers[l.get()] <<
";" << std::endl;
2203 auto r = this->
right->to_vizgraph(stream, registers);
2204 stream <<
" " <<
name <<
" -- " << registers[
r.get()] <<
";" << std::endl;
2221 template<std::
floating_po
int T,
bool SAFE_MATH=false>
2224 auto temp = std::make_shared<hypot_node<T, SAFE_MATH>> (l,
r)->reduce();
2235#if defined(__clang__) || defined(__GNUC__)
2238 assert(
false &&
"Should never reach.");
2253 template<std::
floating_po
int T, jit::
float_scalar L,
bool SAFE_MATH=false>
2270 template<std::
floating_po
int T, jit::
float_scalar R,
bool SAFE_MATH=false>
2277 template<std::
floating_po
int T,
bool SAFE_MATH=false>
2286 template<std::
floating_po
int T,
bool SAFE_MATH=false>
2288 return std::dynamic_pointer_cast<hypot_node<T, SAFE_MATH>> (x);
2302 template<std::
floating_po
int T,
bool SAFE_MATH=false>
2304 branch_node<T, SAFE_MATH>> {
2355 if (
rc.get() &&
rc->is(0)) {
2356 return sqrt(
pow(this->left,
static_cast<T
> (2)));
2357 }
else if (
lc.get() &&
lc->is(0)) {
2358 return sqrt(
pow(this->right,
static_cast<T
> (2)));
2359 }
else if (
rc.get() &&
lc.get()) {
2365 if (
pl1.get() && (
rc.get() ||
pl1->is_arg_match(
this->right))) {
2367 }
else if (
pr1.get() && (
lc.get() ||
pr1->is_arg_match(
this->left))) {
2373 if (
pl2.get() && (
rc.get() ||
pl2->is_arg_match(
this->right))) {
2375 pl2->get_num_columns(),
2378 }
else if (
pr2.get() && (
lc.get() ||
pr2->is_arg_match(
this->left))) {
2380 pr2->get_num_columns(),
2386 if (
pr2.get() &&
pr2->is_row_match(
this->left)) {
2390 pr2->get_num_columns(),
2393 }
else if (
pr2.get() &&
pr2->is_col_match(
this->left)) {
2397 pr2->get_num_columns(),
2400 }
else if (
pl2.get() &&
pl2->is_row_match(
this->right)) {
2404 pl2->get_num_columns(),
2407 }
else if (
pl2.get() &&
pl2->is_col_match(
this->right)) {
2411 pl2->get_num_columns(),
2433 if (registers.find(
this) == registers.end()) {
2434 auto l = this->left->
compile(stream, registers,
2436 auto r = this->right->compile(stream, registers,
2440 stream <<
" const ";
2441 jit::add_type<T> (stream);
2442 stream <<
" " << registers[
this] <<
" = copysign("
2443 << registers[l.get()] <<
", "
2444 << registers[
r.get()] <<
")";
2459 if (
this == x.get()) {
2465 return (this->left->is_match(
x_cast->get_left()) &&
2476 std::cout <<
"copysign\\left(";
2477 this->left->to_latex();
2479 this->right->to_latex();
2480 std::cout <<
"\\right)";
2490 return copysign(this->left->remove_pseudo(),
2491 this->right->remove_pseudo());
2505 if (registers.find(
this) == registers.end()) {
2507 registers[
this] =
name;
2508 stream <<
" " <<
name
2509 <<
" [label = \"copysign\", shape = oval, style = filled, fillcolor = blue, fontcolor = white];" << std::endl;
2511 auto l = this->left->
to_vizgraph(stream, registers);
2512 stream <<
" " <<
name <<
" -- " << registers[l.get()] <<
";" << std::endl;
2513 auto r = this->right->to_vizgraph(stream, registers);
2514 stream <<
" " <<
name <<
" -- " << registers[
r.get()] <<
";" << std::endl;
2531 template<std::
floating_po
int T,
bool SAFE_MATH=false>
2534 auto temp = std::make_shared<copysign_node<T, SAFE_MATH>> (l,
r)->reduce();
2545#if defined(__clang__) || defined(__GNUC__)
2548 assert(
false &&
"Should never reach.");
2563 template<std::
floating_po
int T, jit::
float_scalar L,
bool SAFE_MATH=false>
2580 template<std::
floating_po
int T, jit::
float_scalar R,
bool SAFE_MATH=false>
2587 template<std::
floating_po
int T,
bool SAFE_MATH=false>
2596 template<std::
floating_po
int T,
bool SAFE_MATH=false>
2598 return std::dynamic_pointer_cast<copysign_node<T, SAFE_MATH>> (x);
Class representing a generic buffer.
Definition backend.hpp:29
void erfi()
Take erfi.
Definition backend.hpp:258
void copysign_col(const buffer< T > &x)
copysign col operation.
Definition backend.hpp:841
void log()
Take log.
Definition backend.hpp:223
void sqrt()
Take sqrt.
Definition backend.hpp:209
void hypot_row(const buffer< T > &x)
Hypot row operation.
Definition backend.hpp:733
void pow_col(const buffer< T > &x)
Pow col operation.
Definition backend.hpp:697
void erf()
Take erf.
Definition backend.hpp:251
void pow_row(const buffer< T > &x)
Pow row operation.
Definition backend.hpp:661
void copysign_row(const buffer< T > &x)
copysign row operation.
Definition backend.hpp:805
void hypot_col(const buffer< T > &x)
Hypot col operation.
Definition backend.hpp:769
void exp()
Take exp.
Definition backend.hpp:216
Class representing a branch node.
Definition node.hpp:1337
shared_leaf< T, SAFE_MATH > right
Right branch of the tree.
Definition node.hpp:1342
shared_leaf< T, SAFE_MATH > left
Left branch of the tree.
Definition node.hpp:1340
A copysign node.
Definition math.hpp:2304
virtual bool is_match(shared_leaf< T, SAFE_MATH > x)
Query if the nodes match.
Definition math.hpp:2458
virtual backend::buffer< T > evaluate()
Evaluate the results of copysign.
Definition math.hpp:2340
virtual shared_leaf< T, SAFE_MATH > remove_pseudo()
Remove pseudo variable nodes.
Definition math.hpp:2488
virtual shared_leaf< T, SAFE_MATH > compile(std::ostringstream &stream, jit::register_map ®isters, const jit::register_map &thread_mem, const jit::register_usage &usage)
Compile the node.
Definition math.hpp:2429
virtual void to_latex() const
Convert the node to latex.
Definition math.hpp:2475
virtual shared_leaf< T, SAFE_MATH > to_vizgraph(std::stringstream &stream, jit::register_map ®isters)
Convert the node to vizgraph.
Definition math.hpp:2503
virtual shared_leaf< T, SAFE_MATH > reduce()
Reduce a copysign node.
Definition math.hpp:2351
copysign_node(shared_leaf< T, SAFE_MATH > l, shared_leaf< T, SAFE_MATH > r)
Construct a hypot node.
Definition math.hpp:2326
An error function node.
Definition math.hpp:1464
virtual backend::buffer< T > evaluate()
Evaluate the results of erf.
Definition math.hpp:1492
virtual shared_leaf< T, SAFE_MATH > to_vizgraph(std::stringstream &stream, jit::register_map ®isters)
Convert the node to vizgraph.
Definition math.hpp:1623
virtual void to_latex() const
Convert the node to latex.
Definition math.hpp:1598
virtual shared_leaf< T, SAFE_MATH > reduce()
Reduce the erf(x).
Definition math.hpp:1503
virtual shared_leaf< T, SAFE_MATH > remove_pseudo()
Remove pseudo variable nodes.
Definition math.hpp:1609
virtual bool is_match(shared_leaf< T, SAFE_MATH > x)
Query if the nodes match.
Definition math.hpp:1582
erf_node(shared_leaf< T, SAFE_MATH > x)
Construct a erf node.
Definition math.hpp:1482
virtual shared_leaf< T, SAFE_MATH > df(shared_leaf< T, SAFE_MATH > x)
Transform node to derivative.
Definition math.hpp:1533
virtual shared_leaf< T, SAFE_MATH > compile(std::ostringstream &stream, jit::register_map ®isters, const jit::register_map &thread_mem, const jit::register_usage &usage)
Compile the node.
Definition math.hpp:1557
An imaginary error function node.
Definition math.hpp:1699
virtual shared_leaf< T, SAFE_MATH > compile(std::ostringstream &stream, jit::register_map ®isters, const jit::register_map &thread_mem, const jit::register_usage &usage)
Compile the node.
Definition math.hpp:1798
erfi_node(shared_leaf< T, SAFE_MATH > x)
Construct a erfi node.
Definition math.hpp:1717
virtual shared_leaf< T, SAFE_MATH > reduce()
Reduce the erfi(x).
Definition math.hpp:1738
virtual void to_latex() const
Convert the node to latex.
Definition math.hpp:1839
virtual shared_leaf< T, SAFE_MATH > remove_pseudo()
Remove pseudo variable nodes.
Definition math.hpp:1850
virtual shared_leaf< T, SAFE_MATH > df(shared_leaf< T, SAFE_MATH > x)
Transform node to derivative.
Definition math.hpp:1768
virtual bool is_match(shared_leaf< T, SAFE_MATH > x)
Query if the nodes match.
Definition math.hpp:1823
virtual backend::buffer< T > evaluate()
Evaluate the results of erfi.
Definition math.hpp:1727
virtual shared_leaf< T, SAFE_MATH > to_vizgraph(std::stringstream &stream, jit::register_map ®isters)
Convert the node to vizgraph.
Definition math.hpp:1864
A exp node.
Definition math.hpp:347
virtual backend::buffer< T > evaluate()
Evaluate the results of exp.
Definition math.hpp:375
virtual shared_leaf< T, SAFE_MATH > df(shared_leaf< T, SAFE_MATH > x)
Transform node to derivative.
Definition math.hpp:422
virtual bool is_match(shared_leaf< T, SAFE_MATH > x)
Query if the nodes match.
Definition math.hpp:491
virtual shared_leaf< T, SAFE_MATH > remove_pseudo()
Remove pseudo variable nodes.
Definition math.hpp:518
exp_node(shared_leaf< T, SAFE_MATH > x)
Construct a exp node.
Definition math.hpp:365
virtual shared_leaf< T, SAFE_MATH > compile(std::ostringstream &stream, jit::register_map ®isters, const jit::register_map &thread_mem, const jit::register_usage &usage)
Compile the node.
Definition math.hpp:444
virtual void to_latex() const
Convert the node to latex.
Definition math.hpp:507
virtual shared_leaf< T, SAFE_MATH > reduce()
Reduce the exp(x).
Definition math.hpp:386
virtual shared_leaf< T, SAFE_MATH > to_vizgraph(std::stringstream &stream, jit::register_map ®isters)
Convert the node to vizgraph.
Definition math.hpp:532
A hypot node.
Definition math.hpp:1940
virtual bool is_match(shared_leaf< T, SAFE_MATH > x)
Query if the nodes match.
Definition math.hpp:2145
virtual shared_leaf< T, SAFE_MATH > df(shared_leaf< T, SAFE_MATH > x)
Transform node to derivative.
Definition math.hpp:2083
virtual void to_latex() const
Convert the node to latex.
Definition math.hpp:2165
virtual shared_leaf< T, SAFE_MATH > reduce()
Reduce a hypot node.
Definition math.hpp:1985
virtual shared_leaf< T, SAFE_MATH > compile(std::ostringstream &stream, jit::register_map ®isters, const jit::register_map &thread_mem, const jit::register_usage &usage)
Compile the node.
Definition math.hpp:2107
hypot_node(shared_leaf< T, SAFE_MATH > l, shared_leaf< T, SAFE_MATH > r)
Construct a hypot node.
Definition math.hpp:1962
virtual shared_leaf< T, SAFE_MATH > to_vizgraph(std::stringstream &stream, jit::register_map ®isters)
Convert the node to vizgraph.
Definition math.hpp:2193
virtual shared_leaf< T, SAFE_MATH > remove_pseudo()
Remove pseudo variable nodes.
Definition math.hpp:2178
virtual backend::buffer< T > evaluate()
Evaluate the results of hypot.
Definition math.hpp:1974
Class representing a node leaf.
Definition node.hpp:371
virtual std::shared_ptr< leaf_node< T, SAFE_MATH > > compile(std::ostringstream &stream, jit::register_map ®isters, const jit::register_map &thread_mem, const jit::register_usage &usage)=0
Compile the node.
virtual void endline(std::ostringstream &stream, const jit::register_usage &usage, const char end=';') const
End a line in the kernel source.
Definition node.hpp:653
virtual std::shared_ptr< leaf_node< T, SAFE_MATH > > to_vizgraph(std::stringstream &stream, jit::register_map ®isters)=0
Convert the node to vizgraph.
virtual bool has_pseudo() const
Query if the node contains pseudo variables.
Definition node.hpp:633
const size_t hash
Hash for node.
Definition node.hpp:374
std::unordered_map< size_t, std::shared_ptr< leaf_node< T, SAFE_MATH > > > df_cache
Cache derivative terms.
Definition node.hpp:378
A log node.
Definition math.hpp:608
virtual shared_leaf< T, SAFE_MATH > compile(std::ostringstream &stream, jit::register_map ®isters, const jit::register_map &thread_mem, const jit::register_usage &usage)
Compile the node.
Definition math.hpp:705
virtual shared_leaf< T, SAFE_MATH > to_vizgraph(std::stringstream &stream, jit::register_map ®isters)
Convert the node to vizgraph.
Definition math.hpp:771
virtual shared_leaf< T, SAFE_MATH > df(shared_leaf< T, SAFE_MATH > x)
Transform node to derivative.
Definition math.hpp:683
virtual backend::buffer< T > evaluate()
Evaluate the results of log.
Definition math.hpp:636
virtual bool is_match(shared_leaf< T, SAFE_MATH > x)
Query if the nodes match.
Definition math.hpp:730
virtual shared_leaf< T, SAFE_MATH > reduce()
Reduce the log(x).
Definition math.hpp:647
virtual void to_latex() const
Convert the node to latex.
Definition math.hpp:746
log_node(shared_leaf< T, SAFE_MATH > x)
Construct a log node.
Definition math.hpp:626
virtual shared_leaf< T, SAFE_MATH > remove_pseudo()
Remove pseudo variable nodes.
Definition math.hpp:757
Nodes without derivatives.
Definition node.hpp:1713
An power node.
Definition math.hpp:846
virtual shared_leaf< T, SAFE_MATH > to_vizgraph(std::stringstream &stream, jit::register_map ®isters)
Convert the node to vizgraph.
Definition math.hpp:1305
virtual bool is_all_variables() const
Test if node acts like a variable.
Definition math.hpp:1327
virtual shared_leaf< T, SAFE_MATH > get_power_base()
Get the base of a power.
Definition math.hpp:1347
virtual shared_leaf< T, SAFE_MATH > compile(std::ostringstream &stream, jit::register_map ®isters, const jit::register_map &thread_mem, const jit::register_usage &usage)
Compile the node.
Definition math.hpp:1224
virtual backend::buffer< T > evaluate()
Evaluate the results of pow.
Definition math.hpp:880
pow_node(shared_leaf< T, SAFE_MATH > l, shared_leaf< T, SAFE_MATH > r)
Construct a power node.
Definition math.hpp:868
virtual bool is_power_like() const
Test if the node acts like a power of variable.
Definition math.hpp:1338
virtual shared_leaf< T, SAFE_MATH > remove_pseudo()
Remove pseudo variable nodes.
Definition math.hpp:1365
virtual bool is_match(shared_leaf< T, SAFE_MATH > x)
Query if the nodes match.
Definition math.hpp:1265
virtual shared_leaf< T, SAFE_MATH > get_power_exponent() const
Get the exponent of a power.
Definition math.hpp:1356
virtual void to_latex() const
Convert the node to latex.
Definition math.hpp:1282
virtual shared_leaf< T, SAFE_MATH > reduce()
Reduce a power node.
Definition math.hpp:891
virtual shared_leaf< T, SAFE_MATH > df(shared_leaf< T, SAFE_MATH > x)
Transform node to derivative.
Definition math.hpp:1200
A sqrt node.
Definition math.hpp:27
virtual shared_leaf< T, SAFE_MATH > get_power_exponent() const
Get the exponent of a power.
Definition math.hpp:248
virtual shared_leaf< T, SAFE_MATH > compile(std::ostringstream &stream, jit::register_map ®isters, const jit::register_map &thread_mem, const jit::register_usage &usage)
Compile the node.
Definition math.hpp:178
virtual backend::buffer< T > evaluate()
Evaluate the results of sqrt.
Definition math.hpp:55
virtual shared_leaf< T, SAFE_MATH > reduce()
Reduce the sqrt(x).
Definition math.hpp:66
sqrt_node(shared_leaf< T, SAFE_MATH > x)
Construct a sqrt node.
Definition math.hpp:45
virtual bool is_power_like() const
Test if the node acts like a power of variable.
Definition math.hpp:230
virtual bool is_match(shared_leaf< T, SAFE_MATH > x)
Query if the nodes match.
Definition math.hpp:203
virtual shared_leaf< T, SAFE_MATH > remove_pseudo()
Remove pseudo variable nodes.
Definition math.hpp:257
virtual shared_leaf< T, SAFE_MATH > df(shared_leaf< T, SAFE_MATH > x)
Transform node to derivative.
Definition math.hpp:155
virtual shared_leaf< T, SAFE_MATH > to_vizgraph(std::stringstream &stream, jit::register_map ®isters)
Convert the node to vizgraph.
Definition math.hpp:271
virtual void to_latex() const
Convert the node to latex.
Definition math.hpp:219
virtual shared_leaf< T, SAFE_MATH > get_power_base()
Get the base of a power.
Definition math.hpp:239
Class representing a straight node.
Definition node.hpp:1219
shared_leaf< T, SAFE_MATH > arg
Argument.
Definition node.hpp:1222
Complex scalar concept.
Definition register.hpp:25
subroutine assert(test, message)
Assert check.
Definition f_binding_test.f90:38
buffer< T > pow(buffer< T > &base, buffer< T > &exponent)
Take the power.
Definition backend.hpp:1537
buffer< T > copysign(buffer< T > &x, buffer< T > &y)
Copy the sign of x and apply it to y.
Definition backend.hpp:1654
buffer< T > hypot(buffer< T > &a, buffer< T > &b)
hypot operation.
Definition backend.hpp:1204
Name space for graph nodes.
Definition arithmetic.hpp:13
shared_piecewise_2D< T, SAFE_MATH > piecewise_2D_cast(shared_leaf< T, SAFE_MATH > x)
Cast to a piecewise 2D node.
Definition piecewise.hpp:1508
shared_leaf< T, SAFE_MATH > log(shared_leaf< T, SAFE_MATH > x)
Define log convenience function.
Definition math.hpp:797
shared_pow< T, SAFE_MATH > pow_cast(shared_leaf< T, SAFE_MATH > x)
Cast to a power node.
Definition math.hpp:1448
constexpr shared_leaf< T, SAFE_MATH > zero()
Forward declare for zero.
Definition node.hpp:1154
shared_sqrt< T, SAFE_MATH > sqrt_cast(shared_leaf< T, SAFE_MATH > x)
Cast to a sqrt node.
Definition math.hpp:331
std::shared_ptr< erf_node< T, SAFE_MATH > > shared_erf
Convenience type alias for shared erf nodes.
Definition math.hpp:1671
shared_leaf< T, SAFE_MATH > pow(shared_leaf< T, SAFE_MATH > l, shared_leaf< T, SAFE_MATH > r)
Build power node.
Definition math.hpp:1384
shared_divide< T, SAFE_MATH > divide_cast(shared_leaf< T, SAFE_MATH > x)
Cast to a divide node.
Definition arithmetic.hpp:3802
std::shared_ptr< erfi_node< T, SAFE_MATH > > shared_erfi
Convenience type alias for shared erfi nodes.
Definition math.hpp:1912
shared_piecewise_1D< T, SAFE_MATH > piecewise_1D_cast(shared_leaf< T, SAFE_MATH > x)
Cast to a piecewise 1D node.
Definition piecewise.hpp:849
shared_multiply< T, SAFE_MATH > multiply_cast(shared_leaf< T, SAFE_MATH > x)
Cast to a multiply node.
Definition arithmetic.hpp:2843
std::shared_ptr< hypot_node< T, SAFE_MATH > > shared_hypot
Convenience type alias for shared hypot nodes.
Definition math.hpp:2278
shared_leaf< T, SAFE_MATH > erf(shared_leaf< T, SAFE_MATH > x)
Define erf convenience function.
Definition math.hpp:1649
shared_leaf< T, SAFE_MATH > exp(shared_leaf< T, SAFE_MATH > x)
Define exp convenience function.
Definition math.hpp:558
shared_leaf< T, SAFE_MATH > copysign(shared_leaf< T, SAFE_MATH > l, shared_leaf< T, SAFE_MATH > r)
Build copysign node.
Definition math.hpp:2532
shared_exp< T, SAFE_MATH > exp_cast(shared_leaf< T, SAFE_MATH > x)
Cast to a exp node.
Definition math.hpp:592
shared_constant< T, SAFE_MATH > constant_cast(shared_leaf< T, SAFE_MATH > x)
Cast to a constant node.
Definition node.hpp:1202
shared_leaf< T, SAFE_MATH > erfi(shared_leaf< T, SAFE_MATH > x)
Define erfi convenience function.
Definition math.hpp:1890
bool is_variable_combinable(shared_leaf< T, SAFE_MATH > a, shared_leaf< T, SAFE_MATH > b)
Check if the variable is combinable.
Definition arithmetic.hpp:75
shared_variable< T, SAFE_MATH > variable_cast(shared_leaf< T, SAFE_MATH > x)
Cast to a variable node.
Definition node.hpp:2169
shared_erf< T, SAFE_MATH > erf_cast(shared_leaf< T, SAFE_MATH > x)
Cast to a erf node.
Definition math.hpp:1683
constexpr T i
Convenience type for imaginary constant.
Definition node.hpp:1186
std::shared_ptr< copysign_node< T, SAFE_MATH > > shared_copysign
Convenience type alias for shared copysign nodes.
Definition math.hpp:2588
shared_erfi< T, SAFE_MATH > erfi_cast(shared_leaf< T, SAFE_MATH > x)
Cast to a erfi node.
Definition math.hpp:1924
shared_leaf< T, SAFE_MATH > sqrt(shared_leaf< T, SAFE_MATH > x)
Define sqrt convenience function.
Definition math.hpp:297
std::shared_ptr< exp_node< T, SAFE_MATH > > shared_exp
Convenience type alias for shared exp nodes.
Definition math.hpp:580
shared_log< T, SAFE_MATH > log_cast(shared_leaf< T, SAFE_MATH > x)
Cast to a exp node.
Definition math.hpp:830
std::shared_ptr< leaf_node< T, SAFE_MATH > > shared_leaf
Convenience type alias for shared leaf nodes.
Definition node.hpp:691
shared_hypot< T, SAFE_MATH > hypot_cast(shared_leaf< T, SAFE_MATH > x)
Cast to a hypot node.
Definition math.hpp:2287
std::shared_ptr< log_node< T, SAFE_MATH > > shared_log
Convenience type alias for shared log nodes.
Definition math.hpp:818
shared_leaf< T, SAFE_MATH > hypot(shared_leaf< T, SAFE_MATH > l, shared_leaf< T, SAFE_MATH > r)
Build hypot node.
Definition math.hpp:2222
std::shared_ptr< pow_node< T, SAFE_MATH > > shared_pow
Convenience type alias for shared add nodes.
Definition math.hpp:1439
std::shared_ptr< sqrt_node< T, SAFE_MATH > > shared_sqrt
Convenience type alias for shared sqrt nodes.
Definition math.hpp:319
shared_copysign< T, SAFE_MATH > copysign_cast(shared_leaf< T, SAFE_MATH > x)
Cast to a copysign node.
Definition math.hpp:2597
std::string format_to_string(const T value)
Convert a value to a string while avoiding locale.
Definition register.hpp:213
std::unordered_map< void *, size_t > register_usage
Type alias for counting register usage.
Definition register.hpp:261
std::unordered_map< void *, std::string > register_map
Type alias for mapping node pointers to register names.
Definition register.hpp:259
std::string to_string(const char prefix, const NODE *pointer)
Convert a graph::leaf_node pointer to a string.
Definition register.hpp:247
Base nodes of graph computation framework.
void piecewise_1D()
Tests for 1D piecewise nodes.
Definition piecewise_test.cpp:82
void piecewise_2D()
Tests for 2D piecewise nodes.
Definition piecewise_test.cpp:321