25template<jit::
float_scalar T>
31 const std::string type = jit::type_to_string<T> ();
32 stream <<
"(" << jit::smallest_uint_type<T> (length) <<
")min";
33 if constexpr (!jit::use_metal<T> ()) {
34 stream <<
"<" << type <<
">";
37 if constexpr (!jit::use_metal<T> ()) {
38 stream <<
"<" << type <<
">";
48 stream << offset <<
")/";
57 if constexpr (jit::use_metal<T> ()) {
58 stream <<
"(" << type <<
")";
61 if constexpr (jit::use_metal<T> ()) {
62 stream <<
"(" << type <<
")";
64 stream << length - 1 <<
")";
104 template<jit::
float_scalar T,
bool SAFE_MATH=false>
120 for (
size_t i = 0,
ie =
d.size();
i <
ie;
i++) {
140 return piecewise_1D_node::to_string(
d) +
153 const size_t h = std::hash<std::string>{} (piecewise_1D_node::to_string(
d));
163#if defined(__clang__) || defined(__GNUC__)
166 assert(
false &&
"Should never reach.");
171 const size_t data_hash;
215 const T
arg = (this->arg->evaluate().at(0) + offset)/scale;
217 const size_t i = std::max<float> (std::min<float> (std::real(
arg),
222 const size_t i = std::max<double> (std::min<double> (std::real(
arg),
264 this->
arg->compile_preamble(stream, registers,
272 if constexpr (jit::use_metal<T> ()) {
275#ifdef USE_CUDA_TEXTURES
285 stream <<
"__constant__ ";
289 jit::add_type<T> (stream);
292 jit::add_type<T> (stream);
295 for (
size_t i = 1;
i < length;
i++) {
298 jit::add_type<T> (stream);
302 stream <<
"};" << std::endl;
308 if constexpr (jit::use_metal<T> ()) {
311#ifdef USE_CUDA_TEXTURES
353 if (registers.find(
this) == registers.end()) {
354#ifdef USE_INDEX_CACHE
362#ifdef USE_INDEX_CACHE
365 << jit::smallest_uint_type<T> (length) <<
" "
369 a->endline(stream,
usage);
375 jit::add_type<T> (stream);
376 stream <<
" " << registers[
this] <<
" = ";
377#ifdef USE_CUDA_TEXTURES
381 stream <<
"to_cmp_float(tex1D<float2> (";
383 stream <<
"tex1D<float> (";
387 stream <<
"to_cmp_double(tex1D<uint4> (";
389 stream <<
"to_double(tex1D<uint2> (";
395 if constexpr (jit::use_metal<T> ()) {
396#ifdef USE_INDEX_CACHE
406#ifdef USE_CUDA_TEXTURES
408#ifdef USE_INDEX_CACHE
422#ifdef USE_INDEX_CACHE
452 return this->data_hash ==
x_cast->data_hash &&
463 std::cout <<
"r\\_" <<
reinterpret_cast<size_t> (
this) <<
"_{i}";
475 if (registers.find(
this) == registers.end()) {
477 registers[
this] =
name;
478 stream <<
" " <<
name
479 <<
" [label = \"r_" <<
reinterpret_cast<size_t> (
this)
480 <<
"_{i}\", shape = hexagon, style = filled, fillcolor = black, fontcolor = white];" << std::endl;
482 auto a = this->
arg->to_vizgraph(stream, registers);
483 stream <<
" " <<
name <<
" -- " << registers[
a.get()] <<
";" << std::endl;
552 this->
arg->is_match(
temp->get_arg()) &&
554 (
temp->get_scale() == this->scale) &&
555 (
temp->get_offset() == this->offset);
598 template<jit::
float_scalar T,
bool SAFE_MATH=false>
603 auto temp = std::make_shared<piecewise_1D_node<T, SAFE_MATH>> (
d, x,
616#if defined(__clang__) || defined(__GNUC__)
619 assert(
false &&
"Should never reach.");
624 template<jit::
float_scalar T,
bool SAFE_MATH=false>
636 template<jit::
float_scalar T,
bool SAFE_MATH=false>
638 return std::dynamic_pointer_cast<piecewise_1D_node<T, SAFE_MATH>> (x);
685 template<jit::
float_scalar T,
bool SAFE_MATH=false>
705 for (
size_t i = 0,
ie =
d.size();
i <
ie;
i++) {
731 return piecewise_2D_node::to_string(
d) +
747 const size_t h = std::hash<std::string>{} (piecewise_2D_node::to_string(
d));
757#if defined(__clang__) || defined(__GNUC__)
760 assert(
false &&
"Should never reach.");
765 const size_t data_hash;
767 const size_t num_columns;
792 x, x_scale, x_offset,
793 y, y_scale, y_offset)),
795 num_columns(
n), x_scale(x_scale), x_offset(x_offset), y_scale(y_scale),
798 "Expected the data buffer to be a multiple of the number of columns.");
880 const T
l = (this->
left->evaluate().at(0) + x_offset)/x_scale;
881 const T
r = (this->
right->evaluate().at(0) + y_offset)/y_scale;
884 const size_t i = std::max<float> (std::min<float> (std::real(
l),
887 const size_t j = std::max<float> (std::min<float> (std::real(
r),
892 const size_t i = std::max<double> (std::min<double> (std::real(
l),
895 const size_t j = std::max<double> (std::min<double> (std::real(
r),
901 const T
l = (this->
left->evaluate().at(0) + x_offset)/x_scale;
904 const size_t i = std::max<float> (std::min<float> (std::real(
l),
908 this->
right, y_scale, y_offset);
910 const size_t i = std::max<double> (std::min<double> (std::real(
l),
914 this->
right, y_scale, y_offset);
917 const T
r = (this->
right->evaluate().at(0) + y_offset)/y_scale;
920 const size_t j = std::max<float> (std::min<float> (std::real(
r),
924 this->
left, x_scale, x_offset);
926 const size_t j = std::max<double> (std::min<double> (std::real(
r),
930 this->
left, x_scale, x_offset);
970 this->
left->compile_preamble(stream, registers,
974 this->
right->compile_preamble(stream, registers,
982 if constexpr (jit::use_metal<T> ()) {
984 std::array<size_t, 2> ({length/num_columns, num_columns}));
985#ifdef USE_CUDA_TEXTURES
988 std::array<size_t, 2> ({length/num_columns, num_columns}));
995 stream <<
"__constant__ ";
999 jit::add_type<T> (stream);
1002 jit::add_type<T> (stream);
1005 for (
size_t i = 1;
i < length;
i++) {
1008 jit::add_type<T> (stream);
1012 stream <<
"};" << std::endl;
1018 if constexpr (jit::use_metal<T> ()) {
1020 std::array<size_t, 2> ({length/num_columns, num_columns}));
1021#ifdef USE_CUDA_TEXTURES
1024 std::array<size_t, 2> ({length/num_columns, num_columns}));
1029#ifdef SHOW_USE_COUNT
1076 if (registers.find(
this) == registers.end()) {
1078 const size_t num_rows = length/num_columns;
1089#ifdef USE_INDEX_CACHE
1093 << jit::smallest_uint_type<T> (
num_rows) <<
" "
1097 x->endline(stream,
usage);
1102 << jit::smallest_uint_type<T> (num_columns) <<
" "
1106 y->endline(stream,
usage);
1110 if constexpr (!jit::use_metal<T> ()
1111#ifdef USE_CUDA_TEXTURES
1118 << jit::smallest_uint_type<T> (length) <<
" "
1121 <<
"*" << num_columns <<
" + "
1123 <<
";" << std::endl;
1129 stream <<
" const ";
1130 jit::add_type<T> (stream);
1131 stream <<
" " << registers[
this] <<
" = ";
1132#ifdef USE_CUDA_TEXTURES
1136 stream <<
"to_cmp_float(tex1D<float2> (";
1138 stream <<
"tex1D<float> (";
1142 stream <<
"to_cmp_double(tex1D<uint4> (";
1144 stream <<
"to_double(tex1D<uint2> (";
1150 if constexpr (jit::use_metal<T> ()) {
1151#ifdef USE_INDEX_CACHE
1153 << jit::smallest_uint_type<T> (std::max(
num_rows,
1161 stream <<
".read(uint2(";
1169#ifdef USE_CUDA_TEXTURES
1171#ifdef USE_INDEX_CACHE
1190#ifdef USE_INDEX_CACHE
1198 stream <<
"*" << num_columns <<
" + ";
1222 return this->data_hash ==
x_cast->data_hash &&
1235 std::cout <<
"r\\_" <<
reinterpret_cast<size_t> (
this) <<
"_{ij}";
1247 if (registers.find(
this) == registers.end()) {
1249 registers[
this] =
name;
1250 stream <<
" " <<
name
1251 <<
" [label = \"r_" <<
reinterpret_cast<size_t> (
this)
1252 <<
"_{ij}\", shape = hexagon, style = filled, fillcolor = black, fontcolor = white];" << std::endl;
1254 auto l = this->
left->to_vizgraph(stream, registers);
1255 stream <<
" " <<
name <<
" -- " << registers[
l.get()] <<
";" << std::endl;
1256 auto r = this->
right->to_vizgraph(stream, registers);
1257 stream <<
" " <<
name <<
" -- " << registers[
r.get()] <<
";" << std::endl;
1325 return temp.get() &&
1326 this->
left->is_match(
temp->get_left()) &&
1327 this->
right->is_match(
temp->get_right()) &&
1330 (
temp->get_x_scale() == this->x_scale) &&
1331 (
temp->get_x_offset() == this->x_offset) &&
1332 (
temp->get_y_scale() == this->y_scale) &&
1333 (
temp->get_y_offset() == this->y_offset);
1344 return temp.get() &&
1345 this->
left->is_match(
temp->get_arg()) &&
1347 (
temp->get_scale() == this->x_scale) &&
1348 (
temp->get_offset() == this->x_offset);
1361 return temp.get() &&
1362 this->
right->is_match(
temp->get_arg()) &&
1364 (
temp->get_scale() == this->y_scale) &&
1365 (
temp->get_offset() == this->y_offset);
1385 template<jit::
float_scalar T,
bool SAFE_MATH=false>
1394 auto temp = std::make_shared<piecewise_2D_node<T, SAFE_MATH>> (
d,
n,
1395 x, x_scale, x_offset,
1396 y, y_scale, y_offset)->reduce();
1407#if defined(__clang__) || defined(__GNUC__)
1410 assert(
false &&
"Should never reach.");
1415 template<jit::
float_scalar T,
bool SAFE_MATH=false>
1427 template<jit::
float_scalar T,
bool SAFE_MATH=false>
1429 return std::dynamic_pointer_cast<piecewise_2D_node<T, SAFE_MATH>> (x);
1447 template<jit::
float_scalar T,
bool SAFE_MATH=false>
1490 scale(scale), offset(offset) {}
1502 return this->
right->evaluate();
1534 if (registers.find(
this) == registers.end()) {
1535#ifdef USE_INDEX_CACHE
1543#ifdef USE_INDEX_CACHE
1546 << jit::smallest_uint_type<T> (length) <<
" "
1550 a->endline(stream,
usage);
1555 stream <<
" const ";
1556 jit::add_type<T> (stream);
1557 auto var = this->
left->compile(stream,
1561 stream <<
" " << registers[
this] <<
" = "
1563#ifdef USE_INDEX_CACHE
1589 return this->
left->is_match(
x_cast->get_left()) &&
1600 std::cout <<
"r\\_" <<
reinterpret_cast<size_t> (this->
left.get())
1602 <<
reinterpret_cast<size_t> (this->
right.get())
1615 if (registers.find(
this) == registers.end()) {
1617 registers[
this] =
name;
1618 stream <<
" " <<
name
1619 <<
" [label = \"r_" <<
reinterpret_cast<size_t> (this->
left.get())
1620 <<
"\", shape = hexagon, style = filled, fillcolor = black, fontcolor = white];" << std::endl;
1622 auto l = this->
left->to_vizgraph(stream, registers);
1623 stream <<
" " <<
name <<
" -- " << registers[
l.get()] <<
";" << std::endl;
1624 auto r = this->
right->to_vizgraph(stream, registers);
1625 stream <<
" " <<
name <<
" -- " << registers[
r.get()] <<
";" << std::endl;
1677 return this->
right->is_match(
temp->get_right()) &&
1679 (
temp->get_scale() == this->scale) &&
1680 (
temp->get_offset() == this->offset);
1726 template<jit::
float_scalar T,
bool SAFE_MATH=false>
1732 "index_1D requires a variable node for first arg.");
1733 auto temp = std::make_shared<index_1D_node<T, SAFE_MATH>> (
v, x,
1746#if defined(__clang__) || defined(__GNUC__)
1749 assert(
false &&
"Should never reach.");
1754 template<jit::
float_scalar T,
bool SAFE_MATH=false>
1766 template<jit::
float_scalar T,
bool SAFE_MATH=false>
1768 return std::dynamic_pointer_cast<index_1D_node<T, SAFE_MATH>> (x);
1787 template<jit::
float_scalar T,
bool SAFE_MATH=false>
1799 const size_t num_columns;
1852 x, x_scale, x_offset,
1853 y, y_scale, y_offset)),
1854 num_columns(
n), x_scale(x_scale), x_offset(x_offset), y_scale(y_scale),
1855 y_offset(y_offset) {
1857 "Expected the data buffer to be a multiple of the number of columns.");
1870 return this->
left->evaluate();
1903 if (registers.find(
this) == registers.end()) {
1905 const size_t num_rows = length/num_columns;
1916#ifdef USE_INDEX_CACHE
1920 << jit::smallest_uint_type<T> (
num_rows) <<
" "
1924 x->endline(stream,
usage);
1929 << jit::smallest_uint_type<T> (num_columns) <<
" "
1933 y->endline(stream,
usage);
1937 if constexpr (!jit::use_metal<T> () ||
1942 << jit::smallest_uint_type<T> (length) <<
" "
1945 <<
"*" << num_columns <<
" + "
1947 <<
";" << std::endl;
1953 stream <<
" const ";
1954 jit::add_type<T> (stream);
1955 auto var = this->
left->compile(stream,
1959 stream <<
" " << registers[
this] <<
" = "
1961#ifdef USE_INDEX_CACHE
1969 stream <<
"*" << num_columns <<
" + ";
1992 return this->
left->is_match(
x_cast->get_left()) &&
2003 std::cout <<
"r\\_" <<
reinterpret_cast<size_t> (this->
left.get())
2005 <<
reinterpret_cast<size_t> (this->
middle.get())
2007 <<
reinterpret_cast<size_t> (this->
right.get())
2020 if (registers.find(
this) == registers.end()) {
2022 registers[
this] =
name;
2023 stream <<
" " <<
name
2024 <<
" [label = \"r_" <<
reinterpret_cast<size_t> (this->
left.get())
2025 <<
"\", shape = hexagon, style = filled, fillcolor = black, fontcolor = white];" << std::endl;
2027 auto l = this->
left->to_vizgraph(stream, registers);
2028 stream <<
" " <<
name <<
" -- " << registers[
l.get()] <<
";" << std::endl;
2029 auto m = this->
middle->to_vizgraph(stream, registers);
2030 stream <<
" " <<
name <<
" -- " << registers[
m.get()] <<
";" << std::endl;
2031 auto r = this->
right->to_vizgraph(stream, registers);
2032 stream <<
" " <<
name <<
" -- " << registers[
r.get()] <<
";" << std::endl;
2084 return this->
right->is_match(
temp->get_right()) &&
2086 (
temp->get_x_scale() == this->x_scale) &&
2087 (
temp->get_x_offset() == this->x_offset) &&
2088 (
temp->get_y_scale() == this->y_scale) &&
2089 (
temp->get_y_offset() == this->y_offset);
2157 template<jit::
float_scalar T,
bool SAFE_MATH=false>
2167 "index_2D requires a variable node for first arg.");
2168 auto temp = std::make_shared<index_2D_node<T, SAFE_MATH>> (
v,
n,
2169 x, x_scale, x_offset,
2170 y, y_scale, y_offset)->reduce();
2181#if defined(__clang__) || defined(__GNUC__)
2184 assert(
false &&
"Should never reach.");
2189 template<jit::
float_scalar T,
bool SAFE_MATH=false>
2201 template<jit::
float_scalar T,
bool SAFE_MATH=false>
2203 return std::dynamic_pointer_cast<index_2D_node<T, SAFE_MATH>> (x);
Class representing a generic buffer.
Definition backend.hpp:29
Class representing a branch node.
Definition node.hpp:1165
shared_leaf< T, SAFE_MATH > right
Right branch of the tree.
Definition node.hpp:1170
shared_leaf< T, SAFE_MATH > left
Left branch of the tree.
Definition node.hpp:1168
Class representing a 1D index.
Definition piecewise.hpp:1448
virtual shared_leaf< T, SAFE_MATH > get_power_exponent() const
Get the exponent of a power.
Definition piecewise.hpp:1663
virtual backend::buffer< T > evaluate()
Evaluate the results of the piecewise constant.
Definition piecewise.hpp:1501
size_t get_size() const
Get the size of the buffer.
Definition piecewise.hpp:1709
virtual bool is_power_like() const
Test if the node acts like a power of variable.
Definition piecewise.hpp:1654
virtual shared_leaf< T, SAFE_MATH > compile(std::ostringstream &stream, jit::register_map ®isters, jit::register_map &indices, const jit::register_usage &usage)
the node.
Definition piecewise.hpp:1530
T get_scale() const
Get x argument scale.
Definition piecewise.hpp:1691
bool is_arg_match(shared_leaf< T, SAFE_MATH > x)
Check if the args match.
Definition piecewise.hpp:1673
virtual bool is_match(shared_leaf< T, SAFE_MATH > x)
Query if the nodes match.
Definition piecewise.hpp:1585
T get_offset() const
Get x argument offset.
Definition piecewise.hpp:1700
virtual shared_leaf< T, SAFE_MATH > to_vizgraph(std::stringstream &stream, jit::register_map ®isters)
Convert the node to vizgraph.
Definition piecewise.hpp:1613
index_1D_node(shared_leaf< T, SAFE_MATH > var, shared_leaf< T, SAFE_MATH > x, const T scale, const T offset)
Construct a 1D index.
Definition piecewise.hpp:1483
virtual bool is_all_variables() const
Test if node acts like a variable.
Definition piecewise.hpp:1645
virtual shared_leaf< T, SAFE_MATH > df(shared_leaf< T, SAFE_MATH > x)
Transform node to derivative.
Definition piecewise.hpp:1511
virtual bool is_constant() const
Test if node is a constant.
Definition piecewise.hpp:1636
virtual void to_latex() const
Convert the node to latex.
Definition piecewise.hpp:1599
Class representing a 2D index.
Definition piecewise.hpp:1788
size_t get_size() const
Get the size of the buffer.
Definition piecewise.hpp:2136
virtual shared_leaf< T, SAFE_MATH > df(shared_leaf< T, SAFE_MATH > x)
Transform node to derivative.
Definition piecewise.hpp:1879
virtual bool is_power_like() const
Test if the node acts like a power of variable.
Definition piecewise.hpp:2061
virtual backend::buffer< T > evaluate()
Evaluate the results of the piecewise constant.
Definition piecewise.hpp:1869
virtual bool is_match(shared_leaf< T, SAFE_MATH > x)
Query if the nodes match.
Definition piecewise.hpp:1988
virtual void to_latex() const
Convert the node to latex.
Definition piecewise.hpp:2002
T get_x_offset() const
Get x argument offset.
Definition piecewise.hpp:2109
virtual shared_leaf< T, SAFE_MATH > compile(std::ostringstream &stream, jit::register_map ®isters, jit::register_map &indices, const jit::register_usage &usage)
the node.
Definition piecewise.hpp:1899
T get_y_scale() const
Get y argument scale.
Definition piecewise.hpp:2118
virtual shared_leaf< T, SAFE_MATH > get_power_exponent() const
Get the exponent of a power.
Definition piecewise.hpp:2070
bool is_arg_match(shared_leaf< T, SAFE_MATH > x)
Check if the args match.
Definition piecewise.hpp:2080
T get_x_scale() const
Get x argument scale.
Definition piecewise.hpp:2100
virtual shared_leaf< T, SAFE_MATH > to_vizgraph(std::stringstream &stream, jit::register_map ®isters)
Convert the node to vizgraph.
Definition piecewise.hpp:2018
virtual bool is_all_variables() const
Test if node acts like a variable.
Definition piecewise.hpp:2052
T get_y_offset() const
Get y argument offset.
Definition piecewise.hpp:2127
index_2D_node(shared_leaf< T, SAFE_MATH > var, const size_t n, shared_leaf< T, SAFE_MATH > x, const T x_scale, const T x_offset, shared_leaf< T, SAFE_MATH > y, const T y_scale, const T y_offset)
Construct a 2D index.
Definition piecewise.hpp:1842
virtual bool is_constant() const
Test if node is a constant.
Definition piecewise.hpp:2043
Class representing a node leaf.
Definition node.hpp:364
virtual void endline(std::ostringstream &stream, const jit::register_usage &usage) const final
End a line in the kernel source.
Definition node.hpp:639
virtual std::shared_ptr< leaf_node< T, SAFE_MATH > > compile(std::ostringstream &stream, jit::register_map ®isters, jit::register_map &indices, const jit::register_usage &usage)=0
Compile the node.
Class representing a 1D piecewise constant.
Definition piecewise.hpp:105
virtual void compile_preamble(std::ostringstream &stream, jit::register_map ®isters, jit::visiter_map &visited, jit::register_usage &usage, jit::texture1d_list &textures1d, jit::texture2d_list &textures2d, int &avail_const_mem)
Compile preamble.
Definition piecewise.hpp:256
virtual bool is_power_like() const
Test if the node acts like a power of variable.
Definition piecewise.hpp:521
piecewise_1D_node(const backend::buffer< T > &d, shared_leaf< T, SAFE_MATH > x, const T scale, const T offset)
Construct 1D a piecewise constant node.
Definition piecewise.hpp:182
virtual bool is_constant() const
Test if node is a constant.
Definition piecewise.hpp:494
virtual bool is_match(shared_leaf< T, SAFE_MATH > x)
Query if the nodes match.
Definition piecewise.hpp:448
virtual shared_leaf< T, SAFE_MATH > get_power_exponent() const
Get the exponent of a power.
Definition piecewise.hpp:539
virtual shared_leaf< T, SAFE_MATH > reduce()
Reduction method.
Definition piecewise.hpp:213
virtual backend::buffer< T > evaluate()
Evaluate the results of the piecewise constant.
Definition piecewise.hpp:201
virtual shared_leaf< T, SAFE_MATH > df(shared_leaf< T, SAFE_MATH > x)
Transform node to derivative.
Definition piecewise.hpp:241
T get_scale() const
Get x argument scale.
Definition piecewise.hpp:563
virtual void to_latex() const
Convert the node to latex.
Definition piecewise.hpp:462
virtual shared_leaf< T, SAFE_MATH > get_power_base()
Get the base of a power.
Definition piecewise.hpp:530
size_t get_size() const
Get the size of the buffer.
Definition piecewise.hpp:581
virtual bool has_constant_zero() const
Test the constant node has a zero.
Definition piecewise.hpp:503
virtual shared_leaf< T, SAFE_MATH > to_vizgraph(std::stringstream &stream, jit::register_map ®isters)
Convert the node to vizgraph.
Definition piecewise.hpp:473
virtual shared_leaf< T, SAFE_MATH > compile(std::ostringstream &stream, jit::register_map ®isters, jit::register_map &indices, const jit::register_usage &usage)
Compile the node.
Definition piecewise.hpp:349
T get_offset() const
Get x argument offset.
Definition piecewise.hpp:572
virtual bool is_all_variables() const
Test if node acts like a variable.
Definition piecewise.hpp:512
bool is_arg_match(shared_leaf< T, SAFE_MATH > x)
Check if the args match.
Definition piecewise.hpp:549
Class representing a 2D piecewise constant.
Definition piecewise.hpp:686
T get_y_scale() const
Get y argument scale.
Definition piecewise.hpp:843
virtual shared_leaf< T, SAFE_MATH > df(shared_leaf< T, SAFE_MATH > x)
Transform node to derivative.
Definition piecewise.hpp:947
bool is_arg_match(shared_leaf< T, SAFE_MATH > x)
Check if the args match.
Definition piecewise.hpp:1323
T get_y_offset() const
Get y argument offset.
Definition piecewise.hpp:852
virtual bool is_power_like() const
Test if the node acts like a power of variable.
Definition piecewise.hpp:1295
T get_x_scale() const
Get x argument scale.
Definition piecewise.hpp:825
virtual shared_leaf< T, SAFE_MATH > compile(std::ostringstream &stream, jit::register_map ®isters, jit::register_map &indices, const jit::register_usage &usage)
Compile the node.
Definition piecewise.hpp:1072
size_t get_num_columns() const
Get the number of columns.
Definition piecewise.hpp:806
virtual shared_leaf< T, SAFE_MATH > get_power_base()
Get the base of a power.
Definition piecewise.hpp:1304
virtual bool is_match(shared_leaf< T, SAFE_MATH > x)
Query if the nodes match.
Definition piecewise.hpp:1218
virtual bool is_all_variables() const
Test if node acts like a variable.
Definition piecewise.hpp:1286
virtual bool is_constant() const
Test if node is a constant.
Definition piecewise.hpp:1268
size_t get_num_rows() const
Get the number of columns.
Definition piecewise.hpp:815
bool is_col_match(shared_leaf< T, SAFE_MATH > x)
Do the columns match.
Definition piecewise.hpp:1359
T get_x_offset() const
Get x argument offset.
Definition piecewise.hpp:834
virtual void to_latex() const
Convert the node to latex.
Definition piecewise.hpp:1234
virtual shared_leaf< T, SAFE_MATH > to_vizgraph(std::stringstream &stream, jit::register_map ®isters)
Convert the node to vizgraph.
Definition piecewise.hpp:1245
bool is_row_match(shared_leaf< T, SAFE_MATH > x)
Do the rows match.
Definition piecewise.hpp:1342
virtual shared_leaf< T, SAFE_MATH > get_power_exponent() const
Get the exponent of a power.
Definition piecewise.hpp:1313
virtual shared_leaf< T, SAFE_MATH > reduce()
Reduction method.
Definition piecewise.hpp:877
piecewise_2D_node(const backend::buffer< T > &d, const size_t n, shared_leaf< T, SAFE_MATH > x, const T x_scale, const T x_offset, shared_leaf< T, SAFE_MATH > y, const T y_scale, const T y_offset)
Construct 2D a piecewise constant node.
Definition piecewise.hpp:782
virtual backend::buffer< T > evaluate()
Evaluate the results of the piecewise constant.
Definition piecewise.hpp:865
virtual bool has_constant_zero() const
Test the constant node has a zero.
Definition piecewise.hpp:1277
virtual void compile_preamble(std::ostringstream &stream, jit::register_map ®isters, jit::visiter_map &visited, jit::register_usage &usage, jit::texture1d_list &textures1d, jit::texture2d_list &textures2d, int &avail_const_mem)
Compile preamble.
Definition piecewise.hpp:962
Class representing a straight node.
Definition node.hpp:1051
shared_leaf< T, SAFE_MATH > arg
Argument.
Definition node.hpp:1054
Class representing a triple branch node.
Definition node.hpp:1289
shared_leaf< T, SAFE_MATH > middle
Middle branch of the tree.
Definition node.hpp:1292
Complex scalar concept.
Definition register.hpp:24
Double base concept.
Definition register.hpp:42
float base concept.
Definition register.hpp:37
subroutine assert(test, message)
Assert check.
Definition f_binding_test.f90:38
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:1428
constexpr shared_leaf< T, SAFE_MATH > zero()
Forward declare for zero.
Definition node.hpp:986
shared_index_2D< T, SAFE_MATH > index_2D_cast(shared_leaf< T, SAFE_MATH > x)
Cast to a index 2D node.
Definition piecewise.hpp:2202
std::shared_ptr< index_2D_node< T, SAFE_MATH > > shared_index_2D
Convenience type alias for shared index 2D nodes.
Definition piecewise.hpp:2190
shared_piecewise_1D< T, SAFE_MATH > piecewise_1D_cast(shared_leaf< T, SAFE_MATH > x)
Cast to a piecewise 1D node.
Definition piecewise.hpp:637
std::shared_ptr< piecewise_2D_node< T, SAFE_MATH > > shared_piecewise_2D
Convenience type alias for shared piecewise 2D nodes.
Definition piecewise.hpp:1416
shared_constant< T, SAFE_MATH > constant_cast(shared_leaf< T, SAFE_MATH > x)
Cast to a constant node.
Definition node.hpp:1034
shared_variable< T, SAFE_MATH > variable_cast(shared_leaf< T, SAFE_MATH > x)
Cast to a variable node.
Definition node.hpp:1727
std::shared_ptr< piecewise_1D_node< T, SAFE_MATH > > shared_piecewise_1D
Convenience type alias for shared piecewise 1D nodes.
Definition piecewise.hpp:625
constexpr T i
Convenience type for imaginary constant.
Definition node.hpp:1018
std::shared_ptr< leaf_node< T, SAFE_MATH > > shared_leaf
Convenience type alias for shared leaf nodes.
Definition node.hpp:676
std::shared_ptr< index_1D_node< T, SAFE_MATH > > shared_index_1D
Convenience type alias for shared index 1D nodes.
Definition piecewise.hpp:1755
void compile_index(std::ostringstream &stream, const std::string ®ister_name, const size_t length, const T scale, const T offset)
Compile an index.
Definition piecewise.hpp:26
shared_index_1D< T, SAFE_MATH > index_1D_cast(shared_leaf< T, SAFE_MATH > x)
Cast to a index 1D node.
Definition piecewise.hpp:1767
std::map< void *, size_t > texture1d_list
Type alias for indexing 1D textures.
Definition register.hpp:263
std::string format_to_string(const T value)
Convert a value to a string while avoiding locale.
Definition register.hpp:212
std::map< void *, std::array< size_t, 2 > > texture2d_list
Type alias for indexing 2D textures.
Definition register.hpp:265
std::map< void *, size_t > register_usage
Type alias for counting register usage.
Definition register.hpp:259
std::map< void *, std::string > register_map
Type alias for mapping node pointers to register names.
Definition register.hpp:257
constexpr bool use_cuda()
Test to use Cuda.
Definition register.hpp:67
std::set< void * > visiter_map
Type alias for listing visited nodes.
Definition register.hpp:261
std::string to_string(const char prefix, const NODE *pointer)
Convert a graph::leaf_node pointer to a string.
Definition register.hpp:246
Base nodes of graph computation framework.
void index_2D()
Tests for 2D index nodes.
Definition piecewise_test.cpp:868
void piecewise_1D()
Tests for 1D piecewise nodes.
Definition piecewise_test.cpp:80
void index_1D()
Tests for 1D index nodes.
Definition piecewise_test.cpp:834
void piecewise_2D()
Tests for 2D piecewise nodes.
Definition piecewise_test.cpp:319