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++) {
136 return piecewise_1D_node::to_string(
d) +
147 const size_t h = std::hash<std::string>{} (piecewise_1D_node::to_string(
d));
157#if defined(__clang__) || defined(__GNUC__)
160 assert(
false &&
"Should never reach.");
165 const size_t data_hash;
207 const T
arg = (this->arg->evaluate().at(0) + offset)/scale;
209 const size_t i = std::max<float> (std::min<float> (std::real(
arg),
214 const size_t i = std::max<double> (std::min<double> (std::real(
arg),
256 this->
arg->compile_preamble(stream, registers,
264 if constexpr (jit::use_metal<T> ()) {
267#ifdef USE_CUDA_TEXTURES
277 stream <<
"__constant__ ";
281 jit::add_type<T> (stream);
284 jit::add_type<T> (stream);
287 for (
size_t i = 1;
i < length;
i++) {
290 jit::add_type<T> (stream);
294 stream <<
"};" << std::endl;
300 if constexpr (jit::use_metal<T> ()) {
303#ifdef USE_CUDA_TEXTURES
345 if (registers.find(
this) == registers.end()) {
346#ifdef USE_INDEX_CACHE
354#ifdef USE_INDEX_CACHE
357 << jit::smallest_uint_type<T> (length) <<
" "
361 a->endline(stream,
usage);
367 jit::add_type<T> (stream);
368 stream <<
" " << registers[
this] <<
" = ";
369#ifdef USE_CUDA_TEXTURES
373 stream <<
"to_cmp_float(tex1D<float2> (";
375 stream <<
"tex1D<float> (";
379 stream <<
"to_cmp_double(tex1D<uint4> (";
381 stream <<
"to_double(tex1D<uint2> (";
387 if constexpr (jit::use_metal<T> ()) {
388#ifdef USE_INDEX_CACHE
398#ifdef USE_CUDA_TEXTURES
400#ifdef USE_INDEX_CACHE
414#ifdef USE_INDEX_CACHE
444 return this->data_hash ==
x_cast->data_hash &&
455 std::cout <<
"r\\_" <<
reinterpret_cast<size_t> (
this) <<
"_{i}";
467 if (registers.find(
this) == registers.end()) {
469 registers[
this] =
name;
470 stream <<
" " <<
name
471 <<
" [label = \"r_" <<
reinterpret_cast<size_t> (
this)
472 <<
"_{i}\", shape = hexagon, style = filled, fillcolor = black, fontcolor = white];" << std::endl;
474 auto a = this->
arg->to_vizgraph(stream, registers);
475 stream <<
" " <<
name <<
" -- " << registers[
a.get()] <<
";" << std::endl;
544 this->
arg->is_match(
temp->get_arg()) &&
546 (
temp->get_scale() == this->scale) &&
547 (
temp->get_offset() == this->offset);
590 template<jit::
float_scalar T,
bool SAFE_MATH=false>
595 auto temp = std::make_shared<piecewise_1D_node<T, SAFE_MATH>> (
d, x,
608#if defined(__clang__) || defined(__GNUC__)
611 assert(
false &&
"Should never reach.");
616 template<jit::
float_scalar T,
bool SAFE_MATH=false>
628 template<jit::
float_scalar T,
bool SAFE_MATH=false>
630 return std::dynamic_pointer_cast<piecewise_1D_node<T, SAFE_MATH>> (x);
677 template<jit::
float_scalar T,
bool SAFE_MATH=false>
697 for (
size_t i = 0,
ie =
d.size();
i <
ie;
i++) {
715 return piecewise_2D_node::to_string(
d) +
727 const size_t h = std::hash<std::string>{} (piecewise_2D_node::to_string(
d));
737#if defined(__clang__) || defined(__GNUC__)
740 assert(
false &&
"Should never reach.");
745 const size_t data_hash;
747 const size_t num_columns;
772 num_columns(
n), x_scale(x_scale), x_offset(x_offset), y_scale(y_scale),
775 "Expected the data buffer to be a multiple of the number of columns.");
857 const T
l = (this->
left->evaluate().at(0) + x_offset)/x_scale;
858 const T
r = (this->
right->evaluate().at(0) + y_offset)/y_scale;
861 const size_t i = std::max<float> (std::min<float> (std::real(
l),
864 const size_t j = std::max<float> (std::min<float> (std::real(
r),
869 const size_t i = std::max<double> (std::min<double> (std::real(
l),
872 const size_t j = std::max<double> (std::min<double> (std::real(
r),
878 const T
l = (this->
left->evaluate().at(0) + x_offset)/x_scale;
881 const size_t i = std::max<float> (std::min<float> (std::real(
l),
885 this->
right, y_scale, y_offset);
887 const size_t i = std::max<double> (std::min<double> (std::real(
l),
891 this->
right, y_scale, y_offset);
894 const T
r = (this->
right->evaluate().at(0) + y_offset)/y_scale;
897 const size_t j = std::max<float> (std::min<float> (std::real(
r),
901 this->
left, x_scale, x_offset);
903 const size_t j = std::max<double> (std::min<double> (std::real(
r),
907 this->
left, x_scale, x_offset);
947 this->
left->compile_preamble(stream, registers,
951 this->
right->compile_preamble(stream, registers,
959 if constexpr (jit::use_metal<T> ()) {
961 std::array<size_t, 2> ({length/num_columns, num_columns}));
962#ifdef USE_CUDA_TEXTURES
965 std::array<size_t, 2> ({length/num_columns, num_columns}));
972 stream <<
"__constant__ ";
976 jit::add_type<T> (stream);
979 jit::add_type<T> (stream);
982 for (
size_t i = 1;
i < length;
i++) {
985 jit::add_type<T> (stream);
989 stream <<
"};" << std::endl;
995 if constexpr (jit::use_metal<T> ()) {
997 std::array<size_t, 2> ({length/num_columns, num_columns}));
998#ifdef USE_CUDA_TEXTURES
1001 std::array<size_t, 2> ({length/num_columns, num_columns}));
1006#ifdef SHOW_USE_COUNT
1053 if (registers.find(
this) == registers.end()) {
1055 const size_t num_rows = length/num_columns;
1066#ifdef USE_INDEX_CACHE
1070 << jit::smallest_uint_type<T> (
num_rows) <<
" "
1074 x->endline(stream,
usage);
1079 << jit::smallest_uint_type<T> (num_columns) <<
" "
1083 y->endline(stream,
usage);
1087 if constexpr (!jit::use_metal<T> ()
1088#ifdef USE_CUDA_TEXTURES
1095 << jit::smallest_uint_type<T> (length) <<
" "
1098 <<
"*" << num_columns <<
" + "
1100 <<
";" << std::endl;
1106 stream <<
" const ";
1107 jit::add_type<T> (stream);
1108 stream <<
" " << registers[
this] <<
" = ";
1109#ifdef USE_CUDA_TEXTURES
1113 stream <<
"to_cmp_float(tex1D<float2> (";
1115 stream <<
"tex1D<float> (";
1119 stream <<
"to_cmp_double(tex1D<uint4> (";
1121 stream <<
"to_double(tex1D<uint2> (";
1127 if constexpr (jit::use_metal<T> ()) {
1128#ifdef USE_INDEX_CACHE
1130 << jit::smallest_uint_type<T> (std::max(
num_rows,
1138 stream <<
".read(uint2(";
1146#ifdef USE_CUDA_TEXTURES
1148#ifdef USE_INDEX_CACHE
1167#ifdef USE_INDEX_CACHE
1175 stream <<
"*" << num_columns <<
" + ";
1199 return this->data_hash ==
x_cast->data_hash &&
1213 std::cout <<
"r\\_" <<
reinterpret_cast<size_t> (
this) <<
"_{ij}";
1225 if (registers.find(
this) == registers.end()) {
1227 registers[
this] =
name;
1228 stream <<
" " <<
name
1229 <<
" [label = \"r_" <<
reinterpret_cast<size_t> (
this)
1230 <<
"_{ij}\", shape = hexagon, style = filled, fillcolor = black, fontcolor = white];" << std::endl;
1232 auto l = this->
left->to_vizgraph(stream, registers);
1233 stream <<
" " <<
name <<
" -- " << registers[
l.get()] <<
";" << std::endl;
1234 auto r = this->
right->to_vizgraph(stream, registers);
1235 stream <<
" " <<
name <<
" -- " << registers[
r.get()] <<
";" << std::endl;
1303 return temp.get() &&
1304 this->
left->is_match(
temp->get_left()) &&
1305 this->
right->is_match(
temp->get_right()) &&
1308 (
temp->get_x_scale() == this->x_scale) &&
1309 (
temp->get_x_offset() == this->x_offset) &&
1310 (
temp->get_y_scale() == this->y_scale) &&
1311 (
temp->get_y_offset() == this->y_offset);
1322 return temp.get() &&
1323 this->
left->is_match(
temp->get_arg()) &&
1325 (
temp->get_scale() == this->x_scale) &&
1326 (
temp->get_offset() == this->x_offset);
1339 return temp.get() &&
1340 this->
right->is_match(
temp->get_arg()) &&
1342 (
temp->get_scale() == this->y_scale) &&
1343 (
temp->get_offset() == this->y_offset);
1363 template<jit::
float_scalar T,
bool SAFE_MATH=false>
1372 auto temp = std::make_shared<piecewise_2D_node<T, SAFE_MATH>> (
d,
n,
1373 x, x_scale, x_offset,
1374 y, y_scale, y_offset)->reduce();
1385#if defined(__clang__) || defined(__GNUC__)
1388 assert(
false &&
"Should never reach.");
1393 template<jit::
float_scalar T,
bool SAFE_MATH=false>
1405 template<jit::
float_scalar T,
bool SAFE_MATH=false>
1407 return std::dynamic_pointer_cast<piecewise_2D_node<T, SAFE_MATH>> (x);
1425 template<jit::
float_scalar T,
bool SAFE_MATH=false>
1460 scale(scale), offset(offset) {}
1472 return this->
right->evaluate();
1504 if (registers.find(
this) == registers.end()) {
1505#ifdef USE_INDEX_CACHE
1513#ifdef USE_INDEX_CACHE
1516 << jit::smallest_uint_type<T> (length) <<
" "
1520 a->endline(stream,
usage);
1525 stream <<
" const ";
1526 jit::add_type<T> (stream);
1527 auto var = this->
left->compile(stream,
1531 stream <<
" " << registers[
this] <<
" = "
1533#ifdef USE_INDEX_CACHE
1551 std::cout <<
"r\\_" <<
reinterpret_cast<size_t> (this->
left.get())
1553 <<
reinterpret_cast<size_t> (this->
right.get())
1566 if (registers.find(
this) == registers.end()) {
1568 registers[
this] =
name;
1569 stream <<
" " <<
name
1570 <<
" [label = \"r_" <<
reinterpret_cast<size_t> (this->
left.get())
1571 <<
"\", shape = hexagon, style = filled, fillcolor = black, fontcolor = white];" << std::endl;
1573 auto l = this->
left->to_vizgraph(stream, registers);
1574 stream <<
" " <<
name <<
" -- " << registers[
l.get()] <<
";" << std::endl;
1575 auto r = this->
right->to_vizgraph(stream, registers);
1576 stream <<
" " <<
name <<
" -- " << registers[
r.get()] <<
";" << std::endl;
1626 return temp.get() &&
1627 this->
right->is_match(
temp->get_right()) &&
1629 (
temp->get_scale() == this->scale) &&
1630 (
temp->get_offset() == this->offset);
1673 template<jit::
float_scalar T,
bool SAFE_MATH=false>
1679 "index_1D requires a variable node for first arg.");
1680 auto temp = std::make_shared<index_1D_node<T, SAFE_MATH>> (
v, x,
1693#if defined(__clang__) || defined(__GNUC__)
1696 assert(
false &&
"Should never reach.");
1701 template<jit::
float_scalar T,
bool SAFE_MATH=false>
1713 template<jit::
float_scalar T,
bool SAFE_MATH=false>
1715 return std::dynamic_pointer_cast<index_1D_node<T, SAFE_MATH>> (x);
1734 template<jit::
float_scalar T,
bool SAFE_MATH=false>
1746 const size_t num_columns;
1786 num_columns(
n), x_scale(x_scale), x_offset(x_offset), y_scale(y_scale),
1787 y_offset(y_offset) {
1789 "Expected the data buffer to be a multiple of the number of columns.");
1802 return this->
left->evaluate();
1835 if (registers.find(
this) == registers.end()) {
1837 const size_t num_rows = length/num_columns;
1848#ifdef USE_INDEX_CACHE
1852 << jit::smallest_uint_type<T> (
num_rows) <<
" "
1856 x->endline(stream,
usage);
1861 << jit::smallest_uint_type<T> (num_columns) <<
" "
1865 y->endline(stream,
usage);
1869 if constexpr (!jit::use_metal<T> () ||
1874 << jit::smallest_uint_type<T> (length) <<
" "
1877 <<
"*" << num_columns <<
" + "
1879 <<
";" << std::endl;
1885 stream <<
" const ";
1886 jit::add_type<T> (stream);
1887 auto var = this->
left->compile(stream,
1891 stream <<
" " << registers[
this] <<
" = "
1893#ifdef USE_INDEX_CACHE
1901 stream <<
"*" << num_columns <<
" + ";
1916 std::cout <<
"r\\_" <<
reinterpret_cast<size_t> (this->
left.get())
1918 <<
reinterpret_cast<size_t> (this->
middle.get())
1920 <<
reinterpret_cast<size_t> (this->
right.get())
1933 if (registers.find(
this) == registers.end()) {
1935 registers[
this] =
name;
1936 stream <<
" " <<
name
1937 <<
" [label = \"r_" <<
reinterpret_cast<size_t> (this->
left.get())
1938 <<
"\", shape = hexagon, style = filled, fillcolor = black, fontcolor = white];" << std::endl;
1940 auto l = this->
left->to_vizgraph(stream, registers);
1941 stream <<
" " <<
name <<
" -- " << registers[
l.get()] <<
";" << std::endl;
1942 auto m = this->
middle->to_vizgraph(stream, registers);
1943 stream <<
" " <<
name <<
" -- " << registers[
m.get()] <<
";" << std::endl;
1944 auto r = this->
right->to_vizgraph(stream, registers);
1945 stream <<
" " <<
name <<
" -- " << registers[
r.get()] <<
";" << std::endl;
1995 return temp.get() &&
1996 this->
right->is_match(
temp->get_right()) &&
1998 (
temp->get_scale() == this->scale) &&
1999 (
temp->get_offset() == this->offset);
2064 template<jit::
float_scalar T,
bool SAFE_MATH=false>
2074 "index_2D requires a variable node for first arg.");
2075 auto temp = std::make_shared<index_2D_node<T, SAFE_MATH>> (
v,
n,
2076 x, x_scale, x_offset,
2077 y, y_scale, y_offset)->reduce();
2088#if defined(__clang__) || defined(__GNUC__)
2091 assert(
false &&
"Should never reach.");
2096 template<jit::
float_scalar T,
bool SAFE_MATH=false>
2108 template<jit::
float_scalar T,
bool SAFE_MATH=false>
2110 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:1426
virtual shared_leaf< T, SAFE_MATH > get_power_exponent() const
Get the exponent of a power.
Definition piecewise.hpp:1614
virtual backend::buffer< T > evaluate()
Evaluate the results of the piecewise constant.
Definition piecewise.hpp:1471
size_t get_size() const
Get the size of the buffer.
Definition piecewise.hpp:1656
virtual bool is_power_like() const
Test if the node acts like a power of variable.
Definition piecewise.hpp:1605
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:1500
T get_scale() const
Get x argument scale.
Definition piecewise.hpp:1638
bool is_arg_match(shared_leaf< T, SAFE_MATH > x)
Check if the args match.
Definition piecewise.hpp:1624
T get_offset() const
Get x argument offset.
Definition piecewise.hpp:1647
virtual shared_leaf< T, SAFE_MATH > to_vizgraph(std::stringstream &stream, jit::register_map ®isters)
Convert the node to vizgraph.
Definition piecewise.hpp:1564
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:1455
virtual bool is_all_variables() const
Test if node acts like a variable.
Definition piecewise.hpp:1596
virtual shared_leaf< T, SAFE_MATH > df(shared_leaf< T, SAFE_MATH > x)
Transform node to derivative.
Definition piecewise.hpp:1481
virtual bool is_constant() const
Test if node is a constant.
Definition piecewise.hpp:1587
virtual void to_latex() const
Convert the node to latex.
Definition piecewise.hpp:1550
Class representing a 2D index.
Definition piecewise.hpp:1735
size_t get_size() const
Get the size of the buffer.
Definition piecewise.hpp:2043
virtual shared_leaf< T, SAFE_MATH > df(shared_leaf< T, SAFE_MATH > x)
Transform node to derivative.
Definition piecewise.hpp:1811
virtual bool is_power_like() const
Test if the node acts like a power of variable.
Definition piecewise.hpp:1974
virtual backend::buffer< T > evaluate()
Evaluate the results of the piecewise constant.
Definition piecewise.hpp:1801
virtual void to_latex() const
Convert the node to latex.
Definition piecewise.hpp:1915
T get_x_offset() const
Get x argument offset.
Definition piecewise.hpp:2016
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:1831
T get_y_scale() const
Get y argument scale.
Definition piecewise.hpp:2025
virtual shared_leaf< T, SAFE_MATH > get_power_exponent() const
Get the exponent of a power.
Definition piecewise.hpp:1983
bool is_arg_match(shared_leaf< T, SAFE_MATH > x)
Check if the args match.
Definition piecewise.hpp:1993
T get_x_scale() const
Get x argument scale.
Definition piecewise.hpp:2007
virtual shared_leaf< T, SAFE_MATH > to_vizgraph(std::stringstream &stream, jit::register_map ®isters)
Convert the node to vizgraph.
Definition piecewise.hpp:1931
virtual bool is_all_variables() const
Test if node acts like a variable.
Definition piecewise.hpp:1965
T get_y_offset() const
Get y argument offset.
Definition piecewise.hpp:2034
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:1777
virtual bool is_constant() const
Test if node is a constant.
Definition piecewise.hpp:1956
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 bool is_match(std::shared_ptr< leaf_node< T, SAFE_MATH > > x)
Query if the nodes match.
Definition node.hpp:472
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:248
virtual bool is_power_like() const
Test if the node acts like a power of variable.
Definition piecewise.hpp:513
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:176
virtual bool is_constant() const
Test if node is a constant.
Definition piecewise.hpp:486
virtual bool is_match(shared_leaf< T, SAFE_MATH > x)
Query if the nodes match.
Definition piecewise.hpp:440
virtual shared_leaf< T, SAFE_MATH > get_power_exponent() const
Get the exponent of a power.
Definition piecewise.hpp:531
virtual shared_leaf< T, SAFE_MATH > reduce()
Reduction method.
Definition piecewise.hpp:205
virtual backend::buffer< T > evaluate()
Evaluate the results of the piecewise constant.
Definition piecewise.hpp:193
virtual shared_leaf< T, SAFE_MATH > df(shared_leaf< T, SAFE_MATH > x)
Transform node to derivative.
Definition piecewise.hpp:233
T get_scale() const
Get x argument scale.
Definition piecewise.hpp:555
virtual void to_latex() const
Convert the node to latex.
Definition piecewise.hpp:454
virtual shared_leaf< T, SAFE_MATH > get_power_base()
Get the base of a power.
Definition piecewise.hpp:522
size_t get_size() const
Get the size of the buffer.
Definition piecewise.hpp:573
virtual bool has_constant_zero() const
Test the constant node has a zero.
Definition piecewise.hpp:495
virtual shared_leaf< T, SAFE_MATH > to_vizgraph(std::stringstream &stream, jit::register_map ®isters)
Convert the node to vizgraph.
Definition piecewise.hpp:465
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:341
T get_offset() const
Get x argument offset.
Definition piecewise.hpp:564
virtual bool is_all_variables() const
Test if node acts like a variable.
Definition piecewise.hpp:504
bool is_arg_match(shared_leaf< T, SAFE_MATH > x)
Check if the args match.
Definition piecewise.hpp:541
Class representing a 2D piecewise constant.
Definition piecewise.hpp:678
T get_y_scale() const
Get y argument scale.
Definition piecewise.hpp:820
virtual shared_leaf< T, SAFE_MATH > df(shared_leaf< T, SAFE_MATH > x)
Transform node to derivative.
Definition piecewise.hpp:924
bool is_arg_match(shared_leaf< T, SAFE_MATH > x)
Check if the args match.
Definition piecewise.hpp:1301
T get_y_offset() const
Get y argument offset.
Definition piecewise.hpp:829
virtual bool is_power_like() const
Test if the node acts like a power of variable.
Definition piecewise.hpp:1273
T get_x_scale() const
Get x argument scale.
Definition piecewise.hpp:802
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:1049
size_t get_num_columns() const
Get the number of columns.
Definition piecewise.hpp:783
virtual shared_leaf< T, SAFE_MATH > get_power_base()
Get the base of a power.
Definition piecewise.hpp:1282
virtual bool is_match(shared_leaf< T, SAFE_MATH > x)
Query if the nodes match.
Definition piecewise.hpp:1195
virtual bool is_all_variables() const
Test if node acts like a variable.
Definition piecewise.hpp:1264
virtual bool is_constant() const
Test if node is a constant.
Definition piecewise.hpp:1246
size_t get_num_rows() const
Get the number of columns.
Definition piecewise.hpp:792
bool is_col_match(shared_leaf< T, SAFE_MATH > x)
Do the columns match.
Definition piecewise.hpp:1337
T get_x_offset() const
Get x argument offset.
Definition piecewise.hpp:811
virtual void to_latex() const
Convert the node to latex.
Definition piecewise.hpp:1212
virtual shared_leaf< T, SAFE_MATH > to_vizgraph(std::stringstream &stream, jit::register_map ®isters)
Convert the node to vizgraph.
Definition piecewise.hpp:1223
bool is_row_match(shared_leaf< T, SAFE_MATH > x)
Do the rows match.
Definition piecewise.hpp:1320
virtual shared_leaf< T, SAFE_MATH > get_power_exponent() const
Get the exponent of a power.
Definition piecewise.hpp:1291
virtual shared_leaf< T, SAFE_MATH > reduce()
Reduction method.
Definition piecewise.hpp:854
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:762
virtual backend::buffer< T > evaluate()
Evaluate the results of the piecewise constant.
Definition piecewise.hpp:842
virtual bool has_constant_zero() const
Test the constant node has a zero.
Definition piecewise.hpp:1255
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:939
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:1406
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:2109
std::shared_ptr< index_2D_node< T, SAFE_MATH > > shared_index_2D
Convenience type alias for shared index 2D nodes.
Definition piecewise.hpp:2097
shared_piecewise_1D< T, SAFE_MATH > piecewise_1D_cast(shared_leaf< T, SAFE_MATH > x)
Cast to a piecewise 1D node.
Definition piecewise.hpp:629
std::shared_ptr< piecewise_2D_node< T, SAFE_MATH > > shared_piecewise_2D
Convenience type alias for shared piecewise 2D nodes.
Definition piecewise.hpp:1394
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:617
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:1702
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:1714
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:834
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:807
void piecewise_2D()
Tests for 2D piecewise nodes.
Definition piecewise_test.cpp:306