|
| | 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.
|
| |
| size_t | get_num_columns () const |
| | Get the number of columns.
|
| |
| size_t | get_num_rows () const |
| | Get the number of columns.
|
| |
| T | get_x_scale () const |
| | Get x argument scale.
|
| |
| T | get_x_offset () const |
| | Get x argument offset.
|
| |
| T | get_y_scale () const |
| | Get y argument scale.
|
| |
| T | get_y_offset () const |
| | Get y argument offset.
|
| |
| virtual backend::buffer< T > | evaluate () |
| | Evaluate the results of the piecewise constant.
|
| |
| virtual shared_leaf< T, SAFE_MATH > | reduce () |
| | Reduction method.
|
| |
| virtual shared_leaf< T, SAFE_MATH > | df (shared_leaf< T, SAFE_MATH > x) |
| | Transform node to derivative.
|
| |
| 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.
|
| |
| 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.
|
| |
| virtual bool | is_match (shared_leaf< T, SAFE_MATH > x) |
| | Querey if the nodes match.
|
| |
| virtual void | to_latex () const |
| | Convert the node to latex.
|
| |
| virtual shared_leaf< T, SAFE_MATH > | to_vizgraph (std::stringstream &stream, jit::register_map ®isters) |
| | Convert the node to vizgraph.
|
| |
| virtual bool | is_constant () const |
| | Test if node is a constant.
|
| |
| virtual bool | has_constant_zero () const |
| | Test the constant node has a zero.
|
| |
| virtual bool | is_all_variables () const |
| | Test if node acts like a variable.
|
| |
| virtual bool | is_power_like () const |
| | Test if the node acts like a power of variable.
|
| |
| virtual shared_leaf< T, SAFE_MATH > | get_power_base () |
| | Get the base of a power.
|
| |
| virtual shared_leaf< T, SAFE_MATH > | get_power_exponent () const |
| | Get the exponent of a power.
|
| |
| bool | is_arg_match (shared_leaf< T, SAFE_MATH > x) |
| | Check if the args match.
|
| |
| bool | is_row_match (shared_leaf< T, SAFE_MATH > x) |
| | Do the rows match.
|
| |
| bool | is_col_match (shared_leaf< T, SAFE_MATH > x) |
| | Do the columns match.
|
| |
| | branch_node (shared_leaf< T, SAFE_MATH > l, shared_leaf< T, SAFE_MATH > r, const std::string s) |
| | Assigns the left and right branches.
|
| |
| | branch_node (shared_leaf< T, SAFE_MATH > l, shared_leaf< T, SAFE_MATH > r, const std::string s, const size_t count, const bool pseudo) |
| | Assigns the left and right branches.
|
| |
|
shared_leaf< T, SAFE_MATH > | get_left () |
| | Get the left branch.
|
| |
|
shared_leaf< T, SAFE_MATH > | get_right () |
| | Get the right branch.
|
| |
| | leaf_node (const std::string s, const size_t count, const bool pseudo) |
| | Construct a basic node.
|
| |
|
virtual | ~leaf_node () |
| | Destructor.
|
| |
| virtual std::shared_ptr< leaf_node< T, SAFE_MATH > > | df (std::shared_ptr< leaf_node< T, SAFE_MATH > > x)=0 |
| | Transform node to derivative.
|
| |
| virtual bool | is_match (std::shared_ptr< leaf_node< T, SAFE_MATH > > x) |
| | Querey if the nodes match.
|
| |
| bool | is_power_base_match (std::shared_ptr< leaf_node< T, SAFE_MATH > > x) |
| | Check if the base of the powers match.
|
| |
| virtual void | set (const T d) |
| | Set the value of variable data.
|
| |
| virtual void | set (const size_t index, const T d) |
| | Set the value of variable data.
|
| |
| virtual void | set (const std::vector< T > &d) |
| | Set the value of variable data.
|
| |
| virtual void | set (const backend::buffer< T > &d) |
| | Set the value of variable data.
|
| |
| bool | is_normal () |
| | Test if the result is normal.
|
| |
| size_t | get_hash () const |
| | Get the hash for the node.
|
| |
| size_t | get_complexity () const |
| | Get the number of nodes in the subgraph.
|
| |
| virtual bool | has_pseudo () const |
| | Query if the node contains pseudo variables.
|
| |
| virtual std::shared_ptr< leaf_node< T, SAFE_MATH > > | remove_pseudo () |
| | Remove pseudo variable nodes.
|
| |
| virtual void | endline (std::ostringstream &stream, const jit::register_usage &usage) const final |
| | End a line in the kernel source.
|
| |
Class representing a 2D piecewise constant.
This class is used to impliment the coefficent terms of bicubic spline interpolation. An function is interpolated using
z(x,y) = Σ_i,3Σ_j,3 c_ij*x^i*y^j (1)
The aguments x and y are assumed to be the normalized arguments
x_norm = (x - xmin)/dx - i (2) y_norm = (y - ymin)/dy - j (3)
To avoid tracking the indices i and j which normaizes x and y to a zero to one interval the coefficients should be normalized to
c00'_ij = Σ_k,3Σ_l,3 (-i)^k*(-j)^l*ckl_ij (4) c10'_ij = Σ_k,3Σ_l,3 k*(-i)^(k-1)*(-j)^l*ckl_ij (5) c01'_ij = Σ_k,3Σ_l,3 l*(-i)^k*(-j)^(l-1)*ckl_ij (6) c20'_ij = Σ_k,3Σ_l,3 Max(2*k-3,0)*(-i)^(k-2)*(-j)^l*ckl_ij (7) c02'_ij = Σ_k,3Σ_l,3 Max(2*l-3,0)*(-i)^k*(-j)^(l-2)*ckl_ij (8) c30'_ij = Σ_k,3Σ_l,3 Max(k-2,0)*(-i)^(k-3)*(-j)^l*ckl_ij (9) c03'_ij = Σ_k,3Σ_l,3 Max(l-2,0)*(-i)^k*(-j)^(l-3)*ckl_ij (10) c11'_ij = Σ_k,3Σ_l,3 k*l*(-i)^(k-1)*(-j)^(j-1) (11) c21'_ij = Σ_k,3Σ_l,3 Max(2*k-3,0)*l*(-i)^(k-2)*(-j)^(j-1) (12) c12'_ij = Σ_k,3Σ_l,3 k*Max(2*l-3,0)*(-i)^(k-1)*(-j)^(j-2) (13) c31'_ij = Σ_k,3Σ_l,3 Max(k-2,0)*l*(-i)^(k-3)*(-j)^(j-1) (14) c13'_ij = Σ_k,3Σ_l,3 k*Max(l-2,0)*(-i)^(k-1)*(-j)^(j-3) (15) c22'_ij = Σ_k,3Σ_l,3 Max(2*k-3,0)*Max(2*l-3,0)*(-i)^(k-2)*(-j)^(j-2) (16) c32'_ij = Σ_k,3Σ_l,3 Max(k-2,0)*Max(2*l-3,0)*(-i)^(k-3)*(-j)^(j-2) (17) c23'_ij = Σ_k,3Σ_l,3 Max(2*k-3,0)*Max(l-2,0)*(-i)^(k-2)*(-j)^(j-3) (18) c33'_ij = Σ_k,3Σ_l,3 Max(k-2,0)*Max(l-2,0)*(-i)^(k-3)*(-j)^(j-3) (19)
This makes the normalized arguments (6,7) become
x_norm' = (x - xmin)/dx (20) y_norm' = (y - ymin)/dy (21)
- Template Parameters
-
| T | Base type of the calculation. |
| SAFE_MATH | Use Safe Math operations. |
Compile the node.
This node first evaluates the value of the argument then chooses the correct piecewise index. This assumes that the argument is
x' = (x - xmin)/dx (1) y' = (y - ymin)/dy (2)
and the spline coefficients are of the form.
c00'_ij = Σ_k,3Σ_l,3 (-i)^k*(-j)^l*ckl_ij (3) c10'_ij = Σ_k,3Σ_l,3 k*(-i)^(k-1)*(-j)^l*ckl_ij (4) c01'_ij = Σ_k,3Σ_l,3 l*(-i)^k*(-j)^(l-1)*ckl_ij (5) c20'_ij = Σ_k,3Σ_l,3 Max(2*k-3,0)*(-i)^(k-2)*(-j)^l*ckl_ij (6) c02'_ij = Σ_k,3Σ_l,3 Max(2*l-3,0)*(-i)^k*(-j)^(l-2)*ckl_ij (7) c30'_ij = Σ_k,3Σ_l,3 Max(k-2,0)*(-i)^(k-3)*(-j)^l*ckl_ij (8) c03'_ij = Σ_k,3Σ_l,3 Max(l-2,0)*(-i)^k*(-j)^(l-3)*ckl_ij (9) c11'_ij = Σ_k,3Σ_l,3 k*l*(-i)^(k-1)*(-j)^(j-1) (10) c21'_ij = Σ_k,3Σ_l,3 Max(2*k-3,0)*l*(-i)^(k-2)*(-j)^(j-1) (11) c12'_ij = Σ_k,3Σ_l,3 k*Max(2*l-3,0)*(-i)^(k-1)*(-j)^(j-2) (12) c31'_ij = Σ_k,3Σ_l,3 Max(k-2,0)*l*(-i)^(k-3)*(-j)^(j-1) (13) c13'_ij = Σ_k,3Σ_l,3 k*Max(l-2,0)*(-i)^(k-1)*(-j)^(j-3) (14) c22'_ij = Σ_k,3Σ_l,3 Max(2*k-3,0)*Max(2*l-3,0)*(-i)^(k-2)*(-j)^(j-2) (15) c32'_ij = Σ_k,3Σ_l,3 Max(k-2,0)*Max(2*l-3,0)*(-i)^(k-3)*(-j)^(j-2) (16) c23'_ij = Σ_k,3Σ_l,3 Max(2*k-3,0)*Max(l-2,0)*(-i)^(k-2)*(-j)^(j-3) (17) c33'_ij = Σ_k,3Σ_l,3 Max(k-2,0)*Max(l-2,0)*(-i)^(k-3)*(-j)^(j-3) (18)
- Parameters
-
| [in,out] | stream | String buffer stream. |
| [in,out] | registers | List of defined registers. |
| [in,out] | indices | List of defined indices. |
| [in] | usage | List of register usage count. |
- Returns
- The current node.
Implements graph::leaf_node< T, SAFE_MATH >.